-
Notifications
You must be signed in to change notification settings - Fork 8
/
HUD.cpp
145 lines (136 loc) · 3.9 KB
/
HUD.cpp
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "Engine.h"
#include "UTIL_Misc.h"
//================================================================================================//
/***************
** Render HUD **
****************/
//================================================================================================//
void Engine::RenderHud(float interp)
{
glDisable(GL_TEXTURE_2D);
UTIL_GL::GL2D::SetOrtho(640,480);
UTIL_GL::SetBlend(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glColor4f(0,0,0,1);
glBegin(GL_QUADS);
glVertex2f(0,0);
glVertex2f(640,0);
glColor4f(0,0,0,0);
glVertex2f(640,64);
glVertex2f(0,64);
glVertex2f(0,416);
glVertex2f(640,416);
glColor4f(0,0,0,1);
glVertex2f(640,480);
glVertex2f(0,480);
glEnd();
glDisable(GL_BLEND);
//force charger
UTIL_GL::SetBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
float force = (float)mPlayer.iForceCharge*2;
if(force>200) force = 200;
glBegin(GL_QUADS);
if(mPlayer.iForceCharge>=100)
glColor4f(UTIL_Misc::TimeRamp(0,1,(float)0,25,(float)mPlayer.iChargeFlash),
UTIL_Misc::TimeRamp(0.25f,1,(float)0,25,(float)mPlayer.iChargeFlash),
UTIL_Misc::TimeRamp(0.75f,0,(float)0,25,(float)mPlayer.iChargeFlash),0.7f);
else
glColor4f(0,0.25f,0.75f,0.7f);
glVertex2f(220,430);
if(mPlayer.iForceCharge>=100)
glColor4f(UTIL_Misc::TimeRamp(0,1,(float)0,25,(float)mPlayer.iChargeFlash),
UTIL_Misc::TimeRamp(0.5f,1,(float)0,25,(float)mPlayer.iChargeFlash),
UTIL_Misc::TimeRamp(1,0,(float)0,50,(float)mPlayer.iChargeFlash),0.7f);
else
glColor4f(0,0.5f,1,0.7f);
glVertex2f(220+force,430);
glVertex2f(220+force,450);
if(mPlayer.iForceCharge>=100)
glColor4f(UTIL_Misc::TimeRamp(0,1,(float)0,25,(float)mPlayer.iChargeFlash),
UTIL_Misc::TimeRamp(0.25f,1,(float)0,25,(float)mPlayer.iChargeFlash),
UTIL_Misc::TimeRamp(0.75f,0,(float)0,25,(float)mPlayer.iChargeFlash),0.7f);
else
glColor4f(0,0.25f,0.75f,0.7f);
glVertex2f(220,450);
glColor4f(0,0,0,0.7f);
glVertex2f(220+force,430);
glVertex2f(420,430);
glVertex2f(420,450);
glVertex2f(220+force,450);
glEnd();
glColor4f(0,0,0,0.7f);
glLineWidth(5);
glBegin(GL_LINE_LOOP);
glVertex2f(220,430);
glVertex2f(420,430);
glVertex2f(420,450);
glVertex2f(220,450);
glEnd();
glLineWidth(1);
glColor4f(1,1,1,0.75f);
UTIL_GL::SetBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
UTIL_GL::BindTexture(GL_TEXTURE_2D, imgHudBeam);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(200,424);
glTexCoord2f(1,0);
glVertex2f(232,424);
glTexCoord2f(1,1);
glVertex2f(232,454);
glTexCoord2f(0,1);
glVertex2f(200,454);
glTexCoord2f(1,0);
glVertex2f(402,424);
glTexCoord2f(0,0);
glVertex2f(440,424);
glTexCoord2f(0,1);
glVertex2f(440,454);
glTexCoord2f(1,1);
glVertex2f(402,454);
glTexCoord2f(1,0);
glVertex2f(232,424);
glTexCoord2f(1,0);
glVertex2f(402,424);
glTexCoord2f(1,1);
glVertex2f(402,454);
glTexCoord2f(1,1);
glVertex2f(232,454);
glEnd();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glColor4f(1,1,1,1);
//weapon name
mFont1.SetBlendMode(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
mFont1.SetScale(0.5f,0.5f);
mFont1.SetAlignment(ALIGN_CENTER);
mFont1.SetColor(1,1,0,0.75f);
mFont1.Print("FORCE METER:",320,430);
mFont1.SetScale(1,0.5f);
mFont1.SetColor(1,1,1,1);
if(mPlayer.bHasOrb)
{
switch(mPlayer.mOrb.iWeaponType)
{
case 0: mFont1.Print("PLASMA",320,452); break;
case 1: mFont1.Print("RAIL",320,452); break;
case 2: mFont1.Print("PULSE",320,452); break;
case 3: mFont1.Print("MAGMA",320,452); break;
}
}
char sz[32];
mFont1.SetScale(0.5f,0.5f);
mFont1.SetAlignment(ALIGN_LEFT);
mFont1.Print("SCORE:",100, 16);
sprintf(sz,"TOP:");
mFont1.Print(sz,320,16);
sprintf(sz,"LIVES");
mFont1.Print(sz,10,16);
mFont2.SetScale(0.5f,0.5f);
mFont2.SetColor(1,1,1,1);
mFont2.SetAlignment(ALIGN_LEFT);
sprintf(sz,"%i",mPlayer.iLives);
mFont2.Print(sz,60,16);
sprintf(sz,"%.8i",mPlayer.iScore);
mFont2.Print(sz,155,16);
sprintf(sz,"%.8i %s",iHiScore[0],szHiScore[0]);
mFont2.Print(sz,355,16);
}