void ram(void) { while(1) { if (!screen_intro()){ setTextColor(0xff,0x00); return; } game.rokets = 3; game.level = 1; game.score = 0; init_game(); screen_level(); while (game.rokets>=0) { ////checkISP(); lcdFill(0x00); check_end(); move_ufo(); move_shot(); move_shots(); move_player(); move_enemy(); draw_score(); draw_ufo(); draw_bunker(); draw_player(); draw_enemy(); draw_shots(); // draw_status(); lcdDisplay(); delayms(12); } if (!screen_gameover()) setTextColor(0xff,0x00); return; } }
int run_game(GameData *data) { int cur_shot = 0; while(cur_shot < data->num_shots) { Pacman *cur_pac_shot = (data->shots + cur_shot); draw_pacman(cur_pac_shot); draw_pebbles(data->pebbles, data->num_pebbles); *cur_pac_shot->velocity = *(data->old_velocity); Velocity *velocity = cur_pac_shot->velocity; while(!KEY_PRESSED(START)) { update_velocities(velocity); wait_for_vblank(); draw_user_velocities(data->velocity_frame_x, data->velocity_frame_y, velocity); draw_pacman(cur_pac_shot); } *(data->old_velocity ) = *cur_pac_shot->velocity;//MUST save old shot erase_frame(data->velocity_frame_x, data->bg_color); erase_frame(data->velocity_frame_y, data->bg_color); //now we run simulation fill_frame(data->indicator, GREEN); int i = 0; while(!off_screen(cur_pac_shot->frame)) { for (i = 0; i < data->num_pebbles; i++) { PacmanPebble *cur_pebble = (data->pebbles + i); check_collision(cur_pac_shot, cur_pebble); } wait_for_vblank(); erase_frame(cur_pac_shot->frame, data->bg_color); move_shot(cur_pac_shot); draw_pebbles(data->pebbles, data->num_pebbles); draw_pacman(cur_pac_shot); } erase_frame(cur_pac_shot->frame, data->bg_color); cur_shot++; } fill_frame(data->indicator, RED); return 0; }