ELEC2645 (2018/19) / Mbed 2 deprecated el17mtu_

Dependencies:   mbed

Committer:
el17mtu
Date:
Wed May 08 23:29:53 2019 +0000
Revision:
10:1c3bdbf2fe9f
Parent:
9:571f92b0211b
Child:
11:e29b173ccb27
version with comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17mtu 0:15b74f0f8c7f 1 #ifndef MODEA_H
el17mtu 0:15b74f0f8c7f 2 #define MODEA_H
el17mtu 0:15b74f0f8c7f 3
el17mtu 0:15b74f0f8c7f 4 #include "mbed.h"
el17mtu 0:15b74f0f8c7f 5 #include "main.h"
el17mtu 0:15b74f0f8c7f 6 #include "N5110.h"
el17mtu 0:15b74f0f8c7f 7 #include "Gamepad.h"
el17mtu 0:15b74f0f8c7f 8
el17mtu 10:1c3bdbf2fe9f 9
el17mtu 10:1c3bdbf2fe9f 10 /** ModeA Class
el17mtu 10:1c3bdbf2fe9f 11 @brief Controls the bar and the square in the game
el17mtu 10:1c3bdbf2fe9f 12 @author Maria Ungureanu, University of Leeds
el17mtu 10:1c3bdbf2fe9f 13 @date May 2019
el17mtu 10:1c3bdbf2fe9f 14 */
el17mtu 10:1c3bdbf2fe9f 15
el17mtu 10:1c3bdbf2fe9f 16
el17mtu 10:1c3bdbf2fe9f 17
el17mtu 0:15b74f0f8c7f 18
el17mtu 0:15b74f0f8c7f 19
el17mtu 0:15b74f0f8c7f 20 class ModeA
el17mtu 0:15b74f0f8c7f 21 {
el17mtu 0:15b74f0f8c7f 22
el17mtu 0:15b74f0f8c7f 23 public:
el17mtu 10:1c3bdbf2fe9f 24 /** Constructor */
el17mtu 0:15b74f0f8c7f 25 ModeA();
el17mtu 10:1c3bdbf2fe9f 26 /** Destructor */
el17mtu 0:15b74f0f8c7f 27 ~ModeA();
el17mtu 10:1c3bdbf2fe9f 28
el17mtu 10:1c3bdbf2fe9f 29 /**
el17mtu 10:1c3bdbf2fe9f 30 * @brief Sets the screen
el17mtu 10:1c3bdbf2fe9f 31 * @param lcd @details Clears the lcd
el17mtu 10:1c3bdbf2fe9f 32 @code
el17mtu 10:1c3bdbf2fe9f 33 void ModeA::screen(N5110 &lcd)
el17mtu 10:1c3bdbf2fe9f 34 {
el17mtu 0:15b74f0f8c7f 35
el17mtu 10:1c3bdbf2fe9f 36 lcd.clear();
el17mtu 10:1c3bdbf2fe9f 37 lcd.printString("GAME",0,0);
el17mtu 10:1c3bdbf2fe9f 38 lcd.printString("Back:Rules",0,2);
el17mtu 10:1c3bdbf2fe9f 39
el17mtu 10:1c3bdbf2fe9f 40 };
el17mtu 10:1c3bdbf2fe9f 41 @endcode
el17mtu 10:1c3bdbf2fe9f 42 */
el17mtu 0:15b74f0f8c7f 43 void screen(N5110 &lcd);
el17mtu 10:1c3bdbf2fe9f 44
el17mtu 10:1c3bdbf2fe9f 45
el17mtu 10:1c3bdbf2fe9f 46 /**
el17mtu 10:1c3bdbf2fe9f 47 * @brief Sets the screen
el17mtu 10:1c3bdbf2fe9f 48 * @param x_position @details Sets the x coordinate of the square
el17mtu 10:1c3bdbf2fe9f 49 * @param y_position @details Sets they coordinate of the square
el17mtu 10:1c3bdbf2fe9f 50 * @param speed @details Sets the speed of the square
el17mtu 10:1c3bdbf2fe9f 51 * @param gravity @details Sets the value of the gravitational force
el17mtu 10:1c3bdbf2fe9f 52 * @param screen_width @details Sets the value of the gravitational force
el17mtu 10:1c3bdbf2fe9f 53 * @param bar_width @details Sets the width of the bar
el17mtu 10:1c3bdbf2fe9f 54 * @param bar_speed @details Sets the speed of the bar
el17mtu 10:1c3bdbf2fe9f 55 * @param size_top @details Sets the size of the top bar
el17mtu 10:1c3bdbf2fe9f 56 * @param size_bottom @details Sets the size of the bottom bar
el17mtu 10:1c3bdbf2fe9f 57 @code
el17mtu 10:1c3bdbf2fe9f 58 void ModeA::initialise(N5110 &lcd)
el17mtu 10:1c3bdbf2fe9f 59 {
el17mtu 10:1c3bdbf2fe9f 60 //variables for the square
el17mtu 10:1c3bdbf2fe9f 61 x_position = 12;
el17mtu 10:1c3bdbf2fe9f 62 y_position = 18;
el17mtu 10:1c3bdbf2fe9f 63 speed = 0;
el17mtu 10:1c3bdbf2fe9f 64 gravity = 1;
el17mtu 10:1c3bdbf2fe9f 65 //variables for the bar
el17mtu 10:1c3bdbf2fe9f 66 screen_width = 80;
el17mtu 10:1c3bdbf2fe9f 67 bar_width = 10;
el17mtu 10:1c3bdbf2fe9f 68 bar_speed = 2;
el17mtu 10:1c3bdbf2fe9f 69
el17mtu 10:1c3bdbf2fe9f 70 //score = 1;
el17mtu 10:1c3bdbf2fe9f 71
el17mtu 10:1c3bdbf2fe9f 72 //generating random sizes of the bar
el17mtu 10:1c3bdbf2fe9f 73 srand(time(NULL));
el17mtu 10:1c3bdbf2fe9f 74 size_top = rand() % 15;
el17mtu 10:1c3bdbf2fe9f 75 srand(time(NULL));
el17mtu 10:1c3bdbf2fe9f 76 size_bottom = rand() % 15;
el17mtu 10:1c3bdbf2fe9f 77
el17mtu 10:1c3bdbf2fe9f 78
el17mtu 10:1c3bdbf2fe9f 79 }
el17mtu 10:1c3bdbf2fe9f 80 @endcode
el17mtu 10:1c3bdbf2fe9f 81 */
el17mtu 10:1c3bdbf2fe9f 82
el17mtu 10:1c3bdbf2fe9f 83 /** Constructor */
el17mtu 0:15b74f0f8c7f 84 void initialise(N5110 &lcd);
el17mtu 10:1c3bdbf2fe9f 85
el17mtu 10:1c3bdbf2fe9f 86 /** Constructor */
el17mtu 0:15b74f0f8c7f 87 void Bird(N5110 &lcd);
el17mtu 0:15b74f0f8c7f 88
el17mtu 0:15b74f0f8c7f 89
el17mtu 0:15b74f0f8c7f 90 private:
el17mtu 10:1c3bdbf2fe9f 91
el17mtu 10:1c3bdbf2fe9f 92 int x_position;
el17mtu 10:1c3bdbf2fe9f 93
el17mtu 0:15b74f0f8c7f 94 int y_position;
el17mtu 5:1c56acecc96e 95
el17mtu 0:15b74f0f8c7f 96 int gravity;
el17mtu 10:1c3bdbf2fe9f 97
el17mtu 1:44f4594eacac 98 int screen_width;
el17mtu 10:1c3bdbf2fe9f 99
el17mtu 1:44f4594eacac 100 int bar_width;
el17mtu 10:1c3bdbf2fe9f 101
el17mtu 3:8e6950aeec8a 102 int bar_speed;
el17mtu 10:1c3bdbf2fe9f 103
el17mtu 10:1c3bdbf2fe9f 104
el17mtu 9:571f92b0211b 105 int speed;
el17mtu 10:1c3bdbf2fe9f 106
el17mtu 10:1c3bdbf2fe9f 107 int score;
el17mtu 3:8e6950aeec8a 108
el17mtu 3:8e6950aeec8a 109
el17mtu 1:44f4594eacac 110 int size_bottom;
el17mtu 10:1c3bdbf2fe9f 111
el17mtu 3:8e6950aeec8a 112 int size_top;
el17mtu 5:1c56acecc96e 113
el17mtu 9:571f92b0211b 114
el17mtu 0:15b74f0f8c7f 115 };
el17mtu 0:15b74f0f8c7f 116 #endif