beardedtoolcrafter
Member
I'm trying to have my health bar deplete after characters collide. I have standard health bar code but it won't mix well with a Collisions of instances. How do I ?
if !place_meeting (x, y, Guy) {
var damage= 1;
var current_hp= max_hp -damage;
var max_hp=10;
draw_healthbar(x + 0, y + 20, x + 250, y + 30, current_hp, $FF00FF00 & $FFFFFF, $FF0000FF & $FFFFFF, $FF00FF00 & $FFFFFF, 0, (($FF00FF00>>24) != 0), (($FF000000>>24) != 0));
// Declare Temp
//var temp = 10; //Totally useless, makes 0,0% sense whatsoever
//var temp = current_hp //Useless, just continue to use current_hp in whatever code follows IN THIS BLOCK. If no code follows IN THIS BLOCK, delete the line
}
It should be printing 9 HP every time, because that's the value you give it. They're only technically variables if they always have the same value. We call those "constants". If you want the variables to change, you have to put different values into them at least once. Ever. Perhaps when you detect a collision and then set an alarm that explicitly does nothing.var current_hp=10
var damage= 1;
var max_hp=10;
var current_hp= max_hp -damage;
Did you fix your code according to the comments from @Nidoking and @Slow Fingers ?Anything I'm adding isn't working to the result of collisions=losing hp .... any ideas there.
direction
of your chasing instance to point_direction(x, y, obj_player.x, obj_player.y)
(if you only have one instance of obj_player to chase, others you need to figure out which instance to chase before you can pick its x and y coordinates).other_instance.variable
or the with() {...}
block in GMLSetup / Room editingHey, I’m only trying this software for fun. So I am as far here as now trying to save x,y positions when leaving a room from where I entered the prior room. Much like the modern games have. I can give you an example enter a door to a house in a game, when you exit that house your location is next to it. Cant’t do this yet. Can anyone help me out. The current code is set up as a room_goto event started by a colliison with an object. GML is a likely solution to the problem yet would rather use Drag and Drop if you can.
In room editor store a numerical id for each door in the room and a numerical id for the door it represents in the other room (so bidirectional identification) using variable definitions
Store the numerical id of the door you want to emerge at somewhere (global variable or a player instance variable) using the destination id for the door you are entering through
Apply To block for door object
If Block comparing door id with desired door id
Set Instance Variable X coordinate for player object to x
Set Instance Variable Y coordinate for player object to y
Break block
object.x
and there is more then one object, then it will get the x from the first instance created..if(place_meeting(x,y,object)) health-=1;
with(instance_place(x,y,enemy)) health-=1;
var ins = instance_place(x,y,object);
if(ins != noone) health-=1;
health-=1;