Revision 267
correction on small mistake
proj/include/ent.h | ||
---|---|---|
18 | 18 |
void (gunner_set_pos) (gunner_t *p, double x, double y); |
19 | 19 |
void (gunner_set_spawn) (gunner_t *p, double x, double y); |
20 | 20 |
void (gunner_set_angle) (gunner_t *p, double angle ); |
21 |
void (gunner_set_health) (gunner_t *p, int health);
|
|
22 |
void (gunner_set_curr_health) (gunner_t *p, int health);
|
|
21 |
void (gunner_set_health) (gunner_t *p, double health);
|
|
22 |
void (gunner_set_curr_health) (gunner_t *p, double health);
|
|
23 | 23 |
double (gunner_get_x) (const gunner_t *p); |
24 | 24 |
double (gunner_get_y) (const gunner_t *p); |
25 | 25 |
double (gunner_get_spawn_x) (const gunner_t *p); |
26 | 26 |
double (gunner_get_spawn_y) (const gunner_t *p); |
27 | 27 |
double (gunner_get_angle) (const gunner_t *p); |
28 |
int (gunner_get_health) (const gunner_t *p);
|
|
29 |
int (gunner_get_curr_health) (const gunner_t *p);
|
|
28 |
double (gunner_get_health) (const gunner_t *p);
|
|
29 |
double (gunner_get_curr_health) (const gunner_t *p);
|
|
30 | 30 |
int16_t (gunner_get_x_screen) (const gunner_t *p); |
31 | 31 |
int16_t (gunner_get_y_screen) (const gunner_t *p); |
32 | 32 |
void (gunner_draw)(gunner_t *p); |
... | ... | |
40 | 40 |
double (bullet_get_y) (const bullet_t *p); |
41 | 41 |
int16_t (bullet_get_x_screen)(const bullet_t *p); |
42 | 42 |
int16_t (bullet_get_y_screen)(const bullet_t *p); |
43 |
int (bullet_get_damage) (const bullet_t *p);
|
|
44 |
void (bullet_set_damage) (bullet_t *p, int damage);
|
|
43 |
double (bullet_get_damage) (const bullet_t *p);
|
|
44 |
void (bullet_set_damage) (bullet_t *p, double damage);
|
|
45 | 45 |
void (bullet_update_movement)(bullet_t *p); |
46 | 46 |
void (bullet_update_movement_list)(list_t *bullet_list); |
47 | 47 |
void (bullet_draw)(bullet_t *p); |
proj/include/proj_macros.h | ||
---|---|---|
16 | 16 |
#define PLUS_BREAK_CODE 0x9A /** @brief Plus (+) Break Code */ |
17 | 17 |
#define MINUS_MAKE_CODE 0x35 /** @brief Minus (-) Make Code */ |
18 | 18 |
#define MINUS_BREAK_CODE 0xB5 /** @brief Minus (-) Break Code */ |
19 |
#define ENTER_MAKE_CODE 0x1C |
|
20 |
#define ENTER_BREAK_CODE 0x9C |
|
19 | 21 |
|
20 | 22 |
// Movement Directions |
21 | 23 |
#define UP -1 /** @brief Moving to the top side of screen */ |
proj/src/ent.c | ||
---|---|---|
23 | 23 |
double spawn_x, spawn_y; |
24 | 24 |
sprite_t *dude; |
25 | 25 |
sprite_t *weapon; |
26 |
int health, current_health;
|
|
26 |
double health, current_health;
|
|
27 | 27 |
}; |
28 | 28 |
gunner_t* (gunner_ctor)(basic_sprite_t *dude, basic_sprite_t *weapon){ |
29 | 29 |
gunner_t *ret = malloc(sizeof(gunner_t)); |
... | ... | |
53 | 53 |
sprite_set_angle(p->dude , angle); |
54 | 54 |
sprite_set_angle(p->weapon, angle); |
55 | 55 |
} |
56 |
void (gunner_set_health) (gunner_t *p, int health) {
|
|
56 |
void (gunner_set_health) (gunner_t *p, double health) {
|
|
57 | 57 |
if (health < 0) health = 0; |
58 | 58 |
p->health = health; |
59 | 59 |
} |
60 |
void (gunner_set_curr_health) (gunner_t *p, int health) {
|
|
60 |
void (gunner_set_curr_health) (gunner_t *p, double health) {
|
|
61 | 61 |
if (health < 0) health = 0; |
62 | 62 |
p->current_health = health; |
63 | 63 |
} |
... | ... | |
66 | 66 |
double (gunner_get_spawn_x) (const gunner_t *p){ return p->spawn_x; } |
67 | 67 |
double (gunner_get_spawn_y) (const gunner_t *p){ return p->spawn_y; } |
68 | 68 |
double (gunner_get_angle) (const gunner_t *p){ return sprite_get_angle(p->dude); } |
69 |
int (gunner_get_health) (const gunner_t *p){ return p->health; }
|
|
70 |
int (gunner_get_curr_health) (const gunner_t *p){ return p->current_health; }
|
|
69 |
double (gunner_get_health) (const gunner_t *p){ return p->health; }
|
|
70 |
double (gunner_get_curr_health) (const gunner_t *p){ return p->current_health; }
|
|
71 | 71 |
int16_t (gunner_get_x_screen) (const gunner_t *p){ return (p->x-x_origin)*scale; } |
72 | 72 |
int16_t (gunner_get_y_screen) (const gunner_t *p){ return (p->y-y_origin)*scale; } |
73 | 73 |
void (gunner_draw)(gunner_t *p){ |
... | ... | |
87 | 87 |
int16_t h = sprite_get_h(p->dude); |
88 | 88 |
double x = gunner_get_x_screen(p) - w/2; |
89 | 89 |
double y = gunner_get_y_screen(p) - h/2 - 10; |
90 |
int curr_health = gunner_get_curr_health(p);
|
|
91 |
int health = gunner_get_health(p);
|
|
92 |
double perc = (double)curr_health/health;
|
|
90 |
double curr_health = gunner_get_curr_health(p);
|
|
91 |
double health = gunner_get_health(p);
|
|
92 |
double perc = curr_health/health; |
|
93 | 93 |
rectangle_t *green_bar = rectangle_ctor(x, y, (int16_t)(w*perc), 10); |
94 | 94 |
rectangle_set_fill_color(green_bar, 0x00FF00); |
95 | 95 |
rectangle_t *red_bar = rectangle_ctor(x+(int16_t)(w*perc), y, (int16_t)(w*(1-perc)), 10); |
... | ... | |
105 | 105 |
double x, y; //real position |
106 | 106 |
double vx, vy; |
107 | 107 |
sprite_t *b; |
108 |
int damage;
|
|
108 |
double damage;
|
|
109 | 109 |
}; |
110 | 110 |
bullet_t* (bullet_ctor)(const gunner_t *shooter, const basic_sprite_t *b, double x, double y, double vx, double vy){ |
111 | 111 |
bullet_t *ret = malloc(sizeof(bullet_t)); |
... | ... | |
134 | 134 |
double (bullet_get_y) (const bullet_t *p){ return p->y; } |
135 | 135 |
int16_t (bullet_get_x_screen)(const bullet_t *p){ return (p->x-x_origin)*scale; } |
136 | 136 |
int16_t (bullet_get_y_screen)(const bullet_t *p){ return (p->y-y_origin)*scale; } |
137 |
int (bullet_get_damage) (const bullet_t *p){ return p->damage; }
|
|
138 |
void (bullet_set_damage) (bullet_t *p, int damage) {
|
|
137 |
double (bullet_get_damage) (const bullet_t *p){ return p->damage; }
|
|
138 |
void (bullet_set_damage) (bullet_t *p, double damage) {
|
|
139 | 139 |
if (damage < 0) damage = 0; |
140 | 140 |
p->damage = damage; |
141 | 141 |
} |
proj/src/proj.c | ||
---|---|---|
129 | 129 |
int ipc_status; |
130 | 130 |
message msg; |
131 | 131 |
int game_state = MENU; |
132 |
|
|
133 |
char buffer[1024]; // buffer |
|
134 |
int buffer_pos = 0; |
|
135 |
|
|
132 | 136 |
#ifndef DIOGO |
133 | 137 |
int click = 0; |
134 | 138 |
#endif |
... | ... | |
193 | 197 |
switch (game_state) { |
194 | 198 |
case MENU: |
195 | 199 |
if ((scancode[0]) == ESC_BREAK_CODE) game_state = EXIT; |
200 |
|
|
201 |
else if ((scancode[0]) == A_MAKE_CODE) buffer[buffer_pos++] = 'A'; |
|
202 |
|
|
203 |
else if ((scancode[0]) == ENTER_MAKE_CODE) { |
|
204 |
// func1 |
|
205 |
|
|
206 |
memcpy(buffer, 0, buffer_pos+1); |
|
207 |
buffer_pos = 0; |
|
208 |
} |
|
209 |
|
|
196 | 210 |
break; |
197 | 211 |
case GAME: |
198 | 212 |
if ((scancode[0]) == ESC_BREAK_CODE) { |
Also available in: Unified diff