-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWavePlayState.cpp
More file actions
68 lines (54 loc) · 1.54 KB
/
WavePlayState.cpp
File metadata and controls
68 lines (54 loc) · 1.54 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
59
60
61
62
63
64
65
66
67
68
#include "WavePlayState.h"
#include "PlayDriverState.h"
#include "Event.h"
#include "EventQueue.h"
#include "Config.h"
#include <SFML/Graphics/RenderTarget.hpp>
WavePlayState::WavePlayState(PlayDriverState &play) :
PlayState(play)
{
for (size_t i : play_.selectedBulletSpawns_)
{
play_.bulletSpawns_[i].spawnBullet(play_.bulletSpeed_);
}
EventQueue::getInstance().send(
new EventPlaySound(
12));
}
void WavePlayState::update(float deltaTime)
{
play_.bulletPool_.update(deltaTime, play_.player_, play_.bounds_);
if (play_.bulletPool_.isEmpty())
{
play_.incrementWave_();
EventQueue::getInstance().send(
new EventChangePlayState(
PlayStateType::Arrow));
}
play_.particlePool_.update(deltaTime);
play_.player_.update(deltaTime);
play_.player_.constrain(play_.bounds_); // TODO only update when moving
play_.camera_.update(deltaTime);
}
void WavePlayState::updateOnKeyPress(sf::Keyboard::Key key)
{
play_.player_.updateOnKeyPress(key);
}
void WavePlayState::updateOnKeyRelease(sf::Keyboard::Key key)
{
play_.player_.updateOnKeyRelease(key);
}
void WavePlayState::draw(sf::RenderTarget &target, sf::RenderStates states) const
{
states.transform.scale(
sf::Vector2f(
Config::Game::scale,
Config::Game::scale));
states.transform.translate(-play_.camera_.getPosition());
target.draw(play_.arenaSprite_, states);
target.draw(play_.particlePool_, states);
target.draw(play_.player_, states);
target.draw(play_.bulletPool_, states);
target.draw(play_.healthInterface_, states);
target.draw(play_.scoreInterface_, states);
}