Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
Saphiresurf
Prole
Posts: 14
Joined: Thu Mar 16, 2017 1:53 am

Re: Simple Tiled Implementation - STI v0.18.1.0

Post 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.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.18.1.0

Post 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.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Simple Tiled Implementation - STI v0.18.1.0

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Saphiresurf
Prole
Posts: 14
Joined: Thu Mar 16, 2017 1:53 am

Re: Simple Tiled Implementation - STI v0.18.1.0

Post 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 ;-;.
Attachments
camerissues.PNG
camerissues.PNG (17.17 KiB) Viewed 8509 times
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.18.1.0

Post by Karai17 »

sti draws to a canvas... so it shouldn't do that...
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Saphiresurf
Prole
Posts: 14
Joined: Thu Mar 16, 2017 1:53 am

Re: Simple Tiled Implementation - STI v0.18.1.0

Post 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 ^_^.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.18.1.0

Post 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
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Saphiresurf
Prole
Posts: 14
Joined: Thu Mar 16, 2017 1:53 am

Re: Simple Tiled Implementation - STI v0.18.1.0

Post 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.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.18.1.0

Post by Karai17 »

You want to floor only when drawing, leaving the actual coordinates in tact.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Saphiresurf
Prole
Posts: 14
Joined: Thu Mar 16, 2017 1:53 am

Re: Simple Tiled Implementation - STI v0.18.1.0

Post 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!
Last edited by Saphiresurf on Wed Apr 12, 2017 11:51 pm, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest