Li Ruofan 201199450

Dependencies:   mbed

Snake/Snake.h

Committer:
DannyLee
Date:
2020-05-23
Revision:
0:80a59a49d504
Child:
1:bd7c99a5bd10

File content as of revision 0:80a59a49d504:

#ifndef SNAKE_H
#define SNAKE_H

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

/*
ELEC2645 Embedded Systems Project
School of Electronic & Electrical Engineering
University of Leeds
Name: Ruofan Li
Username: el17rl
Student ID Number: 201199450
Date: May, 2020
*/

/* set position */

struct Body{       
         
    char bodyX[5000];
    char bodyY[5000];
    char _Joystick[5000]; 

    };

struct pos{     
    int x;         
    int y;         
    
    };  

class Snake{
    

    public:
    
 
      
        /** Set the initial parameters of the project
         */
        void init(int _x, int _y, int _L,int _life);
        
        void draw(N5110 &lcd);
        
        void update(Gamepad &pad);
        
        void death(N5110 &lcd);
        
        void produceBody();
        
        void changeDir(Gamepad &pad);
        
        void press(Gamepad &pad);
        
        void WallMeet(N5110 &lcd);
        
        void checkBodyMeet(N5110 &lcd);
        
        bool eatApple();
        
        /** Constructor */
        Snake();
        
        /** Destructor */
        ~Snake();
        
        int L;             
        
        int Life;      

        void drawApple(N5110 &lcd);
        
        void produceApple();
        
        void initApple();
        
        pos getPos();
       
    private:
    
        int _direction;
        int beginX;     
        int beginY;   
        int beginL;   
        Direction d;
};
#endif