Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Fri Apr 26 12:16:05 2019 +0000
Revision:
47:b448ffd073e7
Parent:
41:4edac50f010d
Child:
48:d774bb162c61
the default game speed is now rabbit.

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 41:4edac50f010d 24 void draw(N5110 &lcd, int length, int blockgap);
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 12:1e601b176437 30 void update(int blocknum, int srn, int send);
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 12:1e601b176437 38 /** Get Number
AhmedPlaymaker 12:1e601b176437 39 *
AhmedPlaymaker 12:1e601b176437 40 * This function obtains the number inside the Blocks sprite at a specefic location.
AhmedPlaymaker 12:1e601b176437 41 */
AhmedPlaymaker 12:1e601b176437 42 int * get_number();
AhmedPlaymaker 12:1e601b176437 43
AhmedPlaymaker 10:751bd953fa27 44 /** Set Position
AhmedPlaymaker 10:751bd953fa27 45 *
AhmedPlaymaker 10:751bd953fa27 46 * This function is used to change the position of the sprite to specific coordinates when called.
AhmedPlaymaker 10:751bd953fa27 47 */
AhmedPlaymaker 10:751bd953fa27 48 void set_pos(Vector2D p);
AhmedPlaymaker 10:751bd953fa27 49 int state;
AhmedPlaymaker 47:b448ffd073e7 50 double round; //used to save the rounded number to set the value inside the block.
AhmedPlaymaker 10:751bd953fa27 51 int times;
AhmedPlaymaker 10:751bd953fa27 52 int pos;
AhmedPlaymaker 10:751bd953fa27 53 int caseselect[5];
AhmedPlaymaker 10:751bd953fa27 54 int i;
AhmedPlaymaker 12:1e601b176437 55 int send;
AhmedPlaymaker 37:ee47699915b8 56 Vector2D velocity;
AhmedPlaymaker 10:751bd953fa27 57
AhmedPlaymaker 11:d6ceff1ff6d7 58
AhmedPlaymaker 10:751bd953fa27 59
AhmedPlaymaker 10:751bd953fa27 60 private:
AhmedPlaymaker 41:4edac50f010d 61 int _length;
AhmedPlaymaker 10:751bd953fa27 62 int k;
AhmedPlaymaker 10:751bd953fa27 63 int _bx; //block x
AhmedPlaymaker 10:751bd953fa27 64 int _by; //block y
AhmedPlaymaker 10:751bd953fa27 65
AhmedPlaymaker 10:751bd953fa27 66 };
AhmedPlaymaker 10:751bd953fa27 67 #endif