-
Notifications
You must be signed in to change notification settings - Fork 0
/
Decorations.h
59 lines (51 loc) · 1.42 KB
/
Decorations.h
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
#pragma once
#include "Entity.h"
#include "Sprites.h"
#include "Renderables.h"
class Decoration : public Renderable
{
using base = Renderable;
protected:
float fade_begin = 0; // Life at which to being linearly fading out
public:
float& FadeBegin() { return fade_begin; }
Decoration(const Sprite& sprite, const Position& base, const Size& size, const Vector2& speed = { 0, 0 })
: Renderable(sprite, base, size)
{
Speed() = speed;
}
Decoration(const Sprite& sprite, const Position& base, const Size& size, const Vector2& speed, float life)
: Decoration(sprite, base, size, speed)
{
Life() = life;
LifeDrain() = 1.f;
FadeBegin() = life;
}
[[nodiscard]] virtual EntityType GetType() const { return EntityType::Decoration; }
void Advance(float delta) override
{
base::Advance(delta);
if (Life() < FadeBegin()) {
tint = ((uint8_t)(255 * Life() / FadeBegin()) << 24) | (0x00ffffff & Tint());
}
}
};
class Wormhole : public Decoration
{
float fx_timer = 0;
static constexpr float fx_tick = 1.0f;
bool activated = false;
public:
Wormhole(const Position& base, const Size& size)
: Decoration(GetSprites().Glyphs['o'], base, size)
{
Tint() = 0x44ffffff;
}
[[nodiscard]] virtual EntityType GetType() const { return EntityType::Wormhole; }
void Advance(float delta) override;
void Collide(const Entity& other) override;
bool GetActivated() { return activated; }
private:
using base = Decoration;
public:
};