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
Child:
31:6015e8ed859c
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 28:a5958497d5ce 1 #ifndef RANDOMMOVEMENT_H
evanso 28:a5958497d5ce 2 #define RANDOMMOVEMENT_H
evanso 28:a5958497d5ce 3
evanso 28:a5958497d5ce 4 // Included libraries ----------------------------------------------------------
evanso 28:a5958497d5ce 5 #include "mbed.h"
evanso 28:a5958497d5ce 6 #include "Position.h"
evanso 28:a5958497d5ce 7
evanso 28:a5958497d5ce 8 /** Random Movement class
evanso 28:a5958497d5ce 9 * @brief Random Movement perant class
evanso 28:a5958497d5ce 10 * @author Benjamin Evans, University of Leeds
evanso 28:a5958497d5ce 11 * @date May 2020
evanso 28:a5958497d5ce 12 */
evanso 28:a5958497d5ce 13 class RandomMovement: protected Position{
evanso 28:a5958497d5ce 14 protected:
evanso 28:a5958497d5ce 15 // Function prototypes -----------------------------------------------------
evanso 28:a5958497d5ce 16
evanso 28:a5958497d5ce 17 /** Changes the x and y positions of the sprite bject depeding on the
evanso 28:a5958497d5ce 18 * movement direction
evanso 28:a5958497d5ce 19 * @param x_change @details number to change sprite x position by
evanso 28:a5958497d5ce 20 * @param y_change @detials number to change sprite y position by
evanso 28:a5958497d5ce 21 */
evanso 28:a5958497d5ce 22 void set_sprite_direction(int x_change,int y_change);
evanso 28:a5958497d5ce 23
evanso 28:a5958497d5ce 24 /** Generates the random move dirction and length for the sprite */
evanso 28:a5958497d5ce 25 void set_random_move();
evanso 28:a5958497d5ce 26
evanso 28:a5958497d5ce 27 /** Gets the movement direction of the sprite */
evanso 28:a5958497d5ce 28 void move_direction();
evanso 28:a5958497d5ce 29
evanso 28:a5958497d5ce 30 // Variables ---------------------------------------------------------------
evanso 28:a5958497d5ce 31
evanso 28:a5958497d5ce 32 /** Sprite random move counter */
evanso 28:a5958497d5ce 33 int random_move_counter_;
evanso 28:a5958497d5ce 34
evanso 28:a5958497d5ce 35 /** Random direction variable */
evanso 28:a5958497d5ce 36 int random_direction_;
evanso 28:a5958497d5ce 37 };
evanso 28:a5958497d5ce 38
evanso 28:a5958497d5ce 39 #endif