Solar Striker

Dependencies:   mbed Gamepad N5110 mbed-rtos

Committer:
RexRoshan
Date:
Thu May 09 09:49:35 2019 +0000
Revision:
0:d9cf94b41df3
Documentation has been completed and the code has been slightly modified

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RexRoshan 0:d9cf94b41df3 1 #ifndef MINIGAME_H
RexRoshan 0:d9cf94b41df3 2 #define MINIGAME_H
RexRoshan 0:d9cf94b41df3 3
RexRoshan 0:d9cf94b41df3 4 #include "mbed.h"
RexRoshan 0:d9cf94b41df3 5 #include "N5110.h"
RexRoshan 0:d9cf94b41df3 6 #include "Gamepad.h"
RexRoshan 0:d9cf94b41df3 7 #include "Background.h"
RexRoshan 0:d9cf94b41df3 8 #include "MiniEnemy.h"
RexRoshan 0:d9cf94b41df3 9 #include "Beam.h"
RexRoshan 0:d9cf94b41df3 10 #include "Spacecraft.h"
RexRoshan 0:d9cf94b41df3 11
RexRoshan 0:d9cf94b41df3 12 #define GAP 2
RexRoshan 0:d9cf94b41df3 13
RexRoshan 0:d9cf94b41df3 14 /** GameEngine Class
RexRoshan 0:d9cf94b41df3 15 * @brief The game engine for the game
RexRoshan 0:d9cf94b41df3 16 * @author Rex Roshan Raj
RexRoshan 0:d9cf94b41df3 17 */
RexRoshan 0:d9cf94b41df3 18 class MiniGame
RexRoshan 0:d9cf94b41df3 19 {
RexRoshan 0:d9cf94b41df3 20
RexRoshan 0:d9cf94b41df3 21 public:
RexRoshan 0:d9cf94b41df3 22
RexRoshan 0:d9cf94b41df3 23 /** Constructor */
RexRoshan 0:d9cf94b41df3 24 MiniGame();
RexRoshan 0:d9cf94b41df3 25
RexRoshan 0:d9cf94b41df3 26 /** Destructor */
RexRoshan 0:d9cf94b41df3 27 ~MiniGame();
RexRoshan 0:d9cf94b41df3 28
RexRoshan 0:d9cf94b41df3 29 /** Initialises the parameters
RexRoshan 0:d9cf94b41df3 30 * @param spacecraft x pos
RexRoshan 0:d9cf94b41df3 31 * @param spacecraft y pos
RexRoshan 0:d9cf94b41df3 32 * @param beam_size
RexRoshan 0:d9cf94b41df3 33 */
RexRoshan 0:d9cf94b41df3 34 void init(int spacecraft_xpos,int spacecraft_ypos,int beam_size,int u_cloudx, int u_cloudy, int l_cloudx, int l_cloudy);
RexRoshan 0:d9cf94b41df3 35
RexRoshan 0:d9cf94b41df3 36 /** Read the input
RexRoshan 0:d9cf94b41df3 37 * @param Gamepad pad
RexRoshan 0:d9cf94b41df3 38 * @brief Reads the input from the Gamepad
RexRoshan 0:d9cf94b41df3 39 */
RexRoshan 0:d9cf94b41df3 40 void read_input(Gamepad &pad);
RexRoshan 0:d9cf94b41df3 41
RexRoshan 0:d9cf94b41df3 42 /** Draws objects in minigame
RexRoshan 0:d9cf94b41df3 43 * @param N5110 lcd
RexRoshan 0:d9cf94b41df3 44 * @brief Draws the characters and the beams involved in the minigame
RexRoshan 0:d9cf94b41df3 45 */
RexRoshan 0:d9cf94b41df3 46 void draw_minigame(Gamepad &pad,N5110 &lcd);
RexRoshan 0:d9cf94b41df3 47
RexRoshan 0:d9cf94b41df3 48 /** Updates minigame
RexRoshan 0:d9cf94b41df3 49 * @param Gamepad pad
RexRoshan 0:d9cf94b41df3 50 * @param N5110 lcd
RexRoshan 0:d9cf94b41df3 51 */
RexRoshan 0:d9cf94b41df3 52 void update_minigame(Gamepad &pad,N5110 &lcd);
RexRoshan 0:d9cf94b41df3 53
RexRoshan 0:d9cf94b41df3 54 /** Draws the score
RexRoshan 0:d9cf94b41df3 55 * @param N5110 lcd
RexRoshan 0:d9cf94b41df3 56 * @brief Outputs the score obtained by the player
RexRoshan 0:d9cf94b41df3 57 */
RexRoshan 0:d9cf94b41df3 58 void draw_score(N5110 &lcd);
RexRoshan 0:d9cf94b41df3 59
RexRoshan 0:d9cf94b41df3 60 /** Gets the game stage
RexRoshan 0:d9cf94b41df3 61 * @brief Gets the current stage of the game
RexRoshan 0:d9cf94b41df3 62 * @return stage
RexRoshan 0:d9cf94b41df3 63 */
RexRoshan 0:d9cf94b41df3 64 int get_game_stage();
RexRoshan 0:d9cf94b41df3 65
RexRoshan 0:d9cf94b41df3 66 private:
RexRoshan 0:d9cf94b41df3 67
RexRoshan 0:d9cf94b41df3 68 void check_cloud_wall_collision(Gamepad &pad); // check if the background has collided with the wall
RexRoshan 0:d9cf94b41df3 69 void check_wall_collision(Gamepad &pad); // check if the enemy has collided with the wall
RexRoshan 0:d9cf94b41df3 70 void check_player_collision(Gamepad &pad); // Check if the player has collided with the enemy
RexRoshan 0:d9cf94b41df3 71 void check_enemy_collisions(Gamepad &pad); // check if the player spacecraft beam collided with the enemy in minigame
RexRoshan 0:d9cf94b41df3 72 void enemy_dead(N5110 &lcd,Gamepad &pad); // check if enemy spacecraft is dead
RexRoshan 0:d9cf94b41df3 73 void spacecraft_dead(N5110 &lcd,Gamepad &pad); // check if the player spacecraft is dead
RexRoshan 0:d9cf94b41df3 74 void check_playerbeam_collision(Gamepad &pad); // check if the player's spacecraft beam collided with the wall
RexRoshan 0:d9cf94b41df3 75
RexRoshan 0:d9cf94b41df3 76 void add_speed(); // adds the speed
RexRoshan 0:d9cf94b41df3 77 void add_counter(); // adds the counter
RexRoshan 0:d9cf94b41df3 78
RexRoshan 0:d9cf94b41df3 79 void draw_kills(N5110 &lcd); // draws the number of kills
RexRoshan 0:d9cf94b41df3 80
RexRoshan 0:d9cf94b41df3 81 int _spacecraft_xpos; // x position of the spacecrafts
RexRoshan 0:d9cf94b41df3 82 int _spacecraft_ypos; // y position of the spacecrafts
RexRoshan 0:d9cf94b41df3 83
RexRoshan 0:d9cf94b41df3 84 int _u_cloudx;
RexRoshan 0:d9cf94b41df3 85 int _u_cloudy;
RexRoshan 0:d9cf94b41df3 86
RexRoshan 0:d9cf94b41df3 87 int _l_cloudx;
RexRoshan 0:d9cf94b41df3 88 int _l_cloudy;
RexRoshan 0:d9cf94b41df3 89
RexRoshan 0:d9cf94b41df3 90 int _p1x;
RexRoshan 0:d9cf94b41df3 91 int get_counter(); // value of the counter
RexRoshan 0:d9cf94b41df3 92 int _counter;
RexRoshan 0:d9cf94b41df3 93 int set_counter();
RexRoshan 0:d9cf94b41df3 94
RexRoshan 0:d9cf94b41df3 95 Beam _beam; // Player beam
RexRoshan 0:d9cf94b41df3 96
RexRoshan 0:d9cf94b41df3 97 int _beam_size; // beam size in minigame
RexRoshan 0:d9cf94b41df3 98
RexRoshan 0:d9cf94b41df3 99 Direction _d;
RexRoshan 0:d9cf94b41df3 100 float _mag;
RexRoshan 0:d9cf94b41df3 101
RexRoshan 0:d9cf94b41df3 102 bool _L;
RexRoshan 0:d9cf94b41df3 103 bool _R;
RexRoshan 0:d9cf94b41df3 104 bool spacebeam;
RexRoshan 0:d9cf94b41df3 105 bool score;
RexRoshan 0:d9cf94b41df3 106
RexRoshan 0:d9cf94b41df3 107
RexRoshan 0:d9cf94b41df3 108 Spacecraft _p1; // player spacecraft
RexRoshan 0:d9cf94b41df3 109 MiniEnemy _e1; // Minigame enemy
RexRoshan 0:d9cf94b41df3 110 Background _b1; // Background
RexRoshan 0:d9cf94b41df3 111
RexRoshan 0:d9cf94b41df3 112 int _stage;
RexRoshan 0:d9cf94b41df3 113 int _score;
RexRoshan 0:d9cf94b41df3 114
RexRoshan 0:d9cf94b41df3 115 };
RexRoshan 0:d9cf94b41df3 116
RexRoshan 0:d9cf94b41df3 117 #endif