Snake vs Block Game to be run upon K64F.

Dependencies:   mbed

GameObjects/Snake/Snake.h

Committer:
AhmedPlaymaker
Date:
2019-05-04
Revision:
71:4bd2b27693f3
Parent:
70:7caab8069b9b
Child:
77:5c6bd659c32d

File content as of revision 71:4bd2b27693f3:

#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(int length, int speed);

    /** Draw
    *
    *   This function draws the Snake sprite onto the screen at the specified coordinates.
    */
    void draw(N5110 &lcd, int length, int level);

    /** 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 m;
    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[15];  //each element in this array represents the x position of each beed in the snake.
    int _y[15];  //each element in this array represents the y position of each beed in the snake.
    int _length;

};
#endif