summaryrefslogtreecommitdiffhomepage
path: root/TestStage.cpp
blob: d858fcb8e03c87c7ae7915f7a1588170da607c71 (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
#include "TestStage.h"

#include <memory>
#include <utility>

#include <raylib.h>

#include "EnemyFactory.h"


TestStage::TestStage() :
    m_player {},
    m_const {}
{
    m_enemies.reserve(5);
    m_enemies.push_back(std::move(EnemyFactory::make_example(m_const.m_bullets, 300, -10, 0)));
    m_enemies.push_back(std::move(EnemyFactory::make_example(m_const.m_bullets, 500, -10, 0, true)));
    m_enemies.push_back(std::move(EnemyFactory::make_example(m_const.m_bullets, 400, -10, 10)));
    m_enemies.push_back(std::move(EnemyFactory::make_example(m_const.m_bullets, 550, -10, 20)));
    m_enemies.push_back(std::move(EnemyFactory::make_example(m_const.m_bullets, 250, -10, 20, true)));
}


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();
}