T
tomast
Guest
Hi everyone, I have a small issue with my what i am working with. I am making a game were you control a spaceship and that spaceship has a Lifebar bellow it.
The spaceship only goes up, and it has set a gravity that sends the ship back to the bottom when you are not pressing the up button.
The problem is that when the spaceship goes up the lifebar follows it perfectly with the correct distance between both objects. the problem is that when you stop pressing the up button the ship goes down a little bit faster than the lifebar so the distance between both is smaller (even the lifebar gets over the ship) until it reach de lowest point or you press the up button (where both ship and lifebar gets in the correct position).
In other words, there is a slight delay between the ship and the lifebar when the ship goes down because of the gravity.
My code is very simple
on the create event of the ship
on the step event on the ship:
What I want is to perfectly stick it as if it was the same object
Thanks in advance, any help would be greatly valued!
The spaceship only goes up, and it has set a gravity that sends the ship back to the bottom when you are not pressing the up button.
The problem is that when the spaceship goes up the lifebar follows it perfectly with the correct distance between both objects. the problem is that when you stop pressing the up button the ship goes down a little bit faster than the lifebar so the distance between both is smaller (even the lifebar gets over the ship) until it reach de lowest point or you press the up button (where both ship and lifebar gets in the correct position).
In other words, there is a slight delay between the ship and the lifebar when the ship goes down because of the gravity.
My code is very simple
on the create event of the ship
Code:
grv = 0.5;
Code:
up = keyboard_check(ord('W'));
oLifebar.x = -179 + self.x;
oLifebar.y = 70+self.y;
vsp = vsp + grv;
if (up){
vsp = -4;
}
//Vertical Collision
var emptyspace= 0;
if (place_meeting(x,y+vsp,Owall)){
emptyspace= false;
} else{
emptyspace= true
}
//movement
if (emptyspace== false)
{
vsp = 0
}
y = y + vsp;
Thanks in advance, any help would be greatly valued!