Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / 2D Fighting Game

Author
Message
Riz
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location:
Posted: 10th Feb 2009 04:44
Hey how are you guys I am currently working on a 2D fighting game, my question is how exactly would i go about making the life bars for the two characters that the players will control and how would i have them decrease when one character hits another? i appreciate any help and or advice you can give me
Van B
Moderator
21
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Feb 2009 08:48
Perhaps the easiest method and the method that would need the least maintenance is sprites. You could sprite 2 life bar backgrounds onto the screen, then the bars themselves would be sprites too, but positioned and sized to suit how much health is left.

One thing I like about this method is that you only need to update it when a character is hit, the other 99% of the time it's just being drawn automatically. For instance you might make a function to update the bars, just one for this example. Lets assume that your overall health bar length is 256, height is 16, and your health bar backdrop has a 32 pixel wide margin.

So to draw the sprites:
sprite 1,1,0,0
sprite 2,2,32,32

So thats sprite number, image number, X and Y

And to size sprite 2 to suit a health value, 0 to 100:
size sprite 2,health#*2.55,16

This will support alpha transparency, so no problem with using neat drop shadows or even making the health bar translucent.


Health, Ammo, and bacon and eggs!

Login to post a reply

Server time is: 2024-04-25 11:55:20
Your offset time is: 2024-04-25 11:55:20