-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHud.h
More file actions
68 lines (60 loc) · 1.67 KB
/
Hud.h
File metadata and controls
68 lines (60 loc) · 1.67 KB
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
60
61
62
63
64
65
66
67
68
#pragma once
#include <stdint.h>
#ifndef WOLF_HEAP_COLD_BUFFERS
#define WOLF_HEAP_COLD_BUFFERS 1
#endif
#include "SGF/DirtyRects.h"
#include "SGF/IRenderTarget.h"
class Hud {
public:
static constexpr int MAX_SCREEN_W = 240;
static constexpr int HUD_H = 40;
static constexpr int HUD_LIVES_X = 4;
static constexpr int HUD_LIVES_Y = 4;
static constexpr int HUD_LIVES_W = 58;
static constexpr int HUD_LIVES_H = 32;
static constexpr int HUD_FACE_X = 74;
static constexpr int HUD_FACE_Y = 4;
static constexpr int HUD_FACE_W = 92;
static constexpr int HUD_FACE_H = 32;
static constexpr int HUD_STATS_X = 176;
static constexpr int HUD_AMMO_Y = 4;
static constexpr int HUD_AMMO_H = 14;
static constexpr int HUD_ENERGY_Y = 21;
static constexpr int HUD_ENERGY_H = 14;
static constexpr int HUD_STATS_W = 60;
enum class FaceMood : uint8_t {
Normal,
Blink,
Shoot,
Hurt,
Low
};
void begin(int screenW, int worldScreenH);
void setLives(int value);
void setAmmo(int value);
void setEnergy(int value);
void setKeys(uint8_t value);
void setFaceMood(FaceMood value);
void invalidate();
void render();
void flush(IRenderTarget& target);
private:
DirtyRects dirty;
#if WOLF_HEAP_COLD_BUFFERS
uint8_t* buffer = nullptr;
#else
uint8_t bufferStorage[MAX_SCREEN_W * HUD_H]{};
uint8_t* buffer = bufferStorage;
#endif
int screenW = 0;
int worldScreenH = 0;
int lives = 3;
int ammo = 99;
int energy = 100;
uint8_t keysMask = 0;
FaceMood faceMood = FaceMood::Normal;
void markDirtyRect(int x, int y, int w, int h);
void fillRect(int x0, int y0, int w, int h, uint16_t color565);
void drawFace(int x, int y, int w, int h);
};