diff --git a/src/Unuk/Game.cpp b/src/Unuk/Game.cpp index 79aed62..30c909d 100644 --- a/src/Unuk/Game.cpp +++ b/src/Unuk/Game.cpp @@ -44,6 +44,14 @@ gameNavVal_t Game::Run(const string savegameIDArg) { _playerXY.SetXY(10, 50); _playerXY.SetTextBlended("Player coords - XX XX", vsmall, COLOUR_BLACK); + stringstream playerHealth; + _playerHealth.SetXY(10, 80); + _playerHealth.SetTextBlended("Player Health - XX", vsmall, COLOUR_BLACK); + + stringstream npcHealth; + _npcHealth.SetXY(10, 100); + _npcHealth.SetTextBlended("NPC Health - XX", vsmall, COLOUR_BLACK); + _gameRunning = true; while(_gameRunning) { updateTimer.Start(); @@ -79,6 +87,14 @@ gameNavVal_t Game::Run(const string savegameIDArg) { playerXYString.str(""); playerXYString << "Player coords: x" << _player->GetX() << ", y" << _player->GetY(); _playerXY.SetTextBlended(playerXYString.str(), vsmall, COLOUR_BLACK); + + playerHealth.str(""); + playerHealth << "Player Health: " << _player->GetHealth(); + _playerHealth.SetTextBlended(playerHealth.str(), vsmall, COLOUR_BLACK); + + npcHealth.str(""); + npcHealth << "NPC Health: " << _npc->GetHealth(); + _npcHealth.SetTextBlended(npcHealth.str(), vsmall, COLOUR_BLACK); } } // Restrict the fps. @@ -157,6 +173,8 @@ void Game::Render(void) { _gameRenderTime.RenderLiteral(); _gameUpdateTime.RenderLiteral(); _playerXY.RenderLiteral(); + _playerHealth.RenderLiteral(); + _npcHealth.RenderLiteral(); } } else { _ingameMenu.Render(); diff --git a/src/Unuk/Game.h b/src/Unuk/Game.h index acdb560..5a9b0d4 100644 --- a/src/Unuk/Game.h +++ b/src/Unuk/Game.h @@ -50,6 +50,8 @@ private: Text _gameUpdateTime; Text _gameRenderTime; Text _playerXY; + Text _playerHealth; + Text _npcHealth; IngameMenu _ingameMenu; Map _map; diff --git a/src/Unuk/Player.cpp b/src/Unuk/Player.cpp index 1f6afb2..d0eae53 100644 --- a/src/Unuk/Player.cpp +++ b/src/Unuk/Player.cpp @@ -59,7 +59,6 @@ void Player::Update(void) { Move(); AddSpeachBubble("Woot, My name is Allanis, welcome to my home"); - // For now The camera will be static. //SetCamera(); } diff --git a/src/libUnuk/Character.cpp b/src/libUnuk/Character.cpp index 1d75cf9..691f697 100644 --- a/src/libUnuk/Character.cpp +++ b/src/libUnuk/Character.cpp @@ -142,7 +142,7 @@ void Character::Move(void) { if((x < 0) || (x + w) > levelWidth || (x + w) > SCREEN_WIDTH) x -= xVel; if(CheckTileCollisions()) x -= xVel; if(CheckEntityCollisions()) x -= xVel; - if(CheckCharacterCollisions()) x -= xVel; + //if(CheckCharacterCollisions()) x -= xVel; y += yVel; tileX = ((x + (w / 2)) / TILE_WIDTH); diff --git a/src/libUnuk/NPC.cpp b/src/libUnuk/NPC.cpp index 0ac750e..874badf 100644 --- a/src/libUnuk/NPC.cpp +++ b/src/libUnuk/NPC.cpp @@ -13,12 +13,18 @@ NPC::~NPC(void) { } void NPC::Update(void) { + // Store the NPC's health. + int health = GetHealth(); + Move(); if(xVel > 0) directionFacing = FACING_RIGHT; else if(xVel < 0) directionFacing = FACING_LEFT; else if(yVel > 0) directionFacing = FACING_DOWN; else if(yVel < 0) directionFacing = FACING_UP; + + // Deduct health when collision with player is detected. + if(CheckCharacterCollisions()) { health -= 1, SetHealth(health); } } void NPC::Move(void) {