W
William Kater
Guest
Hello everyone,
real quick before anything else: i'm sorry for my bad grammar.
in my game (in gamemaker 8 lite) i have an object wich can be broken by left pressing on it. i have an healthbar wich will be shown when the object is hit. after 4 seconds the healthbar will be removed (intended). the problem is that even tough i reset the value of the variable, the health-bar won't come back when you click on the object again. Here's my code:
oCollision:
create event:
hp=4;
maxhp=4
breakable=1
hppercent=100
healreset_time=30*20
stopshowing=30*4
step step event:
hppercent=(hp/maxhp)*100
if (hp<1){
instance_destroy()
}
if (hp<maxhp){
healreset_time-=1
//when you are not showing, stop counting down
if stopshowing>0 {stopshowing-=1}
}
if (healreset_time<1){
healreset_time = 30*20
hp+=1
}
left pressed event:
stop_showing=30*4
if breakable = 1 and hp > 0 and distance_to_object(oPlayer)<96
{
hp -= 1
}
if distance_to_object(oPlayer)>96 {
draw_text(view_xview[],view_yview[],"Not close enough!")
}
//set the time to wait until you stop showing
healtime_time=30*20
draw event:
draw_self()
if (hp<maxhp and stopshowing>0){
draw_roundrect(bbox_left+3,bbox_bottom+4,bbox_right-3,bbox_bottom+10,true)
draw_healthbar(bbox_left+4,bbox_bottom+5,bbox_right-4,bbox_bottom+9,hppercent,c_black,c_red,c_green,0,false,0)
}
even tough i reset the stopshowing var, the health-bar won't come back. What did i do wrong?
real quick before anything else: i'm sorry for my bad grammar.
in my game (in gamemaker 8 lite) i have an object wich can be broken by left pressing on it. i have an healthbar wich will be shown when the object is hit. after 4 seconds the healthbar will be removed (intended). the problem is that even tough i reset the value of the variable, the health-bar won't come back when you click on the object again. Here's my code:
oCollision:
create event:
hp=4;
maxhp=4
breakable=1
hppercent=100
healreset_time=30*20
stopshowing=30*4
step step event:
hppercent=(hp/maxhp)*100
if (hp<1){
instance_destroy()
}
if (hp<maxhp){
healreset_time-=1
//when you are not showing, stop counting down
if stopshowing>0 {stopshowing-=1}
}
if (healreset_time<1){
healreset_time = 30*20
hp+=1
}
left pressed event:
stop_showing=30*4
if breakable = 1 and hp > 0 and distance_to_object(oPlayer)<96
{
hp -= 1
}
if distance_to_object(oPlayer)>96 {
draw_text(view_xview[],view_yview[],"Not close enough!")
}
//set the time to wait until you stop showing
healtime_time=30*20
draw event:
draw_self()
if (hp<maxhp and stopshowing>0){
draw_roundrect(bbox_left+3,bbox_bottom+4,bbox_right-3,bbox_bottom+10,true)
draw_healthbar(bbox_left+4,bbox_bottom+5,bbox_right-4,bbox_bottom+9,hppercent,c_black,c_red,c_green,0,false,0)
}
even tough i reset the stopshowing var, the health-bar won't come back. What did i do wrong?