Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

GameObjects/Snake/Snake.h

Committer:
AhmedPlaymaker
Date:
2019-05-06
Revision:
83:329da564799a
Parent:
81:4c1641e10dcd
Child:
87:871d9fecb593

File content as of revision 83:329da564799a:

#ifndef Snake_H
#define Snake_H

#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"


class Snake
{
public:


    Snake();
    ~Snake();

    /** Initialise Snake
    *
    *   This function initalises the Snake library.
    */
    void init(N5110 *lcd);
    
    void _setLength(int length);
    void _setSpeed(int speed);

    /** Draw
    *
    *   This function draws the Snake sprite onto the screen at the specified coordinates.
    */
    void draw();

    /** Set Position
    *
    *   This function sets a position for where the snake should spawn.
    */
    void set_pos(Vector2D p);

    /** Update
    *
    *   This function updates the Snake sprite position on screen.
    */
    void update(Direction d, int* b);
    
    /** Chain Snake Together
    *
    *   This function makes all of the snake beeds chained together by making the lower ones drag towards where the top one was in the previous loop
    */
    void chainSnakeTogether(int* b);

    /** Moove Snake
    *
    *   This function makes the controls of W/E directions only exclusive to the top beed in the snake
    */
    void mooveSnake(Direction d, int* b);

    /** Set Snake Limits
    *
    *   This function makes sure that the snake stays where it is when it ate food and does not travel off the screen.
    */
    void _setSnakeLimits();

    /** Get Position
    *
    *   This function obtains the coordinate of the top-left pixel in the Snake sprite.
    */
    Vector2D get_pos(int snakeIndex);

    int reset;
    int b[10];  //each element in this array represents the beed number in the snake.

private:
    int _speed;  //this is the speed of the snake flowing in the x axis.
    int _x[10];  //each element in this array represents the x position of each beed in the snake.
    int _y[10];  //each element in this array represents the y position of each beed in the snake.
    int _length;
    
    //Pointer to the game pad object pad.
    Gamepad *_pad;
    //Pointer to the N5110 object lcd.
    N5110 *_lcd;

};
#endif