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)
How it looks (space between wood planks is weird)
Does anyone know why this happens? The relevant files are game/objects/World.lua and game/objects/Map.lua
[SOLVED] Camera movement and tilemap issues
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 548
- Joined: Wed Oct 05, 2016 11:53 am
Re: Camera movement and tilemap issues
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:
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:
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.
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);
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.
Re: Camera movement and tilemap issues
Thanks, I'll have a look at it
Edit: Solved
Edit: Solved
Who is online
Users browsing this forum: Google [Bot] and 4 guests