-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhud.c
69 lines (49 loc) · 1.68 KB
/
hud.c
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
#include "hud.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "defs.h"
#include "snge.h"
#include "sprites.h"
static Sprite *sPoints;
static Sprite *sDepth;
static Sprite *sPointsLabel;
static Sprite *sDepthLabel;
static Sprite *airGauge;
static void setTextFromInt(Sprite *fontSprite, int value)
{
snprintf(fontSprite->text, _STR_BUFLEN, "%d", value);
}
void hud_Init()
{
SpriteClassId mainFont = sprites_GetIdByName("font:base");
SpriteClassId labelFont = sprites_GetIdByName("font:hollow");
SpriteClassId smallFont = sprites_GetIdByName("font:small");
int hx = _ACTION_AREA_WIDTH + 20;\
int hy = 20;
sPointsLabel = snge_AddFontSprite(labelFont, point(hx, hy), _HUD_FONT_LAYER, "Points");
sPointsLabel->relative = true;
sPoints = snge_AddFontSprite(mainFont, point(hx, hy + 40), _HUD_FONT_LAYER, "0");
sPoints->relative = true;
sDepthLabel = snge_AddFontSprite(labelFont, point(hx, hy + 102), _HUD_FONT_LAYER, "DEPTH");
sDepthLabel->relative = true;
sDepth = snge_AddFontSprite(mainFont, point(hx, hy + 142), _HUD_FONT_LAYER, "0");
sDepth->relative = true;
airGauge = snge_AddGaugeSprite(sprites_GetIdByName("level_common:gauge-fill"), point(hx, hy + 260), _HUD_FONT_LAYER, GAUGE_DU);
airGauge->gaugeFill = 1.0;
airGauge->relative = true;
Sprite *s = snge_AddSprite(sprites_GetIdByName("level_common:gauge-over"), point(hx, hy + 260), _HUD_FONT_LAYER + 1);
s->relative = true;
}
void hud_SetPoints(int points)
{
setTextFromInt(sPoints, points);
}
void hud_SetDepth(int depth)
{
setTextFromInt(sDepth, depth);
}
void hud_SetAir(float percent)
{
airGauge->gaugeFill = percent / 100.0;
}