-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_draw.c
More file actions
96 lines (88 loc) · 2.59 KB
/
Copy pathft_draw.c
File metadata and controls
96 lines (88 loc) · 2.59 KB
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
86
87
88
89
90
91
92
93
94
95
96
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_draw.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bsautron <bsautron@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/01/20 20:32:16 by bsautron #+# #+# */
/* Updated: 2015/03/31 06:47:48 by bsautron ### ########.fr */
/* */
/* ************************************************************************** */
#include "wolf3d.h"
static void ft_another(t_env *env, int x, double h)
{
double plafond;
double sol;
plafond = 0;
while (plafond < env->mid - h / 2)
{
env->img.char_img[x * 4 + (int)plafond * P0L] = 70;
env->img.char_img[x * 4 + (int)plafond * P0L + 1] = 70;
env->img.char_img[x * 4 + (int)plafond * P0L + 2] = 70;
plafond++;
}
sol = HEIGHT - 1;
while (sol > env->mid + h / 2)
{
env->img.char_img[x * 4 + (int)sol * P0L] = 50;
env->img.char_img[x * 4 + (int)sol * P0L + 1] = 50;
env->img.char_img[x * 4 + (int)sol * P0L + 2] = 50;
sol--;
}
}
static int ft_the_m(t_env *env)
{
double d;
int the_mur_x;
if (env->alpha >= 360)
env->alpha -= 360;
if (env->alpha < 0)
env->alpha += 360;
d = ft_calcul(env, env->alpha);
d = d * cos(ft_dtor(env->bruno.angle - env->alpha));
env->h = env->sz_wall / d * env->bruno.d_proj;
if (env->input.accu)
env->h *= 1.5;
if (env->vorh == 'h')
the_mur_x = ((int)env->hit.x
* env->pic[0].width / env->sz_wall) % (int)env->pic[0].width;
else
the_mur_x = ((int)env->hit.y
* env->pic[0].width / env->sz_wall) % (int)env->pic[0].width;
return (the_mur_x);
}
static void ft_prev(t_env *env)
{
env->alpha = env->bruno.angle + 30;
if (env->input.up)
env->bruno.move += 0.14;
else
env->bruno.move = 0;
if (env->input.accu)
{
env->i_angle = 40.0 / (double)env->w_win;
env->alpha -= 10;
}
else
env->i_angle = 60.0 / (double)env->w_win;
}
void ft_draw(t_env *env)
{
size_t x;
int the_mur_x;
ft_prev(env);
x = 0;
while (x < env->w_win)
{
the_mur_x = ft_the_m(env);
ft_another(env, x, env->h);
ft_mur(env, x, env->h, the_mur_x);
env->alpha = env->alpha - env->i_angle;
x++;
}
if (env->input.accu)
ft_arme(env, 1);
else
ft_arme(env, 0);
}