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

#include <raylib.h>


Flash::Flash() :
    m_color {250, 190, 130, 255},
    m_duration {0.23},
    m_flash {0}
{
}


void
Flash::update(const float dt)
{
    if (m_flash > 0)
        m_flash -= dt;
}


void
Flash::draw()
{
    if (m_flash > 0) {
        Color color = m_color;
        color.a *= m_flash / m_duration;
        DrawRectangle(0, 0, 800, 600, color);
    }
}


void
Flash::start()
{
    m_flash = m_duration;
}