Page 1 of 1

Slow movement in low resolution games

Posted: Wed Jul 15, 2020 9:26 am
by wilco
How would you guys do slow movement in low resolution games (like for example NES games)?
For example move the player for 0.5 pixels at a time.

I tried just rounding the position inside draw(), but results where jerky (which is kinda logical).

I'm now thinking of implementing a system where I just skip frames entirely.
For example 0.5 pixels movement per frame on 60 fps, is the same as 1 pixel movement on 30fps.
I know this has some limitations to what speeds I could use, but I think 0.25px, 0.5px, 1px and 1px+ should be enough for my use case.

Might be good to know I choose to ignore deltaTime and I'm using a "fixed time step with an accumulator" to keep the game running at 60fps (sort of).

Re: Slow movement in low resolution games

Posted: Wed Jul 15, 2020 11:53 am
by wilco
Ok seems I figured it out... all though I don't completely understand it yet...

Rounding the x and y in draw() DOES work, but x needs to be rounded up while y needs to be rounded down... ¯\_(ツ)_/¯

Code: Select all

public draw(): void {
    const x = math.ceil(this.x);
    const y = math.floor(this.y);
    this.animation.draw(x, y); // this is my own animation class that draws a simple sprite based animation at x, y
}

Re: Slow movement in low resolution games

Posted: Wed Jul 15, 2020 7:55 pm
by ReFreezed
Some people may disagree, but I'd say just use subpixels (i.e. either round coords to subpixels or possibly don't round the coords at all). There is a trade-off that has to be made between nice smooth movement and "true pixel-perfect low resolution retro pixel-art" visuals.

You can also mix rounding and not rounding depending on what is being rendered. For example, don't round characters, but do round certain effects if they happen to look better that way.

(By the way, using a fixed time step like you've chosen is generally a good idea, at least when it comes to logical movement and physics.)

Re: Slow movement in low resolution games

Posted: Fri Jul 17, 2020 1:24 pm
by milon
The floor/ceiling thing may be related to the rounding issue I encountered previously: https://love2d.org/forums/viewtopic.php?f=4&t=88933

Try not rounding at all, as ReFreezed suggested. Unless you're using love.graphics.points, in which case see the thread I linked for the solution.