test/snake/snake.c

changeset 248
793a0108c6c4
parent 247
3547254742a7
child 249
2522fbeccede
equal deleted inserted replaced
247:3547254742a7 248:793a0108c6c4
463 game_field_create(); 463 game_field_create();
464 464
465 // create UI elements 465 // create UI elements
466 fps_counter_create(); 466 fps_counter_create();
467 467
468 // create spaceship 468 // create player
469 Player *spaceship = player_create(); 469 Player *player = player_create();
470 470
471 // Main Loop 471 // Main Loop
472 do { 472 do {
473 // quit application on any error 473 // quit application on any error
474 if (asc_has_error()) { 474 if (asc_has_error()) {
480 } 480 }
481 481
482 // player rotation 482 // player rotation
483 // TODO: queue up to two movement commands (for sharp 90° turns) 483 // TODO: queue up to two movement commands (for sharp 90° turns)
484 if (asc_key_pressed(ASC_KEY(LEFT))) { 484 if (asc_key_pressed(ASC_KEY(LEFT))) {
485 if (spaceship->direction != MOVE_RIGHT) { 485 if (player->direction != MOVE_RIGHT) {
486 spaceship->target_direction = MOVE_LEFT; 486 player->target_direction = MOVE_LEFT;
487 } 487 }
488 } 488 }
489 if (asc_key_pressed(ASC_KEY(RIGHT))) { 489 if (asc_key_pressed(ASC_KEY(RIGHT))) {
490 if (spaceship->direction != MOVE_LEFT) { 490 if (player->direction != MOVE_LEFT) {
491 spaceship->target_direction = MOVE_RIGHT; 491 player->target_direction = MOVE_RIGHT;
492 } 492 }
493 } 493 }
494 if (asc_key_pressed(ASC_KEY(UP))) { 494 if (asc_key_pressed(ASC_KEY(UP))) {
495 if (spaceship->direction != MOVE_DOWN) { 495 if (player->direction != MOVE_DOWN) {
496 spaceship->target_direction = MOVE_UP; 496 player->target_direction = MOVE_UP;
497 } 497 }
498 } 498 }
499 if (asc_key_pressed(ASC_KEY(DOWN))) { 499 if (asc_key_pressed(ASC_KEY(DOWN))) {
500 if (spaceship->direction != MOVE_UP) { 500 if (player->direction != MOVE_UP) {
501 spaceship->target_direction = MOVE_DOWN; 501 player->target_direction = MOVE_DOWN;
502 } 502 }
503 } 503 }
504 504
505 // debug-key for clearing the shader registry 505 // debug-key for clearing the shader registry
506 if (asc_key_pressed(ASC_KEY(S))) { 506 if (asc_key_pressed(ASC_KEY(S))) {

mercurial