Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Tue Apr 02 17:06:22 2019 +0000
Revision:
12:1e601b176437
Parent:
11:d6ceff1ff6d7
Child:
19:05cc9f801468
Completed the snake and block collision function, the blocks decrease in number as the snake collides while the snake decreases in length

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 12:1e601b176437 24 int draw(N5110 &lcd, int length, int blocknum, int srn);
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 10:751bd953fa27 50 int times;
AhmedPlaymaker 10:751bd953fa27 51 int pos;
AhmedPlaymaker 10:751bd953fa27 52 int blockdrop;
AhmedPlaymaker 10:751bd953fa27 53 int caseselect[5];
AhmedPlaymaker 10:751bd953fa27 54 int i;
AhmedPlaymaker 12:1e601b176437 55 int send;
AhmedPlaymaker 10:751bd953fa27 56
AhmedPlaymaker 11:d6ceff1ff6d7 57
AhmedPlaymaker 10:751bd953fa27 58
AhmedPlaymaker 10:751bd953fa27 59 private:
AhmedPlaymaker 10:751bd953fa27 60 int k;
AhmedPlaymaker 10:751bd953fa27 61 int _bx; //block x
AhmedPlaymaker 10:751bd953fa27 62 int _by; //block y
AhmedPlaymaker 10:751bd953fa27 63
AhmedPlaymaker 10:751bd953fa27 64 Vector2D _velocity;
AhmedPlaymaker 10:751bd953fa27 65
AhmedPlaymaker 10:751bd953fa27 66 };
AhmedPlaymaker 10:751bd953fa27 67 #endif