Revision 230
health bars
ent.c | ||
---|---|---|
30 | 30 |
ret->x = 0.0; |
31 | 31 |
ret->y = 0.0; |
32 | 32 |
ret->health = 100; |
33 |
ret->current_health = ret->health*2/3;
|
|
33 |
ret->current_health = ret->health; |
|
34 | 34 |
ret->dude = sprite_ctor(dude ); |
35 | 35 |
ret->weapon = sprite_ctor(weapon); |
36 | 36 |
if(ret->dude == NULL || ret->weapon == NULL){ |
... | ... | |
49 | 49 |
sprite_set_angle(p->dude , angle); |
50 | 50 |
sprite_set_angle(p->weapon, angle); |
51 | 51 |
} |
52 |
void (gunner_set_health) (gunner_t *p, int health) { p->health = health; } |
|
53 |
void (gunner_set_curr_health) (gunner_t *p, int health) { p->current_health = health; } |
|
52 |
void (gunner_set_health) (gunner_t *p, int health) { |
|
53 |
if (health < 0) health = 0; |
|
54 |
p->health = health; |
|
55 |
} |
|
56 |
void (gunner_set_curr_health) (gunner_t *p, int health) { |
|
57 |
if (health < 0) health = 0; |
|
58 |
p->current_health = health; |
|
59 |
} |
|
54 | 60 |
double (gunner_get_x) (const gunner_t *p){ return p->x; } |
55 | 61 |
double (gunner_get_y) (const gunner_t *p){ return p->y; } |
56 | 62 |
int (gunner_get_health) (const gunner_t *p){ return p->health; } |
... | ... | |
72 | 78 |
void (gunner_draw_health)(const gunner_t *p) { |
73 | 79 |
int16_t w = sprite_get_w(p->dude); |
74 | 80 |
int16_t h = sprite_get_h(p->dude); |
75 |
double x = gunner_get_x(p) - w/2; |
|
76 |
double y = gunner_get_y(p) - h/2 - 10; |
|
81 |
double x = gunner_get_x_screen(p) - w/2;
|
|
82 |
double y = gunner_get_y_screen(p) - h/2 - 10;
|
|
77 | 83 |
int curr_health = gunner_get_curr_health(p); |
78 | 84 |
int health = gunner_get_health(p); |
79 | 85 |
double perc = (double)curr_health/health; |
... | ... | |
91 | 97 |
double x, y; //real position |
92 | 98 |
double vx, vy; |
93 | 99 |
sprite_t *b; |
100 |
int damage; |
|
94 | 101 |
}; |
95 | 102 |
bullet_t* (bullet_ctor)(basic_sprite_t *b, double x, double y, double vx, double vy){ |
96 | 103 |
bullet_t *ret = malloc(sizeof(bullet_t)); |
... | ... | |
99 | 106 |
ret-> y = y; |
100 | 107 |
ret->vx = vx; |
101 | 108 |
ret->vy = vy; |
109 |
ret->damage = 1; |
|
102 | 110 |
ret->b = sprite_ctor(b); |
103 | 111 |
if(ret->b == NULL){ |
104 | 112 |
bullet_dtor(ret); |
... | ... | |
117 | 125 |
double (bullet_get_y) (const bullet_t *p){ return p->y; } |
118 | 126 |
int16_t (bullet_get_x_screen)(const bullet_t *p){ return (p->x-x_origin)*scale; } |
119 | 127 |
int16_t (bullet_get_y_screen)(const bullet_t *p){ return (p->y-y_origin)*scale; } |
128 |
int (bullet_get_damage) (const bullet_t *p){ return p->damage; } |
|
129 |
void (bullet_set_damage) (bullet_t *p, int damage) { |
|
130 |
if (damage < 0) damage = 0; |
|
131 |
p->damage = damage; |
|
132 |
} |
|
120 | 133 |
void (bullet_update_movement)(bullet_t *p){ |
121 | 134 |
p->x += p->vx; |
122 | 135 |
p->y += p->vy; |
Also available in: Unified diff