-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwave.cpp
70 lines (56 loc) · 1.13 KB
/
wave.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "config.hpp"
#include "wave.hpp"
Wave::Wave() : _isAlive(true), _isMissed(false)
{
}
Wave::~Wave()
{
}
bool Wave::init(sf::Texture &texture)
{
_sprite.setTexture(texture);
_sprite.setPosition(WINDOW_WIDTH - _sprite.getGlobalBounds().width, - _sprite.getGlobalBounds().height);
return true;
}
bool Wave::init(bool retry)
{
_sprite.setPosition(WINDOW_WIDTH - _sprite.getGlobalBounds().width, - _sprite.getGlobalBounds().height);
return true;
}
void Wave::update(sf::Time elapsedTime, sf::Time deltaTimeWaves)
{
_elapsedTime += elapsedTime;
if(_elapsedTime > deltaTimeWaves)
{
_sprite.move(0, 1);
if(_sprite.getPosition().y > WINDOW_HEIGHT)
{
_isMissed = true;
}
_elapsedTime = _elapsedTime.Zero;
}
}
void Wave::draw(sf::RenderWindow &app)
{
app.draw(_sprite);
}
void Wave::die()
{
_isAlive = false;
}
bool Wave::isAlive()
{
return _isAlive;
}
bool Wave::isMissed()
{
return _isMissed;
}
sf::Rect<float> Wave::getRect()
{
return _sprite.getGlobalBounds();
}
sf::Vector2f Wave::getPosition()
{
return _sprite.getPosition();
}