Ben Evans University Second Year Project. Game Called Defender.
Hello, soldier, you have been specially selected as the defender of planet earth.
Your mission, if you choose to accept it. Fly around the planet and pulverise invading alien ships for as long as you can. Stop the aliens abducting the innocent people on the ground. Be warned if an alien ship manages to abduct a person and take them to top of the screen, they will no longer move randomly and will begin to hunt you down. This sounds like a challenge you were trained for.
But don’t worry soldier you’re not going into battle empty-handed. Your ship is equipped with a state of the art laser beam that has unlimited ammo and four smart bombs that will destroy anything on the screen. The ship also has three lives so use them wisely.
As time goes on more alien ships will arrive on planet earth increasing the difficulty of your mission. And remember the landscape bellow loops around so if you continually fly in the same direction you go to your original position. Good luck soldier.
Diff: GameEngine/GameEngine.cpp
- Revision:
- 41:5959256f4aab
- Parent:
- 40:71f947254fda
- Child:
- 42:3aed75338272
--- a/GameEngine/GameEngine.cpp Sun May 17 21:12:34 2020 +0000 +++ b/GameEngine/GameEngine.cpp Sun May 17 23:40:34 2020 +0000 @@ -31,21 +31,78 @@ points = 0; smart_bomb_timer = 0; bullet_timer = 0; + current_menu_part_= menu.get_current_menu_part(); } void GameEngine::gameplay_loop() { + // clear screen and set contrast lcd.setContrast(pad.read_pot1()); lcd.clear(); - read_joystick_direction(); - menu.menu_scroll(pad, d_); - menu.draw_part(lcd); + // creat objects + create_weapons_bullets(); + create_weapons_smart_bomb(); + spawn_aliens(); + spawn_people(); + + //If spaceship is destroyed stop joystick input, dont draw spaceship sprite + if (!spaceship_destroyed){ + read_joystick_direction(); + spaceship.movement(d_); + spaceship.draw(lcd); + } + + // Draws objects + map.draw_map(lcd, d_); + draw_aliens(); + draw_bullets(); + draw_explosions(); + draw_people(); + hud.draw_HUD(lcd, spaceship_lives, points, smart_bomb_counter); + spaceship_lives_leds(); + + reset_map_timer(); // refresh's screen lcd.refresh(); } +// Menu Control----------------------------------------------------------------- +void GameEngine::game_select_part(){ + switch (current_menu_part_) { + case main_menu: run_menu(); break; + case play: run_play(); break; + case settings: run_settings(); break; + case saved_games: run_saved_games(); break; + } +} + +void GameEngine::run_menu(){ + lcd.setContrast(pad.read_pot1()); + lcd.clear(); + + // Scrolls, draws and selcts menu parts + read_joystick_direction(); + menu.menu_scroll(pad, d_); + menu.draw_part(lcd); + menu.select_part(lcd, pad); + + lcd.refresh(); +} + +void GameEngine::run_play(){ + gameplay_loop(); +} + +void GameEngine::run_settings(){ + +} + +void GameEngine::run_saved_games(){ + +} + //Spaceship control ------------------------------------------------------------ void GameEngine::read_joystick_direction(){