Jump to content

characters health span


cassius
 Share

Recommended Posts

In my game the main character has several encounters with enemy characters. The characters health count is decremented until the character dies. I need some method of showing a health progress bar or some other visible record of the health countdown. Has anyone done this.?What is a simple method of acheiving this?

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

A simple way would be to use DrawRect(). Draw 1 rect for the background (red normally), then draw another on top of the first one (green normally) to represent the health. The width of the red (first) rect can be any size you want. The width of the 2nd rect (green to represent health) is the % of health remaining from the total applied to the width.

 

So let's say your enemy has max health of 100 and you want a rect width of 200 pixels to represent that. If the actual health is now 50 (because you hit the enemey), then you find the % of health left (which is 50%) in this case. So now you take 50% of the 200 pixel width (which will be 100 pixels) and that's the new width of your green health bar that you draw on top of your red background healthbar.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...