Slow movement in low resolution games

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
wilco
Prole
Posts: 11
Joined: Sun Jun 21, 2020 8:51 am

Slow movement in low resolution games

Post 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).
wilco
Prole
Posts: 11
Joined: Sun Jun 21, 2020 8:51 am

Re: Slow movement in low resolution games

Post 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
}
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Slow movement in low resolution games

Post 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.)
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
User avatar
milon
Party member
Posts: 472
Joined: Thu Jan 18, 2018 9:14 pm

Re: Slow movement in low resolution games

Post 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.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
Post Reply

Who is online

Users browsing this forum: No registered users and 222 guests