Canvas HP bar with gradients! version 2

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

Canvas HP bar with gradients! version 2

Postby Hblade » Sun Dec 06, 2009 2:21 pm

Version 2:

Hello everyone, this is version 2 of my gradient HP bar :D
New features from version 1:
Color change,
a gray bar that represents your max hp that hides behind your current HP
CONTROLES: use the arrow keys to add / minus HP
(screenshot)
pic1x.png

pic2x.png

pic3x.png

Like the last version, no images are needed, so you dont have to worry about making tons of images for an hp bar :D
CONTROLES: Use the arrow keys to add / minus HP.
Gradient HP bars version 2.zip
(1.38 KiB) Downloaded 172 times

Here's the code for version 2:
Code: Select all
for (i2=0; i2<maxhp; i2++)
{
    setpen(69, 69, 69, 0, 3);
    moveto(i2, 0);
    lineto(i2, height-1);
    i2++;
}
for (i=0; i<hp; i++)
{
    for (gradl=0; hp>gradl; gradl++)
    {
    setpen(gradl, hp+gradl, 255, 0, 3);
    moveto(i, 0);
    lineto(i, height-1);
    i++;
    }
}

NOTE:
Your canvas can go all the way across the screen but it wont change the gray bar, You have to set the max hp and the normal hp in create actor. Look inside the GED file for more information :D

Old Version:
Hello, I made an H P bar that can be used for many games and it's not 1 solid color, it's a gradient and requires no images! It's all done by canvas.
Code: Select all
for (i=0; i<hp; i++)
{
    for (gradl=0; hp>gradl; gradl++)
    {
    setpen(gradl, hp, 255, 0, 3);
    moveto(i, 0);
    lineto(i, height-1);
    i++;
    }
}


Here's a few screenshots
p1.png

p2.png


Here's the GED file. Likewise, no data folder needed :)
Gradient HP bars.zip
(1.22 KiB) Downloaded 128 times


CONTROLES:
Use the left and right keys to make the hp bar bigger / smaller
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Canvas HP bar with gradients! version 2

Postby Scorpion50o1 » Sun Dec 06, 2009 8:04 pm

Nice I think i could really use this and it looks cool , but how do i keep from going to far? Does it go on and on and on? 8)
OMG IM SO BORED <(^^)> (>^^)> (>^^)>
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
User avatar
Scorpion50o1
 
Posts: 246
Joined: Fri Apr 17, 2009 1:07 am
Location: TX
Score: 8 Give a positive score

Re: Canvas HP bar with gradients! version 2

Postby Hblade » Sun Dec 06, 2009 8:07 pm

Version 2 fixes that. WHen your adding / subtracting the HP, instead of putting hp-=6 or something, you would put this:
Code: Select all
if (hp>0)
{
hp-=6;
}

And for adding HP via item or something you picked up,
Code: Select all
if (hp<maxhp)
{
hp+=50;
}

Where 50 is your item's recover rate or what ever :D

Then if you have like 45 / 50 HP, and you heal with 50 HP, to stop it from having 95 / 50 HP, make this code in the draw actor of your player
Code: Select all
if (hp>maxhp)
{
hp = maxhp;
}

The same with if you have 3 HP left, and someone does 40 damage, use this code:
Code: Select all
if (hp<0)
{
hp = 0;
}


But you wont even see it go pass 0 :D
Theres also more advanced methods I could explain if you want me to.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Canvas HP bar with gradients! version 2

Postby DST » Sun Dec 06, 2009 8:10 pm

Nice work, but since you have the erase being sent on the keydown (or player collision), why not send the draw then too? You can save a lot of cpu that way. Just remove canvas>draw actor alltogether.
It's easier to be clever than it is to be kind.
http://www.lostsynapse.com
http://www.dstgames.com
User avatar
DST
 
Posts: 1117
Joined: Sun Apr 15, 2007 5:36 pm
Location: 20 minutes into the future
Score: 151 Give a positive score

Re: Canvas HP bar with gradients! version 2

Postby Hblade » Sun Dec 06, 2009 8:12 pm

OH! LOL i put it in the wrong spot last time - Thanks DST
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Canvas HP bar with gradients! version 2

Postby makslane » Sun Dec 06, 2009 11:24 pm

Works great, congratulations.
Game Editor is an open source game creator software that's wants to pay it's developers to keep evolving.
If you like Game Editor, make a review!
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Re: Canvas HP bar with gradients! version 2

Postby Hblade » Sun Dec 06, 2009 11:28 pm

Thanks :D
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest