Draw Health Bar
Started by adam_jam man, Mar 01 2007 01:29 PM
7 replies to this topic
#1
Posted 01 March 2007 - 01:29 PM
how do you draw a health bar on top of an enemy and moving with the enemy and also make it separate. example: there is enemy 1 and enemy 2. enemy1 is the same object as enemy 2. but if i shoot enemy1 the health will decrease but enemy 2 will not decrease it would stay the same ok comprende
he he he......
#2
Posted 01 March 2007 - 01:51 PM
Righty ho.
To seperate their health (let's call it "hp") variables, just never change the value of "obj_enemy.hp" This applies to all obj_enemy's.
Instead, reference "hp" from the instance (e.g. on collision with bullet) or "other.hp" from another instance that has collided with it (e.g. on bullet collision with obj_enemy)
Now, to draw the healthbar:
2 options:
1) From the obj_enemy's draw event:
2) From a controller's draw event:
That do it for you?
To seperate their health (let's call it "hp") variables, just never change the value of "obj_enemy.hp" This applies to all obj_enemy's.
Instead, reference "hp" from the instance (e.g. on collision with bullet) or "other.hp" from another instance that has collided with it (e.g. on bullet collision with obj_enemy)
Now, to draw the healthbar:
2 options:
1) From the obj_enemy's draw event:
draw_healthbar(x-20,y-30,x+20,y-25,hp,c_black,c_red,c_green,1,0,0)
2) From a controller's draw event:
with obj_enemy
{
draw_healthbar(x-20,y-30,x+20,y-25,hp,c_black,c_red,c_green,1,0,0)
}That do it for you?
Edited by purple_pixie, 01 March 2007 - 01:52 PM.
#3
Posted 01 March 2007 - 02:04 PM
so i just change the selfhealth to hp?
#4
Posted 01 March 2007 - 02:29 PM
Or the hp to selfhealth - doesn't matter
#5
Posted 11 January 2011 - 06:55 PM
i used this code draw_healthbar(x-20,y-30,x+20,y-25,HP,c_black,
c_red,c_green,1,0,0) that you gave him but my enemy seems to disapeer what could i possible have done wrong
c_red,c_green,1,0,0) that you gave him but my enemy seems to disapeer what could i possible have done wrong
#6
Posted 11 January 2011 - 07:31 PM
using the draw event cancels the built-in draw event.
You have to tell the game to draw the sprite, using draw_sprite.
You have to tell the game to draw the sprite, using draw_sprite.
#7
Posted 03 July 2011 - 09:12 PM
Remember, you could also make a seperate draw event, call it object draw. Then set on the player a global.life, then go to the draw step event
x = obj_player.x
y = obj_player.y
And put the code for the drawings in the draw event.
Good luck =)
x = obj_player.x
y = obj_player.y
And put the code for the drawings in the draw event.
Good luck =)
#8
Posted 03 July 2011 - 10:06 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











