-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
===================================================== | ||
Remaking Cavestory in C++ | ||
Episode 14 - The HUD - Part 1 | ||
By: Limeoats | ||
Website: www.limeoats.com | ||
Twitter: @Limeoats | ||
Github: https://github.com/Limeoats/cavestory-development | ||
Reddit: http://www.reddit.com/r/Limeoats | ||
===================================================== | ||
|
||
|
||
===================================================== | ||
Problem | ||
===================================================== | ||
-We need to see certain information on the screen | ||
-Health | ||
-Gun EXP | ||
-Gun Level | ||
-In this episode, we'll be getting health on the screen | ||
|
||
===================================================== | ||
Details | ||
===================================================== | ||
TextBox.pbm | ||
-Health bar sprite: | ||
x: 0 | ||
y: 40 | ||
width: 64 | ||
height: 8 | ||
screen pos x: 35 | ||
screen pos y: 70 | ||
-Health number sprite: | ||
x: 0 | ||
y: 56 | ||
width: 8 | ||
height: 8 | ||
screen pos x: 66 | ||
screen pos y: 70 | ||
|
||
===================================================== | ||
Solution | ||
===================================================== | ||
-Add player health | ||
-Create a bunch of Sprite objects in a new HUD class | ||
-Special update/drawing logic | ||
-Add it to the game class | ||
|
||
|
||
|
||
===================================================== | ||
Next time | ||
===================================================== | ||
-More HUD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef HUD_Hf | ||
#define HUD_H | ||
|
||
#include "sprite.h" | ||
#include "player.h" | ||
|
||
class Graphics; | ||
|
||
class HUD { | ||
public: | ||
HUD(); | ||
HUD(Graphics &graphics, Player &player); | ||
void update(int elapsedTime); | ||
void draw(Graphics &graphics); | ||
|
||
private: | ||
Player _player; | ||
|
||
Sprite _healthBarSprite; | ||
Sprite _healthNumber1; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "hud.h" | ||
|
||
#include "graphics.h" | ||
|
||
HUD::HUD() {} | ||
|
||
HUD::HUD(Graphics &graphics, Player &player) { | ||
this->_player = player; | ||
this->_healthBarSprite = Sprite(graphics, "content/sprites/TextBox.png", 0, 40, 64, 8, 35, 70); | ||
this->_healthNumber1 = Sprite(graphics, "content/sprites/TextBox.png", 0, 56, 8, 8, 66, 70); | ||
} | ||
|
||
void HUD::update(int elapsedTime) { | ||
this->_healthNumber1.setSourceRectX(8 * this->_player.getCurrentHealth()); | ||
} | ||
|
||
void HUD::draw(Graphics &graphics) { | ||
this->_healthBarSprite.draw(graphics, this->_healthBarSprite.getX(), this->_healthBarSprite.getY()); | ||
this->_healthNumber1.draw(graphics, this->_healthNumber1.getX(), this->_healthNumber1.getY()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters