1

Dependencies:   mbed Gamepad N5110

Snake/Snake.h

Committer:
1012754868
Date:
2019-05-05
Revision:
7:cafa0b96e8d3
Parent:
6:1ad8c738b9b7
Child:
9:5f73221012bf

File content as of revision 7:cafa0b96e8d3:

#ifndef SNAKE_H
#define SNAKE_H

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


struct snakePart{
    char _x[4000];
    char _y[4000];
    char _dirc[4000];
    
    };
    


/** My Snake Class
* @brief Class for defining snake's properties and states
* @author Li Saiwen
* @date May, 2019
*/
class Snake{

    public:
    
        /** Constructor */
        Snake();
        
        /** Destructor */
        ~Snake();
        
        /** initial snake's property
        * @param the value of the initial cooridnate_x(int), coordinate_y(int), length(int), live(int)
        */
        void init(int x, int y, int length,int _live);
        
        /** draw snake
        * @param the subclass of N5110(lcd) and Gamepad(pad)
        */
        void drawsnake(N5110 &lcd, Gamepad &pad);
        
        /** Determine the movement of snake
        * @param the subclass of Gamepad(pad)
        */
        void snakemov(Gamepad &pad);
        
        /** Determine if the snake is dead
        * @param the subclass of N5110(lcd) and Gamepad(pad)
        * @return  return 0
        */
        int dead(N5110 &lcd, Gamepad &pad);
        
        /** Determine if the snake eats food
        * @param the subclass of Gamepad(pad)
        */
        void eat(Gamepad &pad);
        
        /** Determine if the snake collide the wall
        * @param the subclass of N5110(lcd) and Gamepad(pad)
        */
        void check_WallCollision(N5110 &lcd, Gamepad &pad);
        
        /** Determine if the snake collide the tail
        * @param the subclass of N5110(lcd) and Gamepad(pad)
        */
        void check_TailCollision(N5110 &lcd, Gamepad &pad);
        
        /** Draw the current health points and score
        * @param the subclass of N5110(lcd)
        */
        void drawscore(N5110 &lcd);
        
        /** Make a noise when eating food
        * @param the subclass of Gamepad(pad)
        */
        void Tone_1(Gamepad &pad);
        
        /** Make a noise when collide wall
        * @param the subclass of Gamepad(pad)
        */
        void game_music(Gamepad &pad);
        int _length;
        int live;
        float waitTime;
        float waitExpect;
        int _speed;
        int Highest_score;
        
        
           
    private:
        
        int _direction;
        int initx;
        int inity;
        int initl;
        int x;
        Direction d;
        Food _food;
        
        
};
    
    #endif