Harry Rance 200925395 Embedded Systems Project

Dependencies:   mbed

Committer:
harryrance
Date:
Wed May 03 16:33:20 2017 +0000
Revision:
7:569f3fc70ac5
Parent:
6:dca8b5e2ebe5
Committed with full documentation generated.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
harryrance 3:43970d8d642e 1 #ifndef MENU_H
harryrance 3:43970d8d642e 2 #define MENU_H
harryrance 3:43970d8d642e 3
harryrance 3:43970d8d642e 4 #include "mbed.h"
harryrance 3:43970d8d642e 5 #include "N5110.h"
harryrance 3:43970d8d642e 6 #include "Gamepad.h"
harryrance 3:43970d8d642e 7 #include "Boss.h"
harryrance 3:43970d8d642e 8 #include "Bullet.h"
harryrance 3:43970d8d642e 9
harryrance 6:dca8b5e2ebe5 10 /** Menu Class
harryrance 6:dca8b5e2ebe5 11 @brief Library for generating the pre-game menu.
harryrance 6:dca8b5e2ebe5 12 @brief Can be used to view the purchasable in-game items, exit the game or start the game running.
harryrance 6:dca8b5e2ebe5 13
harryrance 6:dca8b5e2ebe5 14 @author Harry Rance
harryrance 6:dca8b5e2ebe5 15 @date 2nd May 2017
harryrance 6:dca8b5e2ebe5 16
harryrance 6:dca8b5e2ebe5 17 */
harryrance 3:43970d8d642e 18 class Menu
harryrance 3:43970d8d642e 19 {
harryrance 3:43970d8d642e 20 public:
harryrance 6:dca8b5e2ebe5 21
harryrance 6:dca8b5e2ebe5 22 //Constructor
harryrance 3:43970d8d642e 23 Menu();
harryrance 6:dca8b5e2ebe5 24
harryrance 6:dca8b5e2ebe5 25 //Destructor
harryrance 3:43970d8d642e 26 ~Menu();
harryrance 6:dca8b5e2ebe5 27
harryrance 6:dca8b5e2ebe5 28 /** Initialise
harryrance 6:dca8b5e2ebe5 29 * Initialises the parameters for the menu screen.
harryrance 6:dca8b5e2ebe5 30 * @param square_pos - sets the initial y position for the selection square to 25.
harryrance 6:dca8b5e2ebe5 31 * @param all_coins - sets the initial value to 0 for all the coins if the game has just started.
harryrance 6:dca8b5e2ebe5 32 */
harryrance 3:43970d8d642e 33 void initialise(int square_pos, int all_coins);
harryrance 6:dca8b5e2ebe5 34
harryrance 6:dca8b5e2ebe5 35 /** Draw
harryrance 6:dca8b5e2ebe5 36 * Draws all of the menu items depending on which screen should currently be showing.
harryrance 6:dca8b5e2ebe5 37 */
harryrance 3:43970d8d642e 38 void draw(N5110 &lcd);
harryrance 6:dca8b5e2ebe5 39
harryrance 6:dca8b5e2ebe5 40 /** Read Input
harryrance 6:dca8b5e2ebe5 41 * Reads the input from the buttons and the joystick in order to manipulate the current menu screen.
harryrance 6:dca8b5e2ebe5 42 */
harryrance 3:43970d8d642e 43 void read_input(Gamepad &pad);
harryrance 6:dca8b5e2ebe5 44
harryrance 6:dca8b5e2ebe5 45 /** Update
harryrance 6:dca8b5e2ebe5 46 * Updates menu parameters in order to tell where the selection square should be placed, and which screen should show next.
harryrance 6:dca8b5e2ebe5 47 */
harryrance 4:107bdbbf78bf 48 void update(Gamepad &pad, N5110 &lcd);
harryrance 6:dca8b5e2ebe5 49
harryrance 6:dca8b5e2ebe5 50 /** Move Selection Square - Y
harryrance 6:dca8b5e2ebe5 51 * Used to move the selection square in the y direction.
harryrance 6:dca8b5e2ebe5 52 * Used in the initial screen.
harryrance 6:dca8b5e2ebe5 53 * @param d - enum value to denote what direction the joystick has been moved in. Used to move the selection square.
harryrance 6:dca8b5e2ebe5 54 */
harryrance 3:43970d8d642e 55 void move_selection_square_y(Direction d);
harryrance 6:dca8b5e2ebe5 56
harryrance 6:dca8b5e2ebe5 57 /** Move Selection Square - X
harryrance 6:dca8b5e2ebe5 58 * Used to move the selection square in the x direction.
harryrance 6:dca8b5e2ebe5 59 * Used in the shop screen.
harryrance 6:dca8b5e2ebe5 60 * @param d - enum value to denote what direction the joystick has been moved in. Used to move the selection square.
harryrance 6:dca8b5e2ebe5 61 */
harryrance 3:43970d8d642e 62 void move_selection_square_x(Direction d);
harryrance 6:dca8b5e2ebe5 63
harryrance 6:dca8b5e2ebe5 64 //Integer to total al of the user's current coins in order to be displayed.
harryrance 3:43970d8d642e 65 int total_coins();
harryrance 3:43970d8d642e 66
harryrance 6:dca8b5e2ebe5 67 //Starts the game running by moving from the menu screen into the GameEngine.
harryrance 3:43970d8d642e 68 void run_game();
harryrance 6:dca8b5e2ebe5 69
harryrance 6:dca8b5e2ebe5 70 //Stops the game from running and returns to the menu.
harryrance 3:43970d8d642e 71 void stop_game();
harryrance 6:dca8b5e2ebe5 72
harryrance 6:dca8b5e2ebe5 73 //Returns an integer value to tell the program to either stay in the menu section, or move into the main game.
harryrance 3:43970d8d642e 74 int is_game_active();
harryrance 3:43970d8d642e 75
harryrance 3:43970d8d642e 76 private:
harryrance 6:dca8b5e2ebe5 77
harryrance 6:dca8b5e2ebe5 78 /** Draw Initial Screen
harryrance 6:dca8b5e2ebe5 79 * Draws the three options, Start Game, Shop ane Exit.
harryrance 6:dca8b5e2ebe5 80 * Also draws a title at the top of the screen.
harryrance 6:dca8b5e2ebe5 81 */
harryrance 3:43970d8d642e 82 void draw_initial_screen(N5110 &lcd);
harryrance 6:dca8b5e2ebe5 83
harryrance 6:dca8b5e2ebe5 84 /** Draw Selection Square
harryrance 6:dca8b5e2ebe5 85 * Draws the selection square in the requires position with regards to the user input.
harryrance 6:dca8b5e2ebe5 86 */
harryrance 3:43970d8d642e 87 void draw_selection_square(N5110 &lcd);
harryrance 6:dca8b5e2ebe5 88
harryrance 6:dca8b5e2ebe5 89 /** Page Selection
harryrance 6:dca8b5e2ebe5 90 * Identifies which menu page to display next depending on the position of the selection square and the user input.
harryrance 6:dca8b5e2ebe5 91 */
harryrance 3:43970d8d642e 92 void page_selection(Gamepad &pad);
harryrance 6:dca8b5e2ebe5 93
harryrance 6:dca8b5e2ebe5 94 /** Step Back
harryrance 6:dca8b5e2ebe5 95 * Allows the user to use the BACK button in each menu page to step back to the main page.
harryrance 6:dca8b5e2ebe5 96 */
harryrance 3:43970d8d642e 97 void step_back(Gamepad &pad);
harryrance 6:dca8b5e2ebe5 98
harryrance 6:dca8b5e2ebe5 99 /** Initial Screen Selection
harryrance 6:dca8b5e2ebe5 100 * Allows the user to run the game from the first menu page.
harryrance 6:dca8b5e2ebe5 101 */
harryrance 3:43970d8d642e 102 void initial_screen_selection(Gamepad &pad);
harryrance 6:dca8b5e2ebe5 103
harryrance 6:dca8b5e2ebe5 104 /* Draw Shop
harryrance 6:dca8b5e2ebe5 105 * Calls all 5 draw functions for the shop screen in order to draw the full shop view.
harryrance 6:dca8b5e2ebe5 106 * Calls draw_shop_ship_1-4 and draw_heart.
harryrance 6:dca8b5e2ebe5 107 * Also uses a printString statement to print the word "SHOP" at the top of the screen.
harryrance 6:dca8b5e2ebe5 108 */
harryrance 3:43970d8d642e 109 void draw_shop(N5110 &lcd);
harryrance 6:dca8b5e2ebe5 110
harryrance 6:dca8b5e2ebe5 111 /* Draw Shop Ships
harryrance 6:dca8b5e2ebe5 112 * The following 4 functions set the required pixels for drawing the shop versions of the pruchasable ships.
harryrance 6:dca8b5e2ebe5 113 * Shop versions of the ships are twice the size of the in-game ship to be seen more easily.
harryrance 6:dca8b5e2ebe5 114 */
harryrance 3:43970d8d642e 115 void draw_shop_ship_1(N5110 &lcd);
harryrance 3:43970d8d642e 116 void draw_shop_ship_2(N5110 &lcd);
harryrance 3:43970d8d642e 117 void draw_shop_ship_3(N5110 &lcd);
harryrance 3:43970d8d642e 118 void draw_shop_ship_4(N5110 &lcd);
harryrance 6:dca8b5e2ebe5 119
harryrance 6:dca8b5e2ebe5 120 /** Draw Heart
harryrance 6:dca8b5e2ebe5 121 * Draws the heart display sprite for the shop screen.
harryrance 6:dca8b5e2ebe5 122 */
harryrance 3:43970d8d642e 123 void draw_heart(N5110 &lcd);
harryrance 6:dca8b5e2ebe5 124
harryrance 6:dca8b5e2ebe5 125 /** Exit Game
harryrance 6:dca8b5e2ebe5 126 * Turns LCD screen off and brightness to 0.
harryrance 6:dca8b5e2ebe5 127 */
harryrance 4:107bdbbf78bf 128 void exit_game(N5110 &lcd, Gamepad &pad);
harryrance 3:43970d8d642e 129
harryrance 3:43970d8d642e 130 int _square_pos_x;
harryrance 3:43970d8d642e 131 int _square_pos_y;
harryrance 3:43970d8d642e 132 int _square_active;
harryrance 3:43970d8d642e 133 int _is_game_active;
harryrance 3:43970d8d642e 134 int _all_coins;
harryrance 3:43970d8d642e 135 int _page_index;
harryrance 3:43970d8d642e 136
harryrance 3:43970d8d642e 137 Boss _boss;
harryrance 3:43970d8d642e 138 Bullet _bullet;
harryrance 3:43970d8d642e 139
harryrance 3:43970d8d642e 140 Direction _d;
harryrance 3:43970d8d642e 141
harryrance 3:43970d8d642e 142 };
harryrance 3:43970d8d642e 143
harryrance 3:43970d8d642e 144 #endif
harryrance 3:43970d8d642e 145