-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnake.h
63 lines (56 loc) · 1.56 KB
/
snake.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
*Author:-Pukar Giri
*Created On:-11Th December 2018 at 21:05
*File Name:-snake.h
*Project Name:-dlibprac
*Licence:- MIT
*Email:[email protected]
*/
#ifndef DLIBPRAC_SNAKE_H
#define DLIBPRAC_SNAKE_H
#include <deque>
#include <SDL2/SDL.h>
class snake
{
private:
SDL_Renderer *renderer;
SDL_Rect headleft={192,64,64,64};
SDL_Rect headright={256,0,64,64};
SDL_Rect headup={192,0,64,64};
SDL_Rect headdown={256,64,64,64};
SDL_Rect tailright={256,128,64,64};
SDL_Rect tailleft={192,192,64,64};
SDL_Rect taildown={256,192,64,64};
SDL_Rect tailup={192,128,64,64};
SDL_Rect bodyvert={128,64,64,64};
SDL_Rect bodyhoriz={64,0,64,64};
SDL_Rect curl1={0,0,64,64};
SDL_Rect curl2={128,0,64,64};
SDL_Rect curl3={0,64,64,64};
SDL_Rect curl4={128,128,64,64};
SDL_Rect null={64,64,64,64};
int curdir;
SDL_Rect* getpeice(int x);
void update();
public:
SDL_Texture *spritesheet;
int initlength=5;
std::deque<SDL_Point> body;
std::deque<int> direction;
int lastdirection;
bool dropped=false;
int_fast8_t xdir;
int_fast8_t ydir;
explicit snake(SDL_Renderer *renderer);
bool died=false;
void draw();
void grow();
void die();
void moveup();
void movedown();
void moveleft();
void moveright();
SDL_Point headpos();
// bool outofbound(int x) const;
};
#endif //DLIBPRAC_SNAKE_H