-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbullle.c
61 lines (52 loc) · 1.01 KB
/
bullle.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
#include "bullet.h"
/*
Cria a estrutura da bala
parameters: void
return: BULLET
*/
BULLET *createBullet(unsigned short x, unsigned short y){
BULLET *bullet = (BULLET*) calloc(1, sizeof(BULLET));
if(bullet){
bullet->body = '.';
bullet->position = createPosition();
bullet->position->x = x;
bullet->position->y = y;
}
return bullet;
}
/*
Renderiza bala na tela
parameters: void
return: void
*/
void renderBullet(BULLET *bullet){
if(bullet){
gotoXY(bullet->position->x, bullet->position->y);
printf("%c", bullet->body);
}
}
/*
Função que limpa a bala da tela
parameters: BULLET *bullet
return: void
*/
void clearBullet(BULLET *bullet){
if(bullet){
gotoXY(bullet->position->x, bullet->position->y);
printf(" ");
}
}
/*
Atualiza posição da bala
parameters: void
return: bool
*/
bool updateBullet(BULLET *bullet, unsigned short width){
if(bullet){
clearBullet(bullet);
bullet->position->y--;
renderBullet(bullet);
return (bullet->position->y <= width);
}
return false;
}