Revision 309
finally done with zombies!
proj.c | ||
---|---|---|
83 | 83 |
{ |
84 | 84 |
graph_clear_screen(); |
85 | 85 |
text_t *txt = text_ctor(consolas, "Loading..."); |
86 |
text_set_pos(txt, graph_get_XRes()/2, graph_get_YRes()/2); |
|
87 |
text_set_valign(txt, text_valign_center); |
|
88 |
text_set_halign(txt, text_halign_center); |
|
89 |
text_set_color(txt, TEXT_COLOR); |
|
86 | 90 |
text_draw(txt); |
87 | 91 |
text_dtor(txt); |
88 | 92 |
graph_draw(); |
... | ... | |
362 | 366 |
/* Get a request message. */ |
363 | 367 |
if((r = get_interrupts_vector(&int_vector))) return r; |
364 | 368 |
for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) { |
369 |
if(!good) break; |
|
365 | 370 |
if (int_vector & n) { |
366 | 371 |
interrupt_handler(i); |
367 | 372 |
switch (i) { |
... | ... | |
394 | 399 |
case KBC_IRQ: |
395 | 400 |
if ((scancode[0]) == ESC_BREAK_CODE) { |
396 | 401 |
good = false; |
397 |
// reset game |
|
398 |
while(list_size(bullet_list) > 0){ |
|
399 |
bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list)); |
|
400 |
bullet_dtor(p); |
|
401 |
} |
|
402 |
list_node_t *it = list_begin(shooter_list); |
|
403 |
while (it != list_end(shooter_list)) { |
|
404 |
gunner_t *p = *(gunner_t**)list_node_val(it); |
|
405 |
get_random_spawn(map1, p, shooter_list); |
|
406 |
gunner_set_curr_health(p, gunner_get_health(p)); |
|
407 |
it = list_node_next(it); |
|
408 |
} |
|
409 |
timer_reset(in_game_timer); |
|
410 | 402 |
} |
411 | 403 |
break; |
412 | 404 |
case MOUSE_IRQ: |
... | ... | |
445 | 437 |
|
446 | 438 |
#define ZOMBIES_NUM 5 |
447 | 439 |
#define ZOMBIE_HEALTH_FACTOR 1.1 |
448 |
|
|
449 | 440 |
static int (zombies)(void){ |
450 | 441 |
|
451 | 442 |
int r; |
... | ... | |
478 | 469 |
|
479 | 470 |
int health = 50; |
480 | 471 |
|
472 |
/** #DEV */ /* { |
|
473 |
gunner_t *zombie = gunner_ctor(bsp_zombie, bsp_nothing, gunner_melee | gunner_follow, 3); |
|
474 |
gunner_set_health(zombie, health); |
|
475 |
gunner_set_curr_health(zombie, health); |
|
476 |
health *= ZOMBIE_HEALTH_FACTOR; |
|
477 |
gunner_set_pos(zombie, 1100, 75); |
|
478 |
list_push_back(shooter_list, zombie); |
|
479 |
}*/ //\#DEV |
|
480 |
|
|
481 |
map_make_dijkstra(map1, gunner_get_x(shooter1), gunner_get_y(shooter1)); |
|
482 |
|
|
481 | 483 |
while (good && !dead) { |
482 | 484 |
/* Get a request message. */ |
483 | 485 |
if((r = get_interrupts_vector(&int_vector))) return r; |
484 | 486 |
for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) { |
487 |
if(!good || dead) break; |
|
485 | 488 |
if (int_vector & n) { |
486 | 489 |
interrupt_handler(i); |
487 | 490 |
switch (i) { |
488 | 491 |
case TIMER0_IRQ: |
489 | 492 |
if (no_interrupts % 60 == 0) timer_update(in_game_timer); |
493 |
if (no_interrupts % 6 == 0){ |
|
494 |
map_make_dijkstra(map1, gunner_get_x(shooter1), gunner_get_y(shooter1)); |
|
495 |
} |
|
490 | 496 |
|
491 | 497 |
update_movement(map1, shooter1, keys, shooter_list); |
492 | 498 |
|
... | ... | |
504 | 510 |
ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0, |
505 | 511 |
gunner_get_y(shooter1)-ent_get_YLength()/2.0); |
506 | 512 |
|
507 |
while(list_size(shooter_list) < ZOMBIES_NUM){ |
|
513 |
while(list_size(shooter_list) < ZOMBIES_NUM+1){
|
|
508 | 514 |
gunner_t *zombie = gunner_ctor(bsp_zombie, bsp_nothing, gunner_melee | gunner_follow, 3); |
509 | 515 |
gunner_set_health(zombie, health); |
510 | 516 |
gunner_set_curr_health(zombie, health); |
Also available in: Unified diff