Snake.h 1.02 KB
Newer Older
Nelson Phillips's avatar
Nelson Phillips committed
1 2 3 4
#ifndef SNAKE_H
#define SNAKE_H

#include <iostream>
Konrad McClure's avatar
Konrad McClure committed
5
#include <vector>
Nelson Phillips's avatar
Nelson Phillips committed
6

Konrad McClure's avatar
Konrad McClure committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
class Snake;

class Body {
    public:
    
    Body(int xCord, int yCord);
    int getX();
    int getY();
    void changeX(bool updown);
    void changeY(bool updown);
    void follow(int count, Snake* snake);
    int getlastX();
    int getlastY();
    void setLast(int count);
    
    
    private:
    
    int x, y;
    int lastX, lastY;
    char piece;
};
Nelson Phillips's avatar
Nelson Phillips committed
29 30 31 32 33


class Snake {
    public:
        void movement(char input);
Nelson Phillips's avatar
Nelson Phillips committed
34
        bool draw();
Nelson Phillips's avatar
Nelson Phillips committed
35 36
        int snekoScore();
        void clrScreen();
Nelson Phillips's avatar
Nelson Phillips committed
37
        void bodied();
Nelson Phillips's avatar
Nelson Phillips committed
38
        char input;
Nelson Phillips's avatar
Nelson Phillips committed
39 40 41
        int getX();
        int getY();
        void newBody();
Nelson Phillips's avatar
Nelson Phillips committed
42
        void GameOver();
Nelson Phillips's avatar
Nelson Phillips committed
43
        bool fillspace();
Konrad McClure's avatar
Konrad McClure committed
44
        Body getPart(int index) {return parts.at(index); }
Nelson Phillips's avatar
Nelson Phillips committed
45
        
Nelson Phillips's avatar
Nelson Phillips committed
46
    private:
Nelson Phillips's avatar
Nelson Phillips committed
47 48 49 50
    
        int x = 13, y = 13, i = 0, q = 0, score = 0,
        h = 13, o = 23;
        char grid[30][60];
Nelson Phillips's avatar
Nelson Phillips committed
51
        char whtSpace = ' ';
Nelson Phillips's avatar
Nelson Phillips committed
52
        int direction = 5;
Nelson Phillips's avatar
Nelson Phillips committed
53
        int bonusBody = 0;
Konrad McClure's avatar
Konrad McClure committed
54
        std::vector <Body> parts;
Nelson Phillips's avatar
Nelson Phillips committed
55 56
};
#endif