blob: e6406f8322e060cf5bd1167ea4934c8702b8494d (
plain)
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
|
#include "TestStage.h"
#include <memory>
#include <utility>
#include <raylib.h>
#include "ExampleGenerator.h"
#include "FallingAndOscillating.h"
TestStage::TestStage() :
m_player {},
m_const {}
{
m_enemies.reserve(2);
for (const float x : {350.f, 450.f, 400.f}) {
auto position = std::make_shared<Vector2>(Vector2{x, 100.f});
auto generator = std::make_unique<ExampleGenerator>(m_const.m_bullets);
auto behaviour = std::make_unique<FallingAndOscillating>();
if (x > 410.f) {
generator->m_direction *= -1;
behaviour->set_phase(1.f);
}
Enemy enemy(position, std::move(generator), std::move(behaviour));
if (x > 390.f && x < 410.f)
enemy.set_hold(20.f);
m_enemies.push_back(std::move(enemy));
}
}
void
TestStage::update(const float dt)
{
m_player.update(dt);
for (auto& enemy : m_enemies)
enemy.update(dt);
m_const.update(dt);
bool collided = m_player.collide(m_const.m_bullets);
(void) collided;
}
void
TestStage::draw()
{
m_const.draw();
for (auto& enemy : m_enemies)
enemy.draw();
m_player.draw();
}
int
TestStage::total_bullets() const
{
return m_const.m_bullets.size();
}
|