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 27 02:06:05 2020 +0000
Revision:
87:832ca78426b5
Parent:
85:87bc28b151d8
Final Submission. I have read and agreed with Statement of Academic Integrity.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
evanso 25:70b55f5bfc87 1 #include "Explosion.h"
evanso 25:70b55f5bfc87 2
evanso 85:87bc28b151d8 3 // Defining animation states for explosion 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 29:e96d91f1d39c 17 void Explosion::init(Vector2D destroyed_position) {
evanso 36:27aa597db3d2 18 // Assign values to variables
evanso 29:e96d91f1d39c 19 position_x_ = destroyed_position.x + 3;
evanso 29:e96d91f1d39c 20 position_y_ = destroyed_position.y + 3;
evanso 25:70b55f5bfc87 21 fsm_counter_ = 0;
evanso 25:70b55f5bfc87 22 explosion_radius_ = 4;
evanso 25:70b55f5bfc87 23 draw_counter = 0;
evanso 25:70b55f5bfc87 24 }
evanso 25:70b55f5bfc87 25
evanso 25:70b55f5bfc87 26 void Explosion::draw_explosion(N5110 &lcd) {
evanso 85:87bc28b151d8 27 // Draws each explosion frame depending on state
evanso 36:27aa597db3d2 28 // Draw circle one
evanso 85:87bc28b151d8 29 if (animation_fsm[fsm_counter_].draw_circle_one) {
evanso 27:8bb2bd97c319 30 lcd.drawCircle(position_x_, position_y_,explosion_radius_ + 1,
evanso 27:8bb2bd97c319 31 animation_fsm[fsm_counter_].circle_one);
evanso 25:70b55f5bfc87 32 }
evanso 36:27aa597db3d2 33 // Draw circle two
evanso 85:87bc28b151d8 34 if (animation_fsm[fsm_counter_].draw_circle_two) {
evanso 28:a5958497d5ce 35 lcd.drawCircle(position_x_, position_y_,(explosion_radius_ - 2),
evanso 28:a5958497d5ce 36 animation_fsm[fsm_counter_].circle_two);
evanso 25:70b55f5bfc87 37 }
evanso 25:70b55f5bfc87 38
evanso 85:87bc28b151d8 39 // Slows down animation change time, so explosion animation is longer
evanso 25:70b55f5bfc87 40 if (draw_counter%2 == 0) {
evanso 25:70b55f5bfc87 41 explosion_radius_++;
evanso 25:70b55f5bfc87 42 fsm_counter_ = !fsm_counter_;
evanso 25:70b55f5bfc87 43 }
evanso 25:70b55f5bfc87 44 draw_counter++;
evanso 25:70b55f5bfc87 45 }
evanso 25:70b55f5bfc87 46
evanso 82:3211b31e9421 47 int Explosion::get_explosion_radius() {
evanso 25:70b55f5bfc87 48 return explosion_radius_;
evanso 85:87bc28b151d8 49 }