Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v0.14.1.8
Hi
I seem to have hit an issue with your lib.
For isometric Staggered map, it is only displaying 21, 21 tiles.
I am attaching the map i used.
my code is here
https://github.com/rishavs/RoguishLove/
and the file where all the map stuff happens is src/_state_Game.lua
I seem to have hit an issue with your lib.
For isometric Staggered map, it is only displaying 21, 21 tiles.
I am attaching the map i used.
my code is here
https://github.com/rishavs/RoguishLove/
and the file where all the map stuff happens is src/_state_Game.lua
- Attachments
-
- testMap.lua
- (2.42 KiB) Downloaded 139 times
- giantofbabil
- Prole
- Posts: 32
- Joined: Tue Dec 15, 2015 6:07 pm
Re: Simple Tiled Implementation - STI v0.14.1.8
First off I love STI, you have made my life a hell of a lot easier, thank you!
Is there a way to get the edges of the map? I'd like to be able to restrict both camera and character movement to the map edges but don't know where to get the coordinates. I'm also a little unsure how I would program restricting the camera, my code for it is pretty much the same as the STI Demo:
Is there a way to get the edges of the map? I'd like to be able to restrict both camera and character movement to the map edges but don't know where to get the coordinates. I'm also a little unsure how I would program restricting the camera, my code for it is pretty much the same as the STI Demo:
Code: Select all
function drawLevel_01()
--CAMERA CODE---------------------------------------------------------------------------------------------------
--translation based on player's x/y
local sprite = map.layers['Sprite Layer'].sprites.player
local ww = love.graphics.getWidth()
local wh = love.graphics.getHeight()
tx = math.floor(-sprite.x + ww / 2 - 16)
ty = math.floor(-sprite.y + wh / 2 + 100)
-- Draw sprite in centre of screen
love.graphics.push()
love.graphics.translate(tx, ty)
map:setDrawRange(-tx, -ty, ww, wh)
--draw map and all objects within
map:draw()
--draw collision map (useful for debugging) comment out to get rid of collision boxes
love.graphics.setColor(255, 0, 0, 255)
love.graphics.polygon("line", sprite.body:getWorldPoints(sprite.shape:getPoints()))
love.graphics.polygon("line", sprite.body:getWorldPoints(sprite.gShape:getPoints()))
love.graphics.polygon("line", sprite.body:getWorldPoints(sprite.lwShape:getPoints()))
love.graphics.polygon("line", sprite.body:getWorldPoints(sprite.rwShape:getPoints()))
love.graphics.circle("line",sprite.x, sprite.y + 20, 38)
map:box2d_draw()
love.graphics.pop()
end
Code: Select all
if enemy == lowerClassSaiyan and powerLevel > 9000 then
love.graphics.print("What?! 9000?! There's no way that could be right!", 10, 200)
else
love.graphics.print("You fool!", 10, 200)
end
- giantofbabil
- Prole
- Posts: 32
- Joined: Tue Dec 15, 2015 6:07 pm
Re: Simple Tiled Implementation - STI v0.14.1.8
Haven't been able to test it with the top and right side of the map yet but I got it the camera to limit by putting this in the code in before love.graphics.push()
Where -7680 and -4352 are the negatives of the size of my map from Tiled in pixels
Code: Select all
if tx > 0 then tx = 0 end
if tx < -7680 + love.graphics.getWidth() then tx = -7680 + love.graphics.getWidth() end
if ty > 0 then ty = math.floor(-sprite.y + wh / 2 + 100) end
if ty < -4352 + love.graphics.getHeight() then ty = -4352 + love.graphics.getHeight() end
Code: Select all
if enemy == lowerClassSaiyan and powerLevel > 9000 then
love.graphics.print("What?! 9000?! There's no way that could be right!", 10, 200)
else
love.graphics.print("You fool!", 10, 200)
end
Re: Simple Tiled Implementation - STI v0.14.1.8
@Rishavs sorry for the late response. My computer is currently broken so I can't do much testing atm. Once I get a new power supply I'll take a look at your issue if you haven't already fixed it.
@giantofbabil Yeah you want to make sure that translate isn't going out of bounds
0 < translate < map_size_in_pixels - screen_size
@giantofbabil Yeah you want to make sure that translate isn't going out of bounds
0 < translate < map_size_in_pixels - screen_size
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
- giantofbabil
- Prole
- Posts: 32
- Joined: Tue Dec 15, 2015 6:07 pm
Re: Simple Tiled Implementation - STI v0.14.1.8
Any idea how I can set a specific tile to change a variable in my code? I have a tile that is spikes for instance and I would like it to set a boolean called spikeDamage to true, but I'm not sure how to check if the player is touching a specific tile for anything other than collision(which I do by going custom properties in tiled and putting "collidable" in the left side and "true" in the right in Tiled). I tried just putting spikeDamage in left box and true in right box in Tiled but that doesn't work.
Code: Select all
if enemy == lowerClassSaiyan and powerLevel > 9000 then
love.graphics.print("What?! 9000?! There's no way that could be right!", 10, 200)
else
love.graphics.print("You fool!", 10, 200)
end
Re: Simple Tiled Implementation - STI v0.14.1.8
You can use the convert functions to convert between coordinate systems. In this case you want to convert the pixel value to tiles and then check that tile for whatever property.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
- giantofbabil
- Prole
- Posts: 32
- Joined: Tue Dec 15, 2015 6:07 pm
Re: Simple Tiled Implementation - STI v0.14.1.8
Thanks! I ended up making a couple variables that track the players tile location so I can check that against whatever I need to going forward.Karai17 wrote:You can use the convert functions to convert between coordinate systems. In this case you want to convert the pixel value to tiles and then check that tile for whatever property.
Code: Select all
if enemy == lowerClassSaiyan and powerLevel > 9000 then
love.graphics.print("What?! 9000?! There's no way that could be right!", 10, 200)
else
love.graphics.print("You fool!", 10, 200)
end
Re: Simple Tiled Implementation - STI v0.14.1.8
@giant: you can check my bounds code at. I also discussed the same a couple of pages ago in the very thread.
https://github.com/rishavs/RoguishLove/
@Karai: no worries.
The weird thing is that if I define the, then only 21*21 tiles are rendered.
If i comment it out, 21 tiles rendered widthwise, and then 21 more tiles are rendered on top of it (so it looks multiple sheets with the edges on top of each other). The tiles are rendered properly vertically.
Also, my camera bound code simply doesnt works for the right edge and bottom edge anymore. Not sure if it is relatd to the same "21" issue or something i need to change to handle staggered isometric maps (my bounding code works correctly for normal diamond shaped isometric maps)
Finally, happy holidays everyone!
https://github.com/rishavs/RoguishLove/
@Karai: no worries.
The weird thing is that if I define the
Code: Select all
self.map:setDrawRange(0, 0, windowWidth, windowHeight)
If i comment it out, 21 tiles rendered widthwise, and then 21 more tiles are rendered on top of it (so it looks multiple sheets with the edges on top of each other). The tiles are rendered properly vertically.
Also, my camera bound code simply doesnt works for the right edge and bottom edge anymore. Not sure if it is relatd to the same "21" issue or something i need to change to handle staggered isometric maps (my bounding code works correctly for normal diamond shaped isometric maps)
Finally, happy holidays everyone!
Re: Simple Tiled Implementation - STI v0.14.1.8
Yeah my draw range cover doesn't work for anything besides ortho atm. Since no one seems to use anything else, it was never a priority for me.
STI - An awesome Tiled library
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
LÖVE3D - A 3D library for LÖVE 0.10+
Dev Blog | GitHub | excessive ❤ moé
Re: Simple Tiled Implementation - STI v0.14.1.8
Hi,
thanks for this library. I have a question -- sorry if this has been asked already.
How can I easily implement "collecting" items from a map? For example I have a layer with "coin" or "key" tiles and if player collides with a tile in this layer I want to remove the tile from the layer (simply stop displaying that one).
Is this possible to programatically modify the loaded map or is it out of scope for this library?
What is a recommended or a common way to do this? Should I insert the objects into the map (custom layer?) from code and then remove them? (I probably know how to do this.) But I'd like better to use Tiled editor to insert collectible items into the map.
Thanks!
thanks for this library. I have a question -- sorry if this has been asked already.
How can I easily implement "collecting" items from a map? For example I have a layer with "coin" or "key" tiles and if player collides with a tile in this layer I want to remove the tile from the layer (simply stop displaying that one).
Is this possible to programatically modify the loaded map or is it out of scope for this library?
What is a recommended or a common way to do this? Should I insert the objects into the map (custom layer?) from code and then remove them? (I probably know how to do this.) But I'd like better to use Tiled editor to insert collectible items into the map.
Thanks!
Who is online
Users browsing this forum: Google [Bot] and 6 guests