-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathThrowings.cpp
54 lines (49 loc) · 1.1 KB
/
Throwings.cpp
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
#include "Throwings.h"
#include "ScoreAndLife.h"
void Throwings::update(ScoreAndLife& score) {
if (destroyed == true) {
return;
}
if (this->is_food) {
Vector2f pos = food.getPosition();
if (pos.y > 480.0f - 26.0f) {
speed = 0;
destroyed = true;
clock.restart();
}
food.move(0.0f, 1.0f * speed);
}
else {
Vector2f pos = ddong.getPosition();
if (pos.y > 480.0f - 26.0f) {
speed = 0;
destroyed = true;
clock.restart();
}
ddong.move(0.0f, 1.0f * speed);
}
};
void Throwings::draw(RenderWindow& _window) {
if (destroyed) {
if (clock.getElapsedTime().asMilliseconds() > 500) {
return;
}
}
if (is_food) {
_window.draw(food);
}
else {
_window.draw(ddong);
}
};
FloatRect Throwings::getArea() {
if (this->is_food) {
return food.getGlobalBounds();
}
else {
return ddong.getGlobalBounds();
}
};
bool Throwings::get_is_food(void) {
return (this->is_food);
};