This repository was archived by the owner on Oct 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathobjects.hpp
More file actions
58 lines (54 loc) · 1.26 KB
/
objects.hpp
File metadata and controls
58 lines (54 loc) · 1.26 KB
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
#pragma once
class Fragment {
public:
int x; // Position horizontale
int y; // Position verticale
Fragment(int newX, int newY, SDL_Renderer* newRenderer);
~Fragment();
void move(int newX, int newY);
void createFragment(int newX, int newY);
void printAndNext(int angle);
void printHeadSkin(int angle);
bool checkCollision(int newX, int newY);
Fragment* next; // Next fragment
private:
SDL_Texture* headTexture;
SDL_Texture* bodyTexture;
SDL_Texture* L_bodyTexture;
SDL_Texture* tailTexture;
SDL_Renderer* renderer;
};
class Fruit {
public:
Fruit(SDL_Renderer* renderer);
~Fruit();
int x;
int y;
int type;
void relocate(Fragment* Head, Fragment* Tail);
void print(SDL_Renderer* renderer);
private:
SDL_Texture* appleTexture;
SDL_Texture* jamTexture;
SDL_Texture* shieldTexture;
SDL_Texture* poopTexture;
};
class Snake {
public:
Snake(int newX, int newY, int dir, SDL_Renderer* newRenderer);
~Snake();
void changeDir(int dir);
void move(int dir);
void eat(Fruit* whatever);
void printEntireSnake();
bool hitAWallOrHimself();
Fragment* Head;
bool shield;
int score;
private:
Fragment* Tail;
int dirX; // Direction horizonale
int dirY; // Direction vertiacale
int actualLenght;
SDL_Renderer* renderer;
};