[SOLVED] Camera movement and tilemap issues

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
Skere
Prole
Posts: 6
Joined: Fri Nov 25, 2016 8:21 pm

[SOLVED] Camera movement and tilemap issues

Post by Skere »

First of all, the player/camera movement looks a bit rough at times in my game. I can't find the reason why. I already tried changing the player's step size/speed, but it doesn't seem to be the issue. My guess is that there's something wrong with the camera. I can probably fix this one myself with some more time.

More importantly, my tilemap looks a bit off. It's especially notable when it's downscaled, since it almost looks correct on fullscreen. Some lines between wood planks are a lot thicker than others.

How it should look (space between wood planks is constant)
Image

How it looks (space between wood planks is weird)
Image

Does anyone know why this happens? The relevant files are game/objects/World.lua and game/objects/Map.lua
Attachments
atos.love
(197.99 KiB) Downloaded 186 times
Last edited by Skere on Mon Jun 19, 2017 4:37 pm, edited 1 time in total.
MrFariator
Party member
Posts: 559
Joined: Wed Oct 05, 2016 11:53 am

Re: Camera movement and tilemap issues

Post by MrFariator »

The problem you're experiencing has to do with scaling: you're scaling the map and character sprites at uneven pixel sizes, resulting in artefacting and fat lines of pixels as demonstrated by your screenshot. Here are the relevant lines of code:

Code: Select all

-- line 35 in World.lua
local scale = width() * 0.06 / game.maps.metadata.tileSize;

Code: Select all

-- line 58 in Map.lua
engine.graphics.draw(self.spriteBatch, 0, 0, 0, 0.8, 0.8);
The first may very well result in uneven pixel sizes due to computer math being what it is, while the other outright scales the size of the spritebatch by 20%. If you change scale and sx/sy factors of those lines to 1 you get the following result:

Image

Unless you're dealing with higher resolution assets, the rule of thumb for pixel art is to only render things at 1x, 2x, 3x or so forth, or implement a way to "blur" your pixels in order to create a virtual resolution, much like how Shovel Knight did it.
Skere
Prole
Posts: 6
Joined: Fri Nov 25, 2016 8:21 pm

Re: Camera movement and tilemap issues

Post by Skere »

Thanks, I'll have a look at it

Edit: Solved
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 3 guests