-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenemy_dir.c
85 lines (80 loc) · 3.92 KB
/
enemy_dir.c
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* enemy_dir.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: phelebra <xhelp00@gmail.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/06/10 16:50:14 by jbartosi #+# #+# */
/* Updated: 2023/10/16 16:05:02 by phelebra ### ########.fr */
/* */
/* ************************************************************************** */
#include "cub3d.h"
void leech_vertical(t_box *box, t_sprite *sprites, int dir)
{
if (dir == UP)
box->info.color = extract_color(&box->textures[sprites->data->texture]
.addr[((box->info.tex_x + 16 + 32 * ((int)((box->time.tv_usec
/ 100000.0) * 6) / 10)) * 4) + box
->textures[sprites->data->texture].line_len * box->info.tex_y
+ box->textures[sprites->data->texture].line_len * 16]);
else if (dir == DOWN)
box->info.color = extract_color(&box->textures[sprites->data->texture]
.addr[((box->info.tex_x + 16 + 32 * ((int)((box->time.tv_usec
/ 100000.0) * 6) / 10)) * 4) + box
->textures[sprites->data->texture].line_len * box->info.tex_y
+ box->textures[sprites->data->texture].line_len * 48]);
}
void leech_horizontal(t_box *box, t_sprite *sprites, int dir)
{
if (dir == LEFT && !box->info.flipped)
{
box->info.tex_x = 46 - (box->info.tex_x - 16);
box->info.flipped = 1;
box->info.color = extract_color(&box->textures[sprites->data->texture]
.addr[((box->info.tex_x + 16 + 32 * ((int)((box->time.tv_usec
/ 100000.0) * 6) / 10)) * 4)
+ box->textures[sprites->data->texture].line_len * box->info
.tex_y + box->textures[sprites->data->texture].line_len * -16]);
}
else
box->info.color = extract_color(&box->textures[sprites->data->texture]
.addr[((box->info.tex_x + 16 + 32 * ((int)((box->time.tv_usec
/ 100000.0) * 6) / 10)) * 4) + box
->textures[sprites->data->texture].line_len * box->info.tex_y
+ box->textures[sprites->data->texture].line_len * -16]);
}
void larry_vertical(t_box *box, t_sprite *sprites, int dir)
{
if (dir == UP)
box->info.color = extract_color(&box->textures[sprites->data->texture]
.addr[((box->info.tex_x + 32 + 48) * 4) + box->textures[sprites
->data->texture].line_len * box->info.tex_y + box
->textures[sprites->data->texture].line_len * (-20 + 48
* ((int)((box->time.tv_usec / 100000.0) * 2) / 10))]);
else if (dir == DOWN)
box->info.color = extract_color(&box->textures[sprites->data->texture]
.addr[((box->info.tex_x - 16 + 48 - 48 * ((int)((box->time
.tv_usec / 100000.0) * 2) / 10)) * 4) + box
->textures[sprites->data->texture].line_len * box->info.tex_y
+ box->textures[sprites->data->texture].line_len * 28]);
}
void larry_horizontal(t_box *box, t_sprite *sprites, int dir)
{
if (dir == LEFT && !box->info.flipped)
{
box->info.tex_x = 62 - (box->info.tex_x - 16);
box->info.flipped = 1;
box->info.color = extract_color(&box->textures[sprites->data->texture]
.addr[((box->info.tex_x - 16 + 48 - 48 * ((int)((box->time
.tv_usec / 100000.0) * 2) / 10)) * 4) + box
->textures[sprites->data->texture].line_len * box->info.tex_y
+ box->textures[sprites->data->texture].line_len * -20]);
}
else
box->info.color = extract_color(&box->textures[sprites->data->texture]
.addr[((box->info.tex_x - 16 + 48 - 48 * ((int)((box->time
.tv_usec / 100000.0) * 2) / 10)) * 4) + box
->textures[sprites->data->texture].line_len * box->info.tex_y
+ box->textures[sprites->data->texture].line_len * -20]);
}