add oxygen meter

This commit is contained in:
StrangeD0s
2023-02-18 14:14:23 +01:00
parent fcf9c5d2b7
commit 047877bf0d
11 changed files with 75 additions and 7 deletions
+15 -3
View File
@@ -83,12 +83,16 @@ function toggleDevInfos() {
}
}
// * HUD Renderfunktion
function renderHudSprites() {
const hudObject = {
player_hitpoints: player.currentHitpoints,
player_collected: player.collected,
player_hitpoints: globalObject.hitpoints,
player_collected: globalObject.collected,
player_lifes: globalObject.lifes,
player_ammo: globalObject.ammo,
player_swimming: player.swimming,
player_diving: player.diving,
player_oxygen: Math.trunc(globalObject.oxygen),
}
function hitpoints() {
@@ -98,8 +102,16 @@ function renderHudSprites() {
ctx.font = '12px C64 TrueType'
ctx.fillStyle = 'white'
ctx.fillText(`lifes: ${hudObject.player_lifes}`, 50, 50)
// Hitpoints
ctx.fillText(`HP: ${hudObject.player_hitpoints}`, 20, 40)
// Extralifes
ctx.fillText(`lifes: ${hudObject.player_lifes}`, 20, 20)
// Ammo
ctx.fillText(`ammo: ${hudObject.player_ammo}`, 200, 50)
// Oxygen
ctx.fillText(`O2: ${hudObject.player_oxygen}`, 200, 20)
ctx.restore()
}
hitpoints()