Ben Evans University Second Year Project. Game Called Defender.

Dependencies:   mbed

https://os.mbed.com/media/uploads/evanso/84bc1a30759fd6a1e3f1fd1fae3e97c2.png

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.

Committer:
evanso
Date:
Wed May 13 23:07:52 2020 +0000
Revision:
28:a5958497d5ce
Parent:
27:8bb2bd97c319
Child:
29:e96d91f1d39c
Added Random Movement base class which is inherited by alien bullets and alien direction. Alien now shoots bullets randomly towards the spaceship.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 25:70b55f5bfc87 1 #include "Explosion.h"
evanso 25:70b55f5bfc87 2
evanso 26:1a7056eb3253 3 // Defining animation states for explotion FSM
evanso 25:70b55f5bfc87 4 Animation animation_fsm[2] = {
evanso 25:70b55f5bfc87 5 {false, true, FILL_WHITE, FILL_BLACK},
evanso 27:8bb2bd97c319 6 {true, false, FILL_TRANSPARENT, FILL_WHITE},
evanso 25:70b55f5bfc87 7 };
evanso 25:70b55f5bfc87 8
evanso 25:70b55f5bfc87 9 Explosion::Explosion() {
evanso 25:70b55f5bfc87 10
evanso 25:70b55f5bfc87 11 }
evanso 25:70b55f5bfc87 12
evanso 25:70b55f5bfc87 13 Explosion::~Explosion() {
evanso 25:70b55f5bfc87 14
evanso 25:70b55f5bfc87 15 }
evanso 25:70b55f5bfc87 16
evanso 25:70b55f5bfc87 17 void Explosion::init() {
evanso 27:8bb2bd97c319 18 position_x_ = 0;
evanso 27:8bb2bd97c319 19 position_y_ = 0;
evanso 25:70b55f5bfc87 20 fsm_counter_ = 0;
evanso 25:70b55f5bfc87 21 explosion_radius_ = 4;
evanso 25:70b55f5bfc87 22 draw_counter = 0;
evanso 25:70b55f5bfc87 23 }
evanso 25:70b55f5bfc87 24
evanso 25:70b55f5bfc87 25 void Explosion::draw_explosion(N5110 &lcd) {
evanso 26:1a7056eb3253 26 // Draws each explotion frame depending on state
evanso 25:70b55f5bfc87 27 if(animation_fsm[fsm_counter_].draw_circle_one){
evanso 27:8bb2bd97c319 28 lcd.drawCircle(position_x_, position_y_,explosion_radius_ + 1,
evanso 27:8bb2bd97c319 29 animation_fsm[fsm_counter_].circle_one);
evanso 25:70b55f5bfc87 30 }
evanso 25:70b55f5bfc87 31 if(animation_fsm[fsm_counter_].draw_circle_two){
evanso 28:a5958497d5ce 32 lcd.drawCircle(position_x_, position_y_,(explosion_radius_ - 2),
evanso 28:a5958497d5ce 33 animation_fsm[fsm_counter_].circle_two);
evanso 25:70b55f5bfc87 34 }
evanso 25:70b55f5bfc87 35
evanso 25:70b55f5bfc87 36 // Slows down annimation change time, so eplosion animation is longer
evanso 25:70b55f5bfc87 37 if (draw_counter%2 == 0) {
evanso 25:70b55f5bfc87 38 explosion_radius_++;
evanso 25:70b55f5bfc87 39 fsm_counter_ = !fsm_counter_;
evanso 25:70b55f5bfc87 40 }
evanso 25:70b55f5bfc87 41 draw_counter++;
evanso 25:70b55f5bfc87 42 }
evanso 25:70b55f5bfc87 43
evanso 25:70b55f5bfc87 44 void Explosion::set_explosion_posistion(Vector2D destroyed_position) {
evanso 27:8bb2bd97c319 45 position_x_ = destroyed_position.x + 3;
evanso 27:8bb2bd97c319 46 position_y_ = destroyed_position.y + 3;
evanso 25:70b55f5bfc87 47 }
evanso 25:70b55f5bfc87 48
evanso 25:70b55f5bfc87 49 int Explosion::get_explosion_radius(){
evanso 25:70b55f5bfc87 50 return explosion_radius_;
evanso 25:70b55f5bfc87 51 }