cassius Posted November 8, 2012 Share Posted November 8, 2012 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? Quote 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 More sharing options...
Rick Posted November 9, 2012 Share Posted November 9, 2012 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. Quote Link to comment Share on other sites More sharing options...
cassius Posted November 9, 2012 Author Share Posted November 9, 2012 Great idea.Thanks. Quote 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 More sharing options...
Recommended Posts
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.