blob: 701587f1bc4e48d7a3ddb84f892d5a634ec0b33b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_draw_sprite.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/24 20:22:45 by rbousset #+# #+# */
/* Updated: 2020/02/24 20:22:47 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <cub3d.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void
ft_draw_sprite(t_cub *cl, t_sprite *sprite)
{
int32_t d;
sprite->x = sprite->drawstartx;
while (sprite->x < sprite->drawendx)
{
sprite->tex_x = (int32_t)((sprite->x - (-sprite->spritewidth / 2 +
sprite->spritescreenx)) * cl->tlist[4].img_w / sprite->spritewidth);
sprite->y = sprite->drawstarty;
if (sprite->transformy > 0 && sprite->x >= 0 &&
sprite->x < (int32_t)cl->wlist->x_size)
while (sprite->y < sprite->drawendy)
{
puts("qwe");
d = (sprite->y) * 256 - cl->wlist->y_size * 128 +
sprite->spriteheight * 128;
sprite->tex_y = ((d * cl->tlist[4].img_h) /
sprite->spriteheight) / 128;
if (*(cl->tlist[4].ptr + sprite->tex_x + sprite->tex_y *
cl->tlist[4].sizeline / 4))
cl->img.ptr[sprite->x + sprite->y *
cl->img.sizeline / 4] =
*(cl->tlist[4].ptr + sprite->tex_x + sprite->tex_y * cl->tlist[4].sizeline / 4);
sprite->y++;
}
sprite->x++;
}
}
|