Healthbar won't decrease

You must understand the Game Editor concepts, before post here.

Healthbar won't decrease

Postby raminkhan » Mon Apr 30, 2012 6:52 am

Hi I have a healthbar with this code below but how can I have it decrease the bar which is in animpos of 8.

here's my code:

hp_timer++; //this is my timer which makes the health bar increase in 30 seconds.
if(hp_timer>30 && hp<max_hp)
{
hp++; // this is what increases my health bar
hp_timer=0;
}

animpos=8;
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: Healthbar won't decrease

Postby phyzix5761 » Mon Apr 30, 2012 8:17 am

Not quite sure what you are asking for but you could write a similar code which includes the line

animpos-=1;
phyzix5761
 
Posts: 261
Joined: Sun Feb 27, 2011 4:28 am
Score: 18 Give a positive score

Re: Healthbar won't decrease

Postby skydereign » Mon Apr 30, 2012 3:54 pm

You are using a variable, to store hp right? Then you need to set animpos equal to the variable. Currently you are just setting animpos equal to 8 at the end of that script (which means the bar won't look like it changes).
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Healthbar won't decrease

Postby savvy » Wed May 23, 2012 11:08 am

Code: Select all
hp_timer++; //this is my timer which makes the health bar increase in 30 seconds.
if(hp_timer>30 && hp<max_hp)
{
hp++; // this is what increases my health bar
hp_timer=0;
}
animpos=hp;


savvy

EDIT: I just realised, ++ and 30 wont make 30 seconds either, it will be increasing once a second, 30fps means the hp_timer will increase 30times per second.
For 30 seconds it needs to be hptimer>300.
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron