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

#include <memory>

#include <raylib.h>

#include "Globals.h"
#include "Stats.h"
#include "TitleScreen.h"


static constexpr const char* DIED {"The Bone is Gone"};


OverScreen::OverScreen(std::shared_ptr<Stats> stats) :
    m_stats {stats}
{
    const int screen_width = GetScreenWidth();
    const int died_width = MeasureText(DIED, 20);
    m_died_x = (screen_width - died_width) / 2;
    m_flash.start();
}


void
OverScreen::update(const float dt)
{
    m_flash.update(dt);
    if (IsKeyPressed(KEY_SPACE))
        g_game.set(std::make_unique<TitleScreen>());
}


void
OverScreen::draw()
{
    ClearBackground(BLACK);
    DrawText(DIED, m_died_x, 160, 20, RED);
    m_flash.draw();
}