• 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!

[SOLVED] Slowing down 1 pixel at a time movement w/o fractions

Bentley

Member
I was working with Lemmings and trying to get the movement right. If you let the step event run with x++, they move too fast.

I usually do something like this:
Code:
// o_control begin step event
global.frame++;

// o_lemming step event
if (global.frame mod 3 == 0)
{
    x++;     
}
I was wondering how others go about this. I didn't want to lower the FPS because that messes up other things that I want to run at 60 FPS. I didn't want to move at fractions, although I suppose I could. Anyway, just curious. Thanks for reading.
 
Last edited:

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Like so:
Code:
// Create
acc = 0;

// Step:
acc += 1/3;
var amt = floor(acc);
if (amt > 0) {
    x += amt; // or more complex logic
    acc -= amt;
}
 
Top