N
Noizee
Guest
Hey. I'm making a grid based movement game with infinite backgound (I'm doing this by moving the player once it gets to the limits I stablished).
Once it surpasses, say, 300px before the border of the room, this is what I wrote:
I turn "warping" to true every time the player is in a position in the grid where it is leaving the said parameters.
Everything normal until here.
After that wrote this in the step event of a parent object I called obj_ent (Which I'm using for every instance that isn't the player in the level so I can move every other instance with it).
What this does is calculating the difference in position between the object and the player, and then adding or subtracting that difference. If done right, that would make seem as if no movement happened whatsoever.
But I've been searching in ALL the coding for an hour and a half straight and I have no idea why nothing at all is happening!
No instances besides the player are moving!
By debugging, I saw that both variables are indeed working and switching from true to false for a whole step.
I've tried to put the code in the step events of the enemy instances but the code didn't work either.
I've used event_inherited when needed, and tried with the begin step and end step events, but nothing worked.
I assumed I missunderstood the usage of "id" or "self" (which I was using), but tried everything (even storing the id in a variable and then using it) and nothing happened.
The only way I get the instances to move was by doing it in a keyboard event.
Can someone help me with this?
Thank you in advance.
Once it surpasses, say, 300px before the border of the room, this is what I wrote:
Code:
if (warping=true) && (global.warp_all=false)
{
warping=false;
global.warp_all=true;
}
Everything normal until here.
After that wrote this in the step event of a parent object I called obj_ent (Which I'm using for every instance that isn't the player in the level so I can move every other instance with it).
Code:
if (global.warp_all=true)
{
if (instance_exists(obj_player))
{
if (id.x > obj_player.x)
{
id.x = (obj_player.x + (id.x - obj_player.x))
}
if (id.x < obj_player.x)
{
id.x = (obj_player.x - (obj_player.x - id.x))
}
if (id.y > obj_player.y)
{
id.y = (obj_player.y + (id.y - obj_player.y))
}
if (id.y < obj_player.y)
{
id.y = (obj_player.y - (obj_player.y - id.y))
}
}
global.warp_all=false
}
What this does is calculating the difference in position between the object and the player, and then adding or subtracting that difference. If done right, that would make seem as if no movement happened whatsoever.
But I've been searching in ALL the coding for an hour and a half straight and I have no idea why nothing at all is happening!
No instances besides the player are moving!
By debugging, I saw that both variables are indeed working and switching from true to false for a whole step.
I've tried to put the code in the step events of the enemy instances but the code didn't work either.
I've used event_inherited when needed, and tried with the begin step and end step events, but nothing worked.
I assumed I missunderstood the usage of "id" or "self" (which I was using), but tried everything (even storing the id in a variable and then using it) and nothing happened.
The only way I get the instances to move was by doing it in a keyboard event.
Can someone help me with this?
Thank you in advance.