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.

Dark GDK / Health Bar

Author
Message
Jna99
19
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 29th Sep 2006 03:37
I people I decided to get try something different, so I decided to make a FPS, problem is the health bar...My Idea was to make a Plain and texturized it, so that when I was hurt I'ld simply resize the object, problem is...that when I resize the XX of the object both side are shortened...I've allready tried with sprites but the result is the same...
Lich120
18
Years of Service
User Offline
Joined: 19th Mar 2006
Location:
Posted: 29th Sep 2006 06:44
Well first off, I would recommend using a sprite for the health bar. But as for resizing, using the dbStrechSprite command could be used to resize. Everytime you game refresh (aka. a game update) you need to refresh the whole screen, and all of the HUD for that matter, so just reposition the sprite at the correct position. It wouldnt matter if its resizing around the center as when you redraw the sprite to the screen it will put at the proper position.

Something in the realm of:

//Player takes damage
dbStretchSprite(1, 80, 100); //Resize the sprit to 4/5 the original

//Update the HUD
dbPasteSprite(1, HEALTH_BAR_X, HEALTH_BAR_Y);
Jna99
19
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 29th Sep 2006 14:32
Problem is that the bar position it self wrongly!! see

Lich120
18
Years of Service
User Offline
Joined: 19th Mar 2006
Location:
Posted: 29th Sep 2006 18:40
Im not sure why your using the variable tmp in your dbPasteImage() command. The size of the image should be irrelivant to the X and Y you use to paste it. The reason its not pasting at the same spot for you is because your paste command is dependant on a variable that is chaning (ie. tmp). What you should be using to paste the image is a constant value x, and a constant value y.

int HealthBarX = dbScreenWidth()-330;
int HealthBarY = dbScreenHeight()-151;
float tmp = 100;

while(!dbEscapeKey()) {
if(dbLeftKey()==1 && tmp>0)
{
tmp-=10;
dbStretchSprite(2,tmp,100);
dbPasteSprite(2, HealthBarX, HealthBarY);
}
}
Jna99
19
Years of Service
User Offline
Joined: 3rd Nov 2005
Location: Portugal
Posted: 30th Sep 2006 01:14
Lich120 thks my problem was that I had resized the sprite, and I forgot to count on that when I position!

Login to post a reply

Server time is: 2024-11-19 08:46:12
Your offset time is: 2024-11-19 08:46:12