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 28:a5958497d5ce 1 #ifndef RANDOMMOVEMENT_H
evanso 28:a5958497d5ce 2 #define RANDOMMOVEMENT_H
evanso 28:a5958497d5ce 3
evanso 82:3211b31e9421 4 // Included Headers ------------------------------------------------------------
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 85:87bc28b151d8 9 * @brief Random Movement parent class
evanso 28:a5958497d5ce 10 * @author Benjamin Evans, University of Leeds
evanso 28:a5958497d5ce 11 * @date May 2020
evanso 28:a5958497d5ce 12 */
evanso 35:577c65bf914e 13 class RandomMovement: virtual public Position{
evanso 28:a5958497d5ce 14 protected:
evanso 28:a5958497d5ce 15 // Function prototypes -----------------------------------------------------
evanso 28:a5958497d5ce 16
evanso 85:87bc28b151d8 17 /** Changes the x and y positions of the sprite object depending 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 85:87bc28b151d8 24 /** Generates the random move direction 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 85:87bc28b151d8 30 /** Calculates the sprite movement depending on spaceship positions and
evanso 34:85ccc16f24d2 31 * joystick input
evanso 34:85ccc16f24d2 32 * @param d_ @details : Direction object of joystick
evanso 85:87bc28b151d8 33 * @return integer @details move alien value for alien draw function
evanso 34:85ccc16f24d2 34 */
evanso 34:85ccc16f24d2 35 int calc_sprite_movement(Direction d_);
evanso 34:85ccc16f24d2 36
evanso 28:a5958497d5ce 37 // Variables ---------------------------------------------------------------
evanso 28:a5958497d5ce 38
evanso 28:a5958497d5ce 39 /** Sprite random move counter */
evanso 28:a5958497d5ce 40 int random_move_counter_;
evanso 28:a5958497d5ce 41
evanso 28:a5958497d5ce 42 /** Random direction variable */
evanso 28:a5958497d5ce 43 int random_direction_;
evanso 28:a5958497d5ce 44 };
evanso 28:a5958497d5ce 45
evanso 85:87bc28b151d8 46 #endif