Page 69 of 92

Re: Simple Tiled Implementation - STI v0.18.1.0

Posted: Fri Apr 07, 2017 11:01 am
by Saphiresurf
Thank you so much for creating something like STI, the implementation has worked almost perfectly for me and it's created a really flexible solution for mapping in the sort of game/engine that I'm working on right now ^_^.

I am having one issue though which may not be in the scope of this thread, but I'm just curious if you know much about it. Essentially when I'm using gamera and have it zoomed in there will be weird artifacts on the screen where background tiles will misalign and there will be white space between images sort of like a seam although they work perfectly fine without zoom. I set it so that all images are scaled by nearest neighbor by default and since then the misalignment only happens at the start when I'm not moving my character, then goes away once moving, but then will randomly flash back up as I continue to move around. Just curious if you might know anything about this.. I understand if it's out of the scope of this thread though!

I've already googled around a bit and it seems like a semi-common issue, but other people's solutions that were posted I found it either didn't work, resulted in juttery movement, or I just didn't quite understand (although maybe that's the case for all of them heh). One of the solutions I was trying was math.floor()ing the cameras coordinates... which in this case updates every frame and my player doesn't give a poop about integers thus transcending into the world of decimal/float coordinates, but still causing war on integer ground and anger from the rounded integer camera coordinates (as in causes sort of a jutted character movement) so it didn't quite work out heh.

EDIT: Gamera also has a set of rules to stop this from happening, too: https://github.com/kikito/gamera in the FAQ, but I think I'd need to change how Tiled works with images potentially (although I believe it does work with quads, not sure about the rest). I'm also just not really sure how much these rules apply to Tiled or if they're implemented already heh. Also something good to know, too, is that I do have the same issues with hump.camera as well. Hope this gives a bit of a better idea of the issue. I can always get a screenshot if needed.

Re: Simple Tiled Implementation - STI v0.18.1.0

Posted: Fri Apr 07, 2017 1:56 pm
by Karai17
I generally recommend not using a camera library, they don't provide much. Try using love.graphics.scale and love.graphics.translate directly.

Re: Simple Tiled Implementation - STI v0.18.1.0

Posted: Fri Apr 07, 2017 2:11 pm
by zorg
Karai17 wrote: Fri Apr 07, 2017 1:56 pm I generally recommend not using a camera library, they don't provide much. Try using love.graphics.scale and love.graphics.translate directly.
I'd disagree on the premise that it's a sweeping generalization, camera libs may provide a lot of things (e.g. single or multiple object tracking, etc.), it always depends on the lib itself; though i haven't used STI/Tiled before with any project of mine, so they indeed may not be the best choice to use with STI.

Re: Simple Tiled Implementation - STI v0.18.1.0

Posted: Sun Apr 09, 2017 12:26 am
by Saphiresurf
Seems like the same issue happens even when using love.graphics.scale and love.graphics.translate. Here's a screenshot of the issue! I'll go into gamera or humps thread because it may just be something up with the camera. There's some weird stuff that goes on between LOVE, C++, and OpenGL when it comes to number rounding that supposedly causes these issues... just trying to find out how to solve them ;-;.

Re: Simple Tiled Implementation - STI v0.18.1.0

Posted: Sun Apr 09, 2017 12:36 am
by Karai17
sti draws to a canvas... so it shouldn't do that...

Re: Simple Tiled Implementation - STI v0.18.1.0

Posted: Tue Apr 11, 2017 3:16 am
by Saphiresurf
Yeah I'm not sure what's up with it.... I made a post on the thread for gamera to see if anyone had any ideas as to what's going on with it possibly, but I just haven't got a reply yet. I'll go look through my code a bit more or research around a bit more to see if I can find anyway to fix this though. I'll update if I find out the issue or how to solve it ^_^.

Re: Simple Tiled Implementation - STI v0.18.1.0

Posted: Tue Apr 11, 2017 3:38 am
by Karai17
You could try copying map:draw so that it does everything except draws the internal canvas, then you can take that canvas and draw it after you use gamera's transforms

Re: Simple Tiled Implementation - STI v0.18.1.0

Posted: Wed Apr 12, 2017 5:54 pm
by Saphiresurf
I ended up trying just to pass the camera into map:draw and doing the scaling in there... but it still didn't quite work. Not sure if maybe I'm just doing something wrong here? I'm pretty sure it has to do with non-integer coordinates, but I'm not sure how to use math.floor without making movement juttery. I posted my code up here to see if you might find anything I'm doing weird: https://github.com/Saphiresurf/sidescroller.

One thing to note, too, is that I tried math.flooring just my players coordinates in player.lua under the Player:move(dt) function, but it results in me only being able to move left... so that doesn't quite work out as well. Maybe I just need to revise how I'm doing player movement so I can more safely round players coordinates to integers... I'm not sure.

Re: Simple Tiled Implementation - STI v0.18.1.0

Posted: Wed Apr 12, 2017 6:01 pm
by Karai17
You want to floor only when drawing, leaving the actual coordinates in tact.

Re: Simple Tiled Implementation - STI v0.18.1.0

Posted: Wed Apr 12, 2017 11:24 pm
by Saphiresurf
Problem is that when I do that to the coordinates like I do in the code below:

Code: Select all

-- playercam is just an instance of Gamera, level is my map loaded with STI
function World:update(dt)

    -- Update every layer in the map level
    self.level:update(dt)
    self.playercam:setPosition(math.floor(self.level.layers.entities.player.x), math.floor(self.level.layers.entities.player.y))

end
the camera movement ends up being /super/ juttery at least in relation to the player (the player looks like they're vibrating on whatever axis their moving in). I think that's because the player is still moving in accordance to non-integer/integer values while the camera is only locking to integer values. Perhaps I'm doing something else wrong here, though, I'm not quite sure.


EDIT: Okay so it looks like this is a pretty common issue just because it has to do with how texture filtering tends to operate. The way that these issues can be solved is just to make a 1 pixel padding around the image with the same color as the pixel it's padding (as shown in this image: https://love2d.org/imgmirrur/WNb98pT.png). Not quite sure how this is going to play in with STI and Tiled, but I want to see if maybe there's a way of doing this in code so my assets don't look wonky or so that it doesn't messed up the way Tiled is working. If you have any suggestions I'd definitely love to listen!