Revision 307
working on dijkstra for zombies
proj.c | ||
---|---|---|
109 | 109 |
keys_t *keys = get_key_presses(); |
110 | 110 |
|
111 | 111 |
/// loop stuff |
112 |
int ipc_status; |
|
113 |
message msg; |
|
114 |
|
|
115 | 112 |
int click = 0; |
116 |
|
|
113 |
uint32_t int_vector = 0; |
|
117 | 114 |
int good = true; |
118 |
|
|
119 | 115 |
while (good) { |
120 | 116 |
/* Get a request message. */ |
121 |
if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) { |
|
122 |
printf("driver_receive failed with %d", r); |
|
123 |
continue; |
|
124 |
} |
|
125 |
if (is_ipc_notify(ipc_status)) { /* received notification */ |
|
126 |
switch (_ENDPOINT_P(msg.m_source)) { |
|
127 |
case HARDWARE: /* hardware interrupt notification */ |
|
128 |
for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) { |
|
129 |
if (msg.m_notify.interrupts & n) { |
|
130 |
interrupt_handler(i); |
|
131 |
switch (i) { |
|
132 |
case TIMER0_IRQ: |
|
117 |
if((r = get_interrupts_vector(&int_vector))) return r; |
|
118 |
for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) { |
|
119 |
if (int_vector & n) { |
|
120 |
interrupt_handler(i); |
|
121 |
switch (i) { |
|
122 |
case TIMER0_IRQ: |
|
133 | 123 |
|
134 |
graph_clear_screen();
|
|
135 |
switch(menu_update_state(main_menu, click)){
|
|
136 |
case -1: break;
|
|
137 |
case 0: singleplayer(); break; //campaign(); break;
|
|
138 |
case 1: break;
|
|
139 |
case 2: chat(); break;
|
|
140 |
case 3: good = false; break;
|
|
141 |
}
|
|
142 |
menu_draw(main_menu);
|
|
124 |
graph_clear_screen(); |
|
125 |
switch(menu_update_state(main_menu, click)){ |
|
126 |
case -1: break; |
|
127 |
case 0: singleplayer(); break; //campaign(); break; |
|
128 |
case 1: break; |
|
129 |
case 2: chat(); break; |
|
130 |
case 3: good = false; break; |
|
131 |
} |
|
132 |
menu_draw(main_menu); |
|
143 | 133 |
|
144 |
click = 0;
|
|
134 |
click = 0; |
|
145 | 135 |
|
146 |
sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
|
|
147 |
sprite_draw(sp_crosshair);
|
|
148 |
graph_draw();
|
|
136 |
sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y()); |
|
137 |
sprite_draw(sp_crosshair); |
|
138 |
graph_draw(); |
|
149 | 139 |
|
150 |
break; |
|
151 |
case KBC_IRQ: |
|
152 |
if ((scancode[0]) == ESC_BREAK_CODE) good = false; |
|
153 |
case MOUSE_IRQ: |
|
154 |
if (counter_mouse_ih >= 3) { |
|
155 |
mouse_parse_packet(packet_mouse_ih, &pp); |
|
156 |
update_mouse(&pp); |
|
157 |
if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed; |
|
158 |
last_lb = keys->lb_pressed; |
|
159 |
counter_mouse_ih = 0; |
|
160 |
} |
|
161 |
break; |
|
162 |
case COM1_IRQ: nctp_ih(); break; |
|
163 |
} |
|
140 |
break; |
|
141 |
case KBC_IRQ: |
|
142 |
if ((scancode[0]) == ESC_BREAK_CODE) good = false; |
|
143 |
case MOUSE_IRQ: |
|
144 |
if (counter_mouse_ih >= 3) { |
|
145 |
mouse_parse_packet(packet_mouse_ih, &pp); |
|
146 |
update_mouse(&pp); |
|
147 |
if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed; |
|
148 |
last_lb = keys->lb_pressed; |
|
149 |
counter_mouse_ih = 0; |
|
164 | 150 |
} |
151 |
break; |
|
152 |
case COM1_IRQ: nctp_ih(); break; |
|
165 | 153 |
} |
166 |
|
|
167 |
break; |
|
168 |
default: |
|
169 |
break; /* no other notifications expected: do nothing */ |
|
170 | 154 |
} |
171 |
} else { /* received standart message, not a notification */ |
|
172 |
/* no standart message expected: do nothing */ |
|
173 | 155 |
} |
174 | 156 |
} |
175 | 157 |
|
176 | 158 |
basic_sprite_dtor (bsp_crosshair); bsp_crosshair = NULL; |
177 | 159 |
basic_sprite_dtor (bsp_shooter ); bsp_shooter = NULL; |
178 |
/*basic_sprite_dtor (bsp_zombie );*/ bsp_zombie = NULL;
|
|
160 |
basic_sprite_dtor (bsp_zombie ); bsp_zombie = NULL;
|
|
179 | 161 |
sprite_dtor (sp_crosshair ); sp_crosshair = NULL; |
180 | 162 |
basic_sprite_dtor (bsp_pistol ); bsp_pistol = NULL; |
181 | 163 |
basic_sprite_dtor (bsp_nothing ); bsp_nothing = NULL; |
... | ... | |
339 | 321 |
list_node_t *it = list_begin(shooter_list); |
340 | 322 |
while (it != list_end(shooter_list)) { |
341 | 323 |
gunner_t *p = *(gunner_t**)list_node_val(it); |
342 |
get_random_spawn(map1, p); |
|
324 |
get_random_spawn(map1, p, shooter_list);
|
|
343 | 325 |
gunner_set_curr_health(p, gunner_get_health(p)); |
344 | 326 |
it = list_node_next(it); |
345 | 327 |
} |
... | ... | |
425 | 407 |
case TIMER0_IRQ: |
426 | 408 |
if (no_interrupts % 60 == 0) timer_update(in_game_timer); |
427 | 409 |
|
428 |
clock_t t1, t2; |
|
429 |
t1 = clock(); |
|
430 |
|
|
431 | 410 |
update_movement(map1, shooter1, keys, shooter_list); |
432 | 411 |
|
433 | 412 |
update_game_state(map1, shooter_list, bullet_list); |
... | ... | |
449 | 428 |
gunner_set_health(zombie, health); |
450 | 429 |
gunner_set_curr_health(zombie, health); |
451 | 430 |
health *= ZOMBIE_HEALTH_FACTOR; |
452 |
get_random_spawn(map1, zombie); |
|
431 |
get_random_spawn(map1, zombie, shooter_list);
|
|
453 | 432 |
list_push_back(shooter_list, zombie); |
454 | 433 |
} |
455 | 434 |
|
... | ... | |
464 | 443 |
sprite_draw(sp_crosshair); |
465 | 444 |
graph_draw(); |
466 | 445 |
|
467 |
t2 = clock(); |
|
468 |
printf("%d microseconds\n", t2-t1); |
|
469 |
|
|
470 | 446 |
break; |
471 | 447 |
case KBC_IRQ: |
472 | 448 |
if ((scancode[0]) == ESC_BREAK_CODE) { |
473 | 449 |
good = false; |
474 |
// reset game |
|
475 |
while(list_size(bullet_list) > 0){ |
|
476 |
bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list)); |
|
477 |
bullet_dtor(p); |
|
478 |
} |
|
479 |
list_node_t *it = list_begin(shooter_list); |
|
480 |
while (it != list_end(shooter_list)) { |
|
481 |
gunner_t *p = *(gunner_t**)list_node_val(it); |
|
482 |
get_random_spawn(map1, p); |
|
483 |
gunner_set_curr_health(p, gunner_get_health(p)); |
|
484 |
it = list_node_next(it); |
|
485 |
} |
|
486 |
timer_reset(in_game_timer); |
|
487 | 450 |
} |
488 | 451 |
break; |
489 | 452 |
case MOUSE_IRQ: |
Also available in: Unified diff