#include <acknex.h>
#define PRAGMA_PATH "%EXE_DIR%templatesimages"
FONT *fntCourier20b = "Courier New#20b";
BMAP *bmpBar = "bluebar.pcx";
var nHealthBar = 0;
var nHealthMax = 100;
var nHealth = 100;
PANEL *panHealth = {
pos_x = 100;
pos_y = 100;
window ( 0, 0, 5, 80, bmpBar, 0, nHealthBar );
digits ( 20, 40, "Health [Q+][A-]: %3.1f", fntCourier20b, 1, nHealth );
digits ( 20, 60, "Health Max [W+][S-]: %3.1f", fntCourier20b, 1, nHealthMax );
flags = SHOW;
}
function healthBarUpdate () {
nHealthBar = ( nHealth / nHealthMax ) * ( bmap_height(bmpBar) / 2 );
}
function healthUp () {
while ( key_q ) {
nHealth = minv ( nHealth + 5 * time_step, nHealthMax );
healthBarUpdate ();
wait(1);
}
}
function healthDown () {
while ( key_a ) {
nHealth = maxv ( nHealth - 5 * time_step, 0 );
healthBarUpdate ();
wait(1);
}
}
function healthMaxUp () {
while ( key_w ) {
nHealthMax += 5 * time_step;
healthBarUpdate ();
wait(1);
}
}
function healthMaxDown () {
while ( key_s ) {
nHealthMax = maxv ( nHealthMax - 5 * time_step, 1 );
nHealth = minv ( nHealth, nHealthMax );
healthBarUpdate ();
wait(1);
}
}
function main () {
fps_max = 60;
healthBarUpdate ();
on_q = healthUp;
on_a = healthDown;
on_w = healthMaxUp;
on_s = healthMaxDown;
while ( !key_esc )
wait(1);
sys_exit ( NULL );
}