Revision 250
in-game timer
proj.c | ||
---|---|---|
171 | 171 |
#ifndef DIOGO |
172 | 172 |
ent_set_scale(DEFAULT_SCALE); |
173 | 173 |
|
174 |
text_timer_t *in_game_timer = timer_ctor(consolas); |
|
175 |
|
|
174 | 176 |
list_t *shooter_list = list_ctor(); |
175 | 177 |
|
176 | 178 |
gunner_t *shooter1 = gunner_ctor(bsp_shooter, bsp_pistol); if(shooter1 == NULL) printf("Failed to get shooter1\n"); |
... | ... | |
184 | 186 |
list_insert(shooter_list, list_end(shooter_list), shooter1); |
185 | 187 |
list_insert(shooter_list, list_end(shooter_list), shooter2); |
186 | 188 |
|
187 |
//bullet_t *bullet = bullet_ctor(get_bullet(), 400.0, 400.0, 2.0, -1.0); |
|
188 |
|
|
189 | 189 |
list_t *bullet_list = list_ctor(); |
190 | 190 |
|
191 | 191 |
ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0, |
192 | 192 |
gunner_get_y(shooter1)-ent_get_YLength()/2.0); |
193 | 193 |
|
194 |
uint32_t refresh_count_value = sys_hz() / REFRESH_RATE; |
|
195 |
|
|
194 |
//uint32_t refresh_count_value = sys_hz() / REFRESH_RATE; |
|
195 |
double angle; // mouse angle |
|
196 |
int32_t *mouse_x = get_mouse_X(), *mouse_y = get_mouse_Y(); |
|
196 | 197 |
uint8_t last_lb = 0; |
198 |
struct packet pp; |
|
199 |
keys_t *keys = get_key_presses(); |
|
197 | 200 |
|
198 | 201 |
/// loop stuff |
199 | 202 |
int ipc_status; |
... | ... | |
214 | 217 |
interrupt_handler(i); |
215 | 218 |
if ((scancode[0]) == ESC_BREAK_CODE) good = 0; |
216 | 219 |
if (i == 0) { |
217 |
if (no_interrupts % refresh_count_value == 0) { |
|
218 |
update_movement(map1, shooter1, get_key_presses(), shooter_list); |
|
220 |
if (no_interrupts % 60 == 0) timer_update(in_game_timer); |
|
221 |
//if (no_interrupts % refresh_count_value == 0) { |
|
222 |
update_movement(map1, shooter1, keys, shooter_list); |
|
219 | 223 |
|
220 | 224 |
update_game_state(map1, shooter_list, bullet_list); |
221 | 225 |
|
222 |
update_scale(); |
|
223 |
sprite_set_pos(sp_crosshair, get_mouse_X(), get_mouse_Y());
|
|
224 |
double angle = get_mouse_angle(shooter1);
|
|
226 |
//update_scale();
|
|
227 |
sprite_set_pos(sp_crosshair, *mouse_x, *mouse_y);
|
|
228 |
angle = get_mouse_angle(shooter1); |
|
225 | 229 |
gunner_set_angle(shooter1, angle - M_PI_2); |
226 | 230 |
graph_clear_screen(); |
227 | 231 |
|
... | ... | |
232 | 236 |
gunner_draw_list(shooter_list); |
233 | 237 |
bullet_draw_list(bullet_list); |
234 | 238 |
|
239 |
text_draw(in_game_timer->text); |
|
235 | 240 |
sprite_draw(sp_crosshair); |
236 | 241 |
graph_draw(); |
237 |
} |
|
242 |
//}
|
|
238 | 243 |
} |
239 |
if (i == 12) { |
|
244 |
else if (i == 12) {
|
|
240 | 245 |
if (counter_mouse_ih >= 3) { |
241 |
struct packet pp = mouse_parse_packet(packet_mouse_ih);
|
|
246 |
mouse_parse_packet(packet_mouse_ih, &pp);
|
|
242 | 247 |
update_mouse(&pp); |
243 |
//printf("X: %d Y: %d\n", get_mouse_X(), get_mouse_Y()); |
|
244 |
counter_mouse_ih = 0; |
|
245 |
if (last_lb ^ get_key_presses()->lb_pressed && get_key_presses()->lb_pressed) { |
|
248 |
|
|
249 |
if (last_lb ^ keys->lb_pressed && keys->lb_pressed) { |
|
246 | 250 |
shoot_bullet(shooter1, bullet_list, bsp_bullet); |
247 | 251 |
} |
248 |
last_lb = get_key_presses()->lb_pressed; |
|
252 |
last_lb = keys->lb_pressed; |
|
253 |
counter_mouse_ih = 0; |
|
254 |
|
|
249 | 255 |
} |
250 | 256 |
} |
251 | 257 |
} |
... | ... | |
272 | 278 |
if(list_dtor(shooter_list)) printf("COULD NOT DESTRUCT SHOOTER LIST\n"); |
273 | 279 |
if(list_dtor(bullet_list)) printf("COULD NOT DESTRUCT BULLET LIST\n"); |
274 | 280 |
|
281 |
timer_dtor(in_game_timer); in_game_timer = NULL; |
|
282 |
|
|
275 | 283 |
basic_sprite_dtor (bsp_crosshair); bsp_crosshair = NULL; |
276 | 284 |
basic_sprite_dtor (bsp_shooter ); bsp_shooter = NULL; |
277 | 285 |
sprite_dtor (sp_crosshair ); sp_crosshair = NULL; |
Also available in: Unified diff