-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObjectTypes.h
150 lines (150 loc) · 3.49 KB
/
ObjectTypes.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <map>
#include <string>
#include <vector>
#include "ArrowPNG.h"
#include <SFML/Window.hpp>
#include "ArrowShooterPNG.h"
#include <SFML/Graphics.hpp>
int level = 1;
int ghostLevel = 1;
namespace ObjectEnums {
namespace ArrowShooter {
int left = 0;
int up = 1;
int right = 2;
int down = 3;
};
}
struct GhostData {
int time;
sf::Vector2i pPos;
};
class GhostDataArr : std::vector<GhostData> {
int level;
};
struct Token {
sf::CircleShape token;
int x;
int y;
int timestouched = 0;
bool debounce = true;
sf::Color tokencolor = sf::Color::Yellow;
void draw(sf::RenderWindow* window) {
token.setFillColor(tokencolor);
token.setRadius(8);
token.setPosition(x * 16, y * 16);
window->draw(token);
}
};
struct Checkpoint {
sf::CircleShape checkp;
int x;
int y;
int timestouched = 0;
sf::Color cpcolor = sf::Color(0, 255, 0);
sf::Color activatedcolor = sf::Color(0, 128, 0);
void draw(sf::RenderWindow* window) {
if (timestouched > 0)
checkp.setFillColor(activatedcolor);
else
checkp.setFillColor(cpcolor);
checkp.setRadius(8);
checkp.setPosition(x * 16, y * 16);
window->draw(checkp);
}
};
struct Arrow {
sf::Texture Tarrow;
sf::Sprite Sarrow;
float x;
float y;
sf::Color tokencolor = sf::Color::Yellow;
void draw(sf::RenderWindow* window) {
Tarrow.loadFromMemory(ArrowPNG, ArrowPNG_length);
Sarrow.setTexture(Tarrow);
Sarrow.setPosition(x * 16, y * 16);
window->draw(Sarrow);
}
};
struct ArrowShooter {
sf::Texture Tarrowshooter;
sf::Sprite Sarrowshooter;
Arrow arrow;
int x;
int y;
int type = 0;
bool stop = false;
sf::Color tokencolor = sf::Color::Yellow;
void draw(sf::RenderWindow* window) {
Tarrowshooter.loadFromMemory(ArrowShooterPNG, ArrowShooterPNG_length);
Sarrowshooter.setTexture(Tarrowshooter);
Sarrowshooter.setOrigin(0, 0);
if ((arrow.y <= 0 || arrow.y > 20) || (arrow.x <= 0 || arrow.x > 20)) {
float Width1 = 17;
float Width2 = 14;
float X2 = Sarrowshooter.getPosition().x;
float Height1 = 16;
float Height2 = 16;
float Y2 = Sarrowshooter.getPosition().y;
arrow.x = X2 / 16;
arrow.y = Y2 / 16;
if(type == 1)
arrow.y--;
if(type == 2)
arrow.x++;
if(type == 3)
arrow.y++;
if(type == 0)
arrow.x--;
}
if (type == 1) {
Sarrowshooter.setPosition(x * 16, y * 16 + 16);
}
if (type == 2) {
Sarrowshooter.setPosition(x * 16, y * 16);
}
if (type == 3) {
Sarrowshooter.setPosition(x * 16 + 16, y * 16);
}
if (type == 0) {
Sarrowshooter.setPosition(x * 16 + 16, y * 16 + 16);
}
Sarrowshooter.setOrigin(Sarrowshooter.getGlobalBounds().width, Sarrowshooter.getGlobalBounds().height);
Sarrowshooter.setRotation(type * 90);
arrow.Sarrow.setOrigin(0, 0);
arrow.Sarrow.setRotation(type * 90 - 90);
if (ghostLevel != 1)
level = ghostLevel;
if (!stop) {
if (type == ObjectEnums::ArrowShooter::up) {
arrow.y -= 0.2 * (level - (level / 1.2));
}
if (type == ObjectEnums::ArrowShooter::down) {
arrow.y += 0.2 * (level - (level / 1.2));
}
if (type == ObjectEnums::ArrowShooter::right) {
arrow.x += 0.2 * (level - (level / 1.2));
}
if (type == ObjectEnums::ArrowShooter::left) {
arrow.x -= 0.2 * (level - (level / 1.2));
}
}
arrow.draw(window);
window->draw(Sarrowshooter);
}
};
struct Player {
sf::CircleShape player;
int x;
int y;
void draw(sf::RenderWindow* window) {
player.setFillColor(sf::Color::Red);
player.setRadius(8);
player.setPosition(x * 16, y * 16);
window->draw(player);
}
Player(int x1, int y1) {
x = x1;
y = y1;
}
};