diff --git a/Faceball2030/assets/hudmeter.png b/Faceball2030/assets/hudmeter.png new file mode 100644 index 0000000..f0fe816 Binary files /dev/null and b/Faceball2030/assets/hudmeter.png differ diff --git a/Faceball2030/main.cpp b/Faceball2030/main.cpp index 427e6ad..7af8c44 100644 --- a/Faceball2030/main.cpp +++ b/Faceball2030/main.cpp @@ -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); diff --git a/Faceball2030/main.h b/Faceball2030/main.h index f338789..be842f8 100644 --- a/Faceball2030/main.h +++ b/Faceball2030/main.h @@ -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>map; @@ -261,6 +261,25 @@ class FaceBall : public PixelGameEngine float fYaw = 0; float pitch = -PI / 6; + std::array 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; diff --git a/Faceball2030/pixelGameEngine.h b/Faceball2030/pixelGameEngine.h index a15639a..0d56d3b 100644 --- a/Faceball2030/pixelGameEngine.h +++ b/Faceball2030/pixelGameEngine.h @@ -667,6 +667,10 @@ namespace olc operator v2d_generic() const { return { static_cast(this->x), static_cast(this->y) }; } operator v2d_generic() const { return { static_cast(this->x), static_cast(this->y) }; } operator v2d_generic() const { return { static_cast(this->x), static_cast(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,