Controllable HUD meters added.
This commit is contained in:
parent
16533afa58
commit
9b725bf02a
BIN
Faceball2030/assets/hudmeter.png
Normal file
BIN
Faceball2030/assets/hudmeter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1001 B |
@ -1285,6 +1285,7 @@ bool FaceBall::OnUserCreate()
|
||||
life2 = new Decal(new Sprite("assets/life2.png"));
|
||||
life1 = new Decal(new Sprite("assets/life1.png"));
|
||||
crosshair = new Decal(new Sprite("assets/crosshair.png"));
|
||||
hudmeter = new Decal(new Sprite("assets/hudmeter.png"));
|
||||
|
||||
enemy_ShootMe = { "assets/enemies/ShootMe.obj", enemy_ShootMe_tex };
|
||||
enemy_IShoot = { "assets/enemies/IShoot.obj", enemy_IShoot_tex };
|
||||
@ -1511,6 +1512,9 @@ void FaceBall::RenderHud(float fElapsedTime) {
|
||||
hudAdjustment.y += hudShakeAmt * 4;
|
||||
}
|
||||
vf2d hudLoc = { hudAdjustment.x + (hp>0?hudOffset:0),hudAdjustment.y};
|
||||
DrawWarpedDecal(hudmeter, { meter_ARMOR[0] + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)} / 2,meter_ARMOR[1] + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)} / 2,meter_ARMOR[2].lerp(meter_ARMOR[1],1 - float(armorUpgrades)/maxArmorUpgrades) + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)} / 2, meter_ARMOR[3].lerp(meter_ARMOR[0],1- float(armorUpgrades)/maxArmorUpgrades) + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)} / 2});
|
||||
DrawWarpedDecal(hudmeter, { meter_SPEED[0] + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)}/2, meter_SPEED[1] + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)} / 2,meter_SPEED[2].lerp(meter_SPEED[1],1 - float(speedUpgrades) / maxSpeedUpgrades) + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)}/2, meter_SPEED[3].lerp(meter_SPEED[0],1-float(speedUpgrades) / maxSpeedUpgrades) + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)} / 2 });
|
||||
DrawWarpedDecal(hudmeter, { meter_SHOTS[0] + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)} / 2,meter_SHOTS[1] + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)} / 2,meter_SHOTS[2].lerp(meter_SHOTS[1],1 - float(shotsUpgrades) / maxShotsUpgrades) + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)} / 2, meter_SHOTS[3].lerp(meter_SHOTS[0],1-float(shotsUpgrades) / maxShotsUpgrades) + hudLoc + vf2d{float(hudmeter->sprite->width),float(hudmeter->sprite->height)} / 2});
|
||||
DrawDecal(hudLoc, hud, { 1.05,1.05 });
|
||||
DrawDecal(hudLoc + vf2d{ 704+32,56+18 }, life4, { 1,1 }, float(hp) / maxHP > 0.75f ? WHITE : VERY_DARK_GREEN);
|
||||
DrawDecal(hudLoc + vf2d{ 704 - 64+32,56+18 }, life3, { 1,1 }, float(hp) / maxHP > 0.34f && float(hp) / maxHP <= 0.75f ? WHITE : VERY_DARK_GREEN);
|
||||
|
@ -237,7 +237,7 @@ class FaceBall : public PixelGameEngine
|
||||
|
||||
Decal* dot, * enemy_ShootMe_tex,*bullet_tex,*wall_tex,*floor_tex,
|
||||
*enemy_Sonar_tex,*hud,*exit_wall_tex,*enemy_IShoot_tex,
|
||||
*life4,*life3,*life2,*life1,*crosshair;
|
||||
*life4,*life3,*life2,*life1,*crosshair,*hudmeter;
|
||||
vi2d MAP_SIZE;
|
||||
vi2d exitCoords = { 0,0 };
|
||||
std::vector<std::vector<MapSquare>>map;
|
||||
@ -261,6 +261,25 @@ class FaceBall : public PixelGameEngine
|
||||
float fYaw = 0;
|
||||
float pitch = -PI / 6;
|
||||
|
||||
std::array<vf2d,4> meter_ARMOR = {
|
||||
vf2d{1034,218},
|
||||
vf2d{1039,260},
|
||||
vf2d{1166,244},
|
||||
vf2d{1164,195}
|
||||
},
|
||||
meter_SPEED = {
|
||||
vf2d{1038,360},
|
||||
vf2d{1038,405},
|
||||
vf2d{1167,408},
|
||||
vf2d{1167,360}
|
||||
},
|
||||
meter_SHOTS = {
|
||||
vf2d{1035,512},
|
||||
vf2d{1032,558},
|
||||
vf2d{1162,575},
|
||||
vf2d{1163,525}
|
||||
};
|
||||
|
||||
Player player = { {3.7,0.3,0.7}, {{0.5,0.5},0.2} };
|
||||
int hp = 3;
|
||||
int maxHP=hp;
|
||||
@ -270,6 +289,10 @@ class FaceBall : public PixelGameEngine
|
||||
float freeRoamCamera_pitch = pitch;
|
||||
float freeRoamCamera_yaw = fYaw;
|
||||
|
||||
int armorUpgrades = 2, maxArmorUpgrades=20;
|
||||
int speedUpgrades = 2, maxSpeedUpgrades=5;
|
||||
int shotsUpgrades = 2, maxShotsUpgrades=3;
|
||||
|
||||
float moveSpd = 2.0f;
|
||||
float hudOffset = 0;
|
||||
float hudOffsetAcc = 0;
|
||||
|
@ -667,6 +667,10 @@ namespace olc
|
||||
operator v2d_generic<int32_t>() const { return { static_cast<int32_t>(this->x), static_cast<int32_t>(this->y) }; }
|
||||
operator v2d_generic<float>() const { return { static_cast<float>(this->x), static_cast<float>(this->y) }; }
|
||||
operator v2d_generic<double>() const { return { static_cast<double>(this->x), static_cast<double>(this->y) }; }
|
||||
|
||||
v2d_generic lerp(const v2d_generic& p2, float t) {
|
||||
return (p2 * t) + *this * (1.0f - t);
|
||||
}
|
||||
};
|
||||
|
||||
// Note: joshinils has some good suggestions here, but they are complicated to implement at this moment,
|
||||
|
Loading…
x
Reference in New Issue
Block a user