• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Floor repeat in game maker?

Z

zenoboy

Guest
I have this floor object in game maker and hspeed is -8 & room speed is at 30.
Room size is 1366x1024.

The sprite width used for the floor is 1645px (235px*7times). Sprite origin for X is at 0.
So that means in theory, when the floor reaches -235px I should set it to 0 to give it an illusion that it runs forever.

This is my code for the floor object:
Code:
if (x < -235) {
    x = 0;
}
It runs repeatedly but it seems that it gets 1-2px extra movement to the right side.
I've tried changing 'x' and also the condition above but it either ends up making it worse.
It moves to the left side instead sometimes when I changed this code.

I'm probably missing something like maybe changing the room speed?
How do I fix my problem?
 

Yambam

Member
The floor should already move to the right when x is equal to -235 (so use <= instead of <). And since 235 / 8 is not a round number, try simply adding 235 instead of setting x to 0:
Code:
if (x <= -235) {
    x += 235;
}
 
Top