Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Mon May 06 16:15:21 2019 +0000
Revision:
84:9950d561fdf8
Parent:
83:329da564799a
Child:
95:b068b0735f45
Added some more comments to describe what some of my functions and methods do.

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 83:329da564799a 18 void init(N5110 *lcd);
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 83:329da564799a 24 void draw(int length);
AhmedPlaymaker 10:751bd953fa27 25
AhmedPlaymaker 53:527cf297b088 26 /** Draw Frame
AhmedPlaymaker 53:527cf297b088 27 *
AhmedPlaymaker 53:527cf297b088 28 * This function draws the Blocks' sides onto the screen.
AhmedPlaymaker 53:527cf297b088 29 */
AhmedPlaymaker 83:329da564799a 30 void DrawFrame();
AhmedPlaymaker 53:527cf297b088 31
AhmedPlaymaker 53:527cf297b088 32 /** Choose Blocks
AhmedPlaymaker 53:527cf297b088 33 *
AhmedPlaymaker 53:527cf297b088 34 * This function chooses the correct block using a case structure and draws them onto the screen.
AhmedPlaymaker 53:527cf297b088 35 */
AhmedPlaymaker 83:329da564799a 36 void ChooseBlocks();
AhmedPlaymaker 53:527cf297b088 37
AhmedPlaymaker 10:751bd953fa27 38 /** Update
AhmedPlaymaker 10:751bd953fa27 39 *
AhmedPlaymaker 10:751bd953fa27 40 * This function updates the position of the Blocks as they move down the screen.
AhmedPlaymaker 10:751bd953fa27 41 */
AhmedPlaymaker 48:d774bb162c61 42 void update(int blocknum, int blockgap, int srn, int send_block_number);
AhmedPlaymaker 10:751bd953fa27 43
AhmedPlaymaker 10:751bd953fa27 44 /** Get Position
AhmedPlaymaker 10:751bd953fa27 45 *
AhmedPlaymaker 10:751bd953fa27 46 * This function obtains the coordinates of the top-left pixel in the Blocks sprites.
AhmedPlaymaker 10:751bd953fa27 47 */
AhmedPlaymaker 10:751bd953fa27 48 Vector2D get_pos();
AhmedPlaymaker 10:751bd953fa27 49
AhmedPlaymaker 12:1e601b176437 50 /** Get Number
AhmedPlaymaker 12:1e601b176437 51 *
AhmedPlaymaker 12:1e601b176437 52 * This function obtains the number inside the Blocks sprite at a specefic location.
AhmedPlaymaker 12:1e601b176437 53 */
AhmedPlaymaker 12:1e601b176437 54 int * get_number();
AhmedPlaymaker 12:1e601b176437 55
AhmedPlaymaker 10:751bd953fa27 56 /** Set Position
AhmedPlaymaker 10:751bd953fa27 57 *
AhmedPlaymaker 10:751bd953fa27 58 * This function is used to change the position of the sprite to specific coordinates when called.
AhmedPlaymaker 10:751bd953fa27 59 */
AhmedPlaymaker 10:751bd953fa27 60 void set_pos(Vector2D p);
AhmedPlaymaker 47:b448ffd073e7 61 double round; //used to save the rounded number to set the value inside the block.
AhmedPlaymaker 10:751bd953fa27 62 int caseselect[5];
AhmedPlaymaker 12:1e601b176437 63 int send;
AhmedPlaymaker 37:ee47699915b8 64 Vector2D velocity;
AhmedPlaymaker 10:751bd953fa27 65
AhmedPlaymaker 11:d6ceff1ff6d7 66
AhmedPlaymaker 10:751bd953fa27 67
AhmedPlaymaker 10:751bd953fa27 68 private:
AhmedPlaymaker 41:4edac50f010d 69 int _length;
AhmedPlaymaker 81:4c1641e10dcd 70 int reset;
AhmedPlaymaker 10:751bd953fa27 71 int _bx; //block x
AhmedPlaymaker 10:751bd953fa27 72 int _by; //block y
AhmedPlaymaker 84:9950d561fdf8 73
AhmedPlaymaker 83:329da564799a 74 //Pointer to the game pad object pad.
AhmedPlaymaker 83:329da564799a 75 Gamepad *_pad;
AhmedPlaymaker 83:329da564799a 76 //Pointer to the N5110 object lcd.
AhmedPlaymaker 83:329da564799a 77 N5110 *_lcd;
AhmedPlaymaker 10:751bd953fa27 78
AhmedPlaymaker 10:751bd953fa27 79 };
AhmedPlaymaker 10:751bd953fa27 80 #endif