Simple Tiled Implementation - STI v1.2.3.0

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
zugende
Prole
Posts: 12
Joined: Sun Feb 21, 2016 5:47 pm

Re: Simple Tiled Implementation - STI v0.14.1.12

Post by zugende »

Karai17 wrote:Looks like you mostly have it. I think the batch id should be in the tile instance, so that will tell you exactly which part of the batch you need to update.
Still not working, but I dont give up. :D

ok, this is what I got so far:

1) mouse click
2) tile-x and tile-y is calculated -> then I look up the GID

Code: Select all

mouse.clickedTile = map.layers[1].data[tiley][tilex].gid
3) then I loop through all the instances within the GID to check which x+y coordinate(calculated like tile-x/tile-y var) matches the tile-x and tile.y coordinate

Code: Select all

for i, instance in ipairs(map.tileInstances[mouse.clickedTile]) do
   if instance.x/24+1 == tilex and instance.y/24+1 == tiley then
      print("GID:",instance.gid,"ID:",instance.id,"i:",i)
      mouse.instanceNr = i
   end
end
      
Works perfectly!

4) Now my plan is to change the quad with this function:
batch_setq.JPG
batch_setq.JPG (27.47 KiB) Viewed 4291 times
.. but it dont works.. why? :cry:

Code: Select all

attempt to call method 'setq' (a nil value)
Hope you can help me again.
Thanks so much!
zugende
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Simple Tiled Implementation - STI v0.14.1.12

Post by s-ol »

setq doesn't work because it doesn't exist, which is what the error is telling you: setq is a nil value (= nothing). Look at the wiki screenshot you posted, on the right it says that :setq was removed in version 0.9.0. if you look at the wiki page of :setq it also tells you that "It has been merged into SpriteBatch:set".

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
zugende
Prole
Posts: 12
Joined: Sun Feb 21, 2016 5:47 pm

Re: Simple Tiled Implementation - STI v0.14.1.12

Post by zugende »

Just want to say thanks to Karai17 and s-ol for their help! :)
The

Code: Select all

SpriteBatch:set
function was the solution.
spritebatch_edit.gif
spritebatch_edit.gif (453.06 KiB) Viewed 4232 times
Best
zugende
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.14.1.12

Post by Karai17 »

Cool!
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
User avatar
Temeez
Prole
Posts: 2
Joined: Sun Apr 17, 2016 11:28 am

Re: Simple Tiled Implementation - STI v0.14.1.12

Post by Temeez »

Hey, any chance you could update your tutorial at http://lua.space/gamedev/using-tiled-maps-in-love as it doesn't seem to work with the newest Löve version (0.10.1)? The layer.update and layer.draw functions in the love.load() seem to do nothing, so the end result of that tutorial is a invisible player which doesn't move.

Edit: Interestingly I got it working with the following changes, but I have no idea if there is a better way to do it..

Code: Select all

layer.draw = function(self)
changed to

Code: Select all

function layer:draw()
and then in the love.draw(), after map:draw() I put layer:draw()
The layer of course needs to be global. Similar thing with the layer.update.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Simple Tiled Implementation - STI v0.14.1.12

Post by zorg »

Temeez wrote:Edit: Interestingly I got it working with the following changes, but I have no idea if there is a better way to do it..

Code: Select all

layer.draw = function(self)
changed to

Code: Select all

function layer:draw()
Those two should be equivalent code, since it's nothing Löve specific, rather lua specific, and the used lua version didn't change, so, weird that that would solve any issues :v
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.
User avatar
Temeez
Prole
Posts: 2
Joined: Sun Apr 17, 2016 11:28 am

Re: Simple Tiled Implementation - STI v0.14.1.12

Post by Temeez »

zorg wrote:
Temeez wrote:Edit: Interestingly I got it working with the following changes, but I have no idea if there is a better way to do it..

Code: Select all

layer.draw = function(self)
changed to

Code: Select all

function layer:draw()
Those two should be equivalent code, since it's nothing Löve specific, rather lua specific, and the used lua version didn't change, so, weird that that would solve any issues :v
Looks like even the first one works, if I just put

Code: Select all

layer.draw(layer)
in the love.draw() function.
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.14.1.13

Post by Karai17 »

I've upgraded STI to a new version. Not a huge upgrade, just added some tests and fixes mostly. I plan to spend time soonish updating to Tiled 0.16.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
amcoolio
Prole
Posts: 7
Joined: Fri May 27, 2016 1:15 am

Re: Simple Tiled Implementation - STI v0.14.1.13

Post by amcoolio »

I have that glitch where when the player moves, it looks like my individual map tiles are breaking at the seems similar to the OP in viewtopic.php?t=82141 . However I can't figure it out like they did. Does it have to do with the player movement code? Sorry, new to programming
User avatar
Karai17
Party member
Posts: 930
Joined: Sun Sep 02, 2012 10:46 pm

Re: Simple Tiled Implementation - STI v0.14.1.13

Post by Karai17 »

You need to use math.floor to make sure you are translating and drawing to an internet value.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+

Dev Blog | GitHub | excessive ❤ moé
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest