Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Sat Mar 30 17:09:18 2019 +0000
Revision:
10:751bd953fa27
Child:
11:d6ceff1ff6d7
Can now draw blocks and generate random numbers in them, they can be seen on screen, the next step is creating collision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AhmedPlaymaker 10:751bd953fa27 1 #ifndef BLOCKS_H
AhmedPlaymaker 10:751bd953fa27 2 #define BLOCKS_H
AhmedPlaymaker 10:751bd953fa27 3
AhmedPlaymaker 10:751bd953fa27 4 #include "mbed.h"
AhmedPlaymaker 10:751bd953fa27 5 #include "N5110.h"
AhmedPlaymaker 10:751bd953fa27 6 #include "Gamepad.h"
AhmedPlaymaker 10:751bd953fa27 7
AhmedPlaymaker 10:751bd953fa27 8
AhmedPlaymaker 10:751bd953fa27 9 class Blocks
AhmedPlaymaker 10:751bd953fa27 10 {
AhmedPlaymaker 10:751bd953fa27 11 public:
AhmedPlaymaker 10:751bd953fa27 12 Blocks();
AhmedPlaymaker 10:751bd953fa27 13 ~Blocks();
AhmedPlaymaker 10:751bd953fa27 14 /** Initialise Blocks
AhmedPlaymaker 10:751bd953fa27 15 *
AhmedPlaymaker 10:751bd953fa27 16 * This function initialises the Blocks library.
AhmedPlaymaker 10:751bd953fa27 17 */
AhmedPlaymaker 10:751bd953fa27 18 void init();
AhmedPlaymaker 10:751bd953fa27 19
AhmedPlaymaker 10:751bd953fa27 20 /** Draw
AhmedPlaymaker 10:751bd953fa27 21 *
AhmedPlaymaker 10:751bd953fa27 22 * This function draws the Blocks onto the screen.
AhmedPlaymaker 10:751bd953fa27 23 */
AhmedPlaymaker 10:751bd953fa27 24 void draw(N5110 &lcd, int length);
AhmedPlaymaker 10:751bd953fa27 25
AhmedPlaymaker 10:751bd953fa27 26 /** Update
AhmedPlaymaker 10:751bd953fa27 27 *
AhmedPlaymaker 10:751bd953fa27 28 * This function updates the position of the Blocks as they move down the screen.
AhmedPlaymaker 10:751bd953fa27 29 */
AhmedPlaymaker 10:751bd953fa27 30 void update();
AhmedPlaymaker 10:751bd953fa27 31
AhmedPlaymaker 10:751bd953fa27 32 /** Get Position
AhmedPlaymaker 10:751bd953fa27 33 *
AhmedPlaymaker 10:751bd953fa27 34 * This function obtains the coordinates of the top-left pixel in the Blocks sprites.
AhmedPlaymaker 10:751bd953fa27 35 */
AhmedPlaymaker 10:751bd953fa27 36 Vector2D get_pos();
AhmedPlaymaker 10:751bd953fa27 37
AhmedPlaymaker 10:751bd953fa27 38 /** Set Position
AhmedPlaymaker 10:751bd953fa27 39 *
AhmedPlaymaker 10:751bd953fa27 40 * This function is used to change the position of the sprite to specific coordinates when called.
AhmedPlaymaker 10:751bd953fa27 41 */
AhmedPlaymaker 10:751bd953fa27 42 void set_pos(Vector2D p);
AhmedPlaymaker 10:751bd953fa27 43 int state;
AhmedPlaymaker 10:751bd953fa27 44 int times;
AhmedPlaymaker 10:751bd953fa27 45 int pos;
AhmedPlaymaker 10:751bd953fa27 46 int blockdrop;
AhmedPlaymaker 10:751bd953fa27 47 int caseselect[5];
AhmedPlaymaker 10:751bd953fa27 48 int i;
AhmedPlaymaker 10:751bd953fa27 49
AhmedPlaymaker 10:751bd953fa27 50
AhmedPlaymaker 10:751bd953fa27 51 private:
AhmedPlaymaker 10:751bd953fa27 52 int k;
AhmedPlaymaker 10:751bd953fa27 53 int _bx; //block x
AhmedPlaymaker 10:751bd953fa27 54 int _by; //block y
AhmedPlaymaker 10:751bd953fa27 55
AhmedPlaymaker 10:751bd953fa27 56 Vector2D _velocity;
AhmedPlaymaker 10:751bd953fa27 57
AhmedPlaymaker 10:751bd953fa27 58 };
AhmedPlaymaker 10:751bd953fa27 59 #endif