After seeing the post by DRW about how to calculate attack and such, it gave me some thought on how to manage the health of a character and display it.
Since we are with the nes, the simpler the better. Some system seem simple like if it's a heart and equal 1 (Zelda) unit but what about other system in other games?
For example, if you look at the energy bar in Mega Man, one sprite shows up to 4 bars or black when empty. Depending on the hit and which enemy, the amount removed is different so I'm not sure how they would manage that value. Would it be 1 bar = 1 unit, or 1 bar is a % of the value so depending of attack, more or less is removed.
Ninja gaiden is more an horizontal bar with more line but still, I don't think they all calculate 1 bar = 1 unit or averaging some value before removing 1 bar based on the attack of the enemy.
What do you think game system used for managing their health?
In most cases I would think they have "points" and then some nice power of 2 per "represented unit", so Zelda each heart is 2 ( or is it quarters on the NES as well, been a long time since I've looked a NES Zelda). looking up cheat codes for MM for infinite energy it sets the value to 1C which is 28 and there are 28 bars, so 1 unit is 1 unit on the display.
The health bar in Megaman 2 is a single byte value stored at $06C0. It represents the number of "ticks" or individual parts of the health metre to show. For example, $08 would show 8 ticks; $0A would show 10 ticks.
The metre itself is made up of 7 sprites placed horizontally next to one another (i.e. 7 tiles).
There are 5 tiles that are available for the health bar, starting at PPU RAM $0900: one has 4 ticks (tile $90), one has 3 (tile $91), one has 2 ($92), one has 1 ($93), and one has none ($94).
You should be able to figure out from this how it all works/gets put together. :-)
@Oziphantom
So it was really 1 unit = 1 bar in the case of mm, which is simple (and good thing too), which means other games are maybe using simple display too (ninja gaiden etc). I don't know why I was kind of hoping of more complicated things ^^;;
@koitsu
Now with 2 people with the same values, I guess that confirms 100% how mm works
I think I should try to get used to debug game code (never did much yet), that would help finding my answers. It's a skill I'm lacking for now.
You even went the extra mile and found all the information, thanks! Since I like the mm style bar, I may use it for now in my engine until I make my own custom one.
Some thoughts. Not sure if it's useful for anything/anyone.
For action games, I'd always go 1 visible unit = 1 unit of health. Castlevania, Ninja Gaiden, and Mega Man all do this. For a game based on precision, you want the player to know exactly how much HP he or she has left.
Actually, even as a huge fan of Mega Man, I'm not a big fan of the huge resolution of the healthbar. I'm not sure any enemies even exist that only take one unit of health off your bar. The simpler it is, the tighter your game, and the better information you give to the player. Personally, I really like Zelda-style filled in hearts.
In general, healthbars equals leeway in the player's performance, but also in your game design. You always want to design your game so that a good player can get through without taking damage. And if you want "long healthbars", that should be at the expense of having healing items being a very rare luxury if it exists at all. In aforementioned examples, the apparent size of the healthbar usually betrays the actual difficulty of the game, and the smallest unit is usually exclusive to the first stage, or smaller "pest" enemies. In Castlevania, the damage count depends on the stage/loop you are on, and on the final stage of Vs. Castlevania, any enemy will kill you in two hits, despite the health bar having an apparent 16 units of health.
In Ninja Gaiden, the brids are notorious for taking 3 units of health, despite looking like less dangerous threats. The issue here is mostly in terms of "realism", that the player wouldn't expect a bird to be more dangerous than fire from a machinegun. Gameplay-wise, avoiding hits from birds is absolutely central, and getting hit should be punishing, so the balance is actually fine. They remedied this for NG3, where they kept in enemies with the same patterns and damage output as the birds, but replaced the sprite with something more menacing looking.
Having a larger resolution of hit points is IMO only relevant for games like turn based RPGs where taking unavoidable damage is a natural part of the gameplay. And for such larger amounts, I'd definitely go with always representing health with digits, always giving the player an idea of their progress when they level up, etc.
I'd only have a large number of hit points represented by an "abstract" bar for situations like boss health, etc.
I'm convinced Street Fighter II, Street Fighter II Turbo, and Super Street Fighter II use 176 hit points, where 1 pixel = 2 hit points. Would it have been worthwhile to quantize that smaller?
@Sumez
I like systems like mega man/ninja gaiden/castlevania since they are straightforward. Was I think confused me is that Mega man itself receive damage easily but the boss doesn't, unless you have the known weapon against it weakness. I think that is what made me assume that maybe Mega man health may have been managed with a bigger value. How does the boss energy is managed then? 3~4x the value? ^^;;;
tepples wrote:
I'm convinced Street Fighter II, Street Fighter II Turbo, and Super Street Fighter II use 176 hit points, where 1 pixel = 2 hit points. Would it have been worthwhile to quantize that smaller?
Well, vs fighters is another game design where taking damage is an essential part of the concept. Maybe not unavoidable damage, but usually one part takes damage almost constantly.
Sumez wrote:
For action games, I'd always go 1 visible unit = 1 unit of health. Castlevania, Ninja Gaiden, and Mega Man all do this. For a game based on precision, you want the player to know exactly how much HP he or she has left.
Actually, even as a huge fan of Mega Man, I'm not a big fan of the huge resolution of the healthbar. I'm not sure any enemies even exist that only take one unit of health off your bar. The simpler it is, the tighter your game, and the better information you give to the player.
[...]
Wow, thank you very much this is very great advice. It made me feel like working again on my game after a 2-3 year break.
As already pointed out, most games with a lifebar gives a direct visual represnetation of health. One game that does not is Castlevania II - Simon's quest where actually eath unit in the health bar represent 4 hit points. Because health units are also 4 pixels tall,
I made a hack that allow the lifebar to show directly hit points. I suspect that Castlevania III and Super Castlevania IV have a similar system, where each health unit actually is internally divided in sub-units which are not shown to the player. At least for the bosses' lifebar.
I'll also mention Double Dragon games where there is obviously more health precision than shown to the player. This is especially poor design when it look like the health bar is empty but the character is still alive, this means they round the value down before displaying it. I think this is poor design, and I would agree to Sumez' guidelines when desiging games - even though my own game engine did not follow that philosophy but if I ever release the game I'll definitely change to stick to sumez's guidelines as much as possible.
So if I follow what you wrote then for a game like mega man, when you use the standard weapon, there is a good change that there is 2 values for health: the main health bar ($1C mentioned above) and some sub units, to calculate when to remove 1 unit of health.
If my memory is good, there is many bugs with health/weapon bar in mega man because of such units are lost when changing weapon (not sure if it effect the boss though).
I think this was specific in some versions of Mega Man 2. Other Mega Mans just remove a unit of "weapon power" (it is NOT health) whenever you use the weapon, allowing for at most 28 usages. Some weapons might even use more than 1 unit per attack. Only in Mega Man 2 there is a concept of using less than 1 unit, opening for bugs where you can just switch weapons frequently to have infinite ammo.
Oh yeah, weapon ammo is a different issue altogether, but I think it's actually a fairly frequent source of frustration to not know exactly how many shots you have left. That's insanely important against the boss of Wily-4 in MM2.