Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

Committer:
AhmedPlaymaker
Date:
Thu Apr 18 06:19:33 2019 +0000
Revision:
36:dfdd619874ae
Parent:
25:e827f1a8fadc
Child:
38:30e4e6191762
Minor Bug fixes, and performance improvements. #UpdateVibes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AhmedPlaymaker 9:d1d79d4ee673 1 #ifndef SNAKEFOOD_H
AhmedPlaymaker 9:d1d79d4ee673 2 #define SNAKEFOOD_H
AhmedPlaymaker 9:d1d79d4ee673 3
AhmedPlaymaker 9:d1d79d4ee673 4 #include "mbed.h"
AhmedPlaymaker 9:d1d79d4ee673 5 #include "N5110.h"
AhmedPlaymaker 9:d1d79d4ee673 6 #include "Gamepad.h"
AhmedPlaymaker 9:d1d79d4ee673 7
AhmedPlaymaker 9:d1d79d4ee673 8
AhmedPlaymaker 9:d1d79d4ee673 9 class SnakeFood
AhmedPlaymaker 9:d1d79d4ee673 10 {
AhmedPlaymaker 9:d1d79d4ee673 11 public:
AhmedPlaymaker 9:d1d79d4ee673 12 SnakeFood();
AhmedPlaymaker 9:d1d79d4ee673 13 ~SnakeFood();
AhmedPlaymaker 9:d1d79d4ee673 14
AhmedPlaymaker 9:d1d79d4ee673 15 /** Initialise SnakeFood
AhmedPlaymaker 9:d1d79d4ee673 16 *
AhmedPlaymaker 9:d1d79d4ee673 17 * This function initialises the SnakeFood library.
AhmedPlaymaker 9:d1d79d4ee673 18 */
AhmedPlaymaker 9:d1d79d4ee673 19 void init();
AhmedPlaymaker 9:d1d79d4ee673 20
AhmedPlaymaker 9:d1d79d4ee673 21 /** Draw
AhmedPlaymaker 9:d1d79d4ee673 22 *
AhmedPlaymaker 9:d1d79d4ee673 23 * This function draws the SnakeFood sprite onto the screen.
AhmedPlaymaker 9:d1d79d4ee673 24 */
AhmedPlaymaker 36:dfdd619874ae 25 void draw(N5110 &lcd, int blockbuff);
AhmedPlaymaker 9:d1d79d4ee673 26
AhmedPlaymaker 9:d1d79d4ee673 27 /** Update
AhmedPlaymaker 9:d1d79d4ee673 28 *
AhmedPlaymaker 9:d1d79d4ee673 29 * This function updates the position of the SnakeFood as it moves down the screen.
AhmedPlaymaker 9:d1d79d4ee673 30 */
AhmedPlaymaker 9:d1d79d4ee673 31 void update();
AhmedPlaymaker 9:d1d79d4ee673 32
AhmedPlaymaker 9:d1d79d4ee673 33 /** Get Position
AhmedPlaymaker 9:d1d79d4ee673 34 *
AhmedPlaymaker 9:d1d79d4ee673 35 * This function obtains the coordinates of the top-left pixel in the SnakeFood sprite.
AhmedPlaymaker 9:d1d79d4ee673 36 */
AhmedPlaymaker 9:d1d79d4ee673 37 Vector2D get_pos();
AhmedPlaymaker 9:d1d79d4ee673 38
AhmedPlaymaker 9:d1d79d4ee673 39 /** Set Position
AhmedPlaymaker 9:d1d79d4ee673 40 *
AhmedPlaymaker 9:d1d79d4ee673 41 * This function is used to change the position of the sprite to specific coordinates when called.
AhmedPlaymaker 9:d1d79d4ee673 42 */
AhmedPlaymaker 9:d1d79d4ee673 43 void set_pos(Vector2D p);
AhmedPlaymaker 9:d1d79d4ee673 44
AhmedPlaymaker 9:d1d79d4ee673 45 private:
AhmedPlaymaker 9:d1d79d4ee673 46 int n;
AhmedPlaymaker 9:d1d79d4ee673 47 int _fx; //food x
AhmedPlaymaker 9:d1d79d4ee673 48 int _fy; //food y
AhmedPlaymaker 9:d1d79d4ee673 49 int fooddrop; //this makes food 1,2,and 3 drop at reasonable speeds
AhmedPlaymaker 9:d1d79d4ee673 50
AhmedPlaymaker 9:d1d79d4ee673 51 Vector2D _velocity;
AhmedPlaymaker 9:d1d79d4ee673 52
AhmedPlaymaker 9:d1d79d4ee673 53 };
AhmedPlaymaker 9:d1d79d4ee673 54 #endif