ELEC2645 (2018/19) / Mbed 2 deprecated el17mtu_

Dependencies:   mbed

Committer:
el17mtu
Date:
Thu May 09 01:06:23 2019 +0000
Revision:
11:e29b173ccb27
Parent:
10:1c3bdbf2fe9f
score

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