-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_form.c
71 lines (66 loc) · 1.95 KB
/
draw_form.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* draw_form.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gsauvair <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/05/03 23:33:47 by gsauvair #+# #+# */
/* Updated: 2015/05/03 23:33:49 by gsauvair ### ########.fr */
/* */
/* ************************************************************************** */
#include "arkanoid.h"
static void brick_color(char c)
{
if (c == '1')
glColor3b(51, 51, 127);
if (c == '2')
glColor3b(127, 0, 63);
if (c == '3')
glColor3b(127, 51, 51);
if (c == '4')
glColor3b(127, 0, 0);
}
static int yolo_suague(t_env *env, int i, int *test)
{
if (test_col(env, i, test))
{
if (env->map[i] != '4')
{
env->map[i]--;
env->score += 5;
}
}
if (env->map[i] != '0' && i < 139)
{
glBegin(GL_QUADS);
brick_color(env->map[i]);
glVertex2f(env->squa.x - X_VAR, env->squa.y - Y_VAR);
glVertex2f(env->squa.x + X_VAR, env->squa.y - Y_VAR);
glVertex2f(env->squa.x + X_VAR, env->squa.y + Y_VAR);
glVertex2f(env->squa.x - X_VAR, env->squa.y + Y_VAR);
glEnd();
}
env->squa.x = env->squa.x + X_INC;
return (i + 1);
}
void square_create(t_env *env)
{
int i;
int test;
i = 0;
test = 0;
while (i < 139)
{
while (env->map[i] != '\n' && i < 139)
i = yolo_suague(env, i, &test);
if (env->map[i] == '\n')
{
env->squa.x = X_BEGIN;
env->squa.y = env->squa.y - 0.092f;
i++;
}
}
env->squa.x = X_BEGIN;
env->squa.y = Y_BEGIN;
}