Prints objects on to a Nokia N5110 LCD display and makes them 'fall' down the display.

Dependents:   Game_Controller_Project

Committer:
Nathanj94
Date:
Thu May 04 11:16:20 2017 +0000
Revision:
14:7d04607cae3b
Parent:
12:ba07ab8cdc35
Child:
15:bb213a2e282b
Doxygen updated

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nathanj94 0:a1d36c50a0b7 1 #ifndef OBJECTS_H
Nathanj94 0:a1d36c50a0b7 2 #define OBJECTS_H
Nathanj94 0:a1d36c50a0b7 3
Nathanj94 0:a1d36c50a0b7 4 #include "mbed.h"
Nathanj94 1:a05d10d3d33f 5 #include "N5110.h"
Nathanj94 0:a1d36c50a0b7 6 #include "Gamepad.h"
Nathanj94 0:a1d36c50a0b7 7 #include "Basket.h"
Nathanj94 4:56ca80919a98 8 #include "Fruit.h"
Nathanj94 0:a1d36c50a0b7 9
Nathanj94 0:a1d36c50a0b7 10 class Objects
Nathanj94 0:a1d36c50a0b7 11 {
Nathanj94 0:a1d36c50a0b7 12 public:
Nathanj94 0:a1d36c50a0b7 13
Nathanj94 0:a1d36c50a0b7 14 Objects();
Nathanj94 0:a1d36c50a0b7 15 ~Objects();
Nathanj94 11:1995b5e6303c 16
Nathanj94 11:1995b5e6303c 17 //INITILISATION FUNCTION//
Nathanj94 12:ba07ab8cdc35 18
Nathanj94 12:ba07ab8cdc35 19 /** Initialise Object
Nathanj94 14:7d04607cae3b 20 *
Nathanj94 14:7d04607cae3b 21 * Sets speed at which objects will "fall" down the screen.
Nathanj94 14:7d04607cae3b 22 * Sets the y co-ordionate at which they will enter (8 by default).
Nathanj94 14:7d04607cae3b 23 * Randomly sets the x co-ordinate at which they will enter, which is one of
Nathanj94 14:7d04607cae3b 24 * 7 pre-determined values.
Nathanj94 14:7d04607cae3b 25 * Randomly sets a value to a variable which determines the shape of the
Nathanj94 14:7d04607cae3b 26 * object and the value of score assosciated with it.
Nathanj94 14:7d04607cae3b 27 * @param speed - "fall" speed of the object (2,3,4,5)
Nathanj94 14:7d04607cae3b 28 */
Nathanj94 11:1995b5e6303c 29 void init(int speed);
Nathanj94 11:1995b5e6303c 30
Nathanj94 12:ba07ab8cdc35 31
Nathanj94 11:1995b5e6303c 32 //UPDATE FUNCTIONS//
Nathanj94 12:ba07ab8cdc35 33
Nathanj94 12:ba07ab8cdc35 34 /** Move Object
Nathanj94 14:7d04607cae3b 35 *
Nathanj94 14:7d04607cae3b 36 * Move the object down the display at a fixed value of x.
Nathanj94 14:7d04607cae3b 37 * @param speed - "fall" speed of the object (2,3,4,5)
Nathanj94 14:7d04607cae3b 38 */
Nathanj94 11:1995b5e6303c 39 void move(int speed);
Nathanj94 12:ba07ab8cdc35 40
Nathanj94 12:ba07ab8cdc35 41 /** Get Score Indicator
Nathanj94 14:7d04607cae3b 42 *
Nathanj94 14:7d04607cae3b 43 * Return value of the variable which determines the value of the score
Nathanj94 14:7d04607cae3b 44 * assosciated with the object (1 to 5).
Nathanj94 14:7d04607cae3b 45 */
Nathanj94 11:1995b5e6303c 46 int get_score_var();
Nathanj94 11:1995b5e6303c 47
Nathanj94 12:ba07ab8cdc35 48
Nathanj94 11:1995b5e6303c 49 //DISPLAY FUNCTIONS//
Nathanj94 12:ba07ab8cdc35 50
Nathanj94 12:ba07ab8cdc35 51 /** Draw Object
Nathanj94 14:7d04607cae3b 52 *
Nathanj94 14:7d04607cae3b 53 * Draw the object on the buffer by calling a draw function from Fruit
Nathanj94 14:7d04607cae3b 54 * using the value of the random variable set in Objects::init(int speed).
Nathanj94 14:7d04607cae3b 55 * @param lcd - N5110 custom library
Nathanj94 14:7d04607cae3b 56 */
Nathanj94 3:0c79211fdfe0 57 void draw(N5110 &lcd);
Nathanj94 12:ba07ab8cdc35 58
Nathanj94 12:ba07ab8cdc35 59 /** Undraw Object
Nathanj94 14:7d04607cae3b 60 *
Nathanj94 14:7d04607cae3b 61 * Draw the inverse of the object to clear it from the buffer when it
Nathanj94 14:7d04607cae3b 62 * reaches a boundary by calling a draw function from Fruit
Nathanj94 14:7d04607cae3b 63 * using the value of the random variable set in Objects::init(int speed).
Nathanj94 14:7d04607cae3b 64 * @param lcd - N5110 custom library
Nathanj94 14:7d04607cae3b 65 */
Nathanj94 3:0c79211fdfe0 66 void undraw(N5110 &lcd);
Nathanj94 12:ba07ab8cdc35 67
Nathanj94 12:ba07ab8cdc35 68 /** Get Undraw indicator
Nathanj94 14:7d04607cae3b 69 *
Nathanj94 14:7d04607cae3b 70 * Return value of the variable that determines which shape to undraw.
Nathanj94 14:7d04607cae3b 71 */
Nathanj94 7:e567cd172d2a 72 int get_undraw_var();
Nathanj94 12:ba07ab8cdc35 73
Nathanj94 12:ba07ab8cdc35 74 /** Get x
Nathanj94 14:7d04607cae3b 75 *
Nathanj94 14:7d04607cae3b 76 * Return the x co-ordinate of the object (3,15,27,39,51,63,75).
Nathanj94 14:7d04607cae3b 77 */
Nathanj94 3:0c79211fdfe0 78 int get_x();
Nathanj94 12:ba07ab8cdc35 79
Nathanj94 12:ba07ab8cdc35 80 /** Get y
Nathanj94 14:7d04607cae3b 81 *
Nathanj94 14:7d04607cae3b 82 * Return the y co-ordinate of the object (0 to 47).
Nathanj94 14:7d04607cae3b 83 */
Nathanj94 3:0c79211fdfe0 84 int get_y();
Nathanj94 1:a05d10d3d33f 85
Nathanj94 1:a05d10d3d33f 86 private:
Nathanj94 1:a05d10d3d33f 87
Nathanj94 12:ba07ab8cdc35 88 //OBJECTS//
Nathanj94 9:252abbc93565 89 Basket basket;
Nathanj94 4:56ca80919a98 90 Fruit fruit;
Nathanj94 4:56ca80919a98 91
Nathanj94 12:ba07ab8cdc35 92 //VARIABLES//
Nathanj94 5:217e18adcba7 93 int score_var;
Nathanj94 4:56ca80919a98 94 int undraw_var;
Nathanj94 3:0c79211fdfe0 95 int x_ref;
Nathanj94 3:0c79211fdfe0 96 int y_ref;
Nathanj94 2:3f42da6a4c89 97 int objects_ep;
Nathanj94 4:56ca80919a98 98 int objects_shape;
Nathanj94 11:1995b5e6303c 99 int objects_speed;
Nathanj94 4:56ca80919a98 100
Nathanj94 1:a05d10d3d33f 101 };
Nathanj94 1:a05d10d3d33f 102 #endif