Revision 267
correction on small mistake
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 |
} |
Also available in: Unified diff