Hi markusm,
I am also new to LÖVE2D. I started with a very simple « click on the target » game from a video on YouTube. I then build Bulldozer in steps: I got a copy of Tiled (the editor), found a tile set I liked, made a map, and loaded it in a rudimentary game (it did almost nothing). I added things to it one at a time: sound, an object layer, and the bulldozer. I added LÖVE2D physics later; it took a long time to get the bulldozer moving well.
I then worked on collisions with physics. LÖVE2D uses the Box2D library; it is excellent and well known. This is a complex element of the game. I made the choice to use physics because later stages of the game will benefit from it (e.g., you cannot push too many rocks at a time). You may not need physics; one alternative is bump https://love2d.org/wiki/bump.lua.
When I started having difficulty with collisions, I made a smaller 8 x 8 map with only one rock. I added a lot of print statements to see what was happening. Print is your friend. If there is a lot of output, pipe it into a file you can examine more conveniently with something like the 'less' command.
The world.lua file you provided is quite different from the one I am using. I have not seen chunks before, but may not mean much since I am a beginner with Tiled editor. Here is a half-size screenshot of Tiled with my small testing map. I put the ground tiles in one layer and the rock on an object layer. You can see the dashed lines of the collision boxes; I added those to the tile-set.
There are other tricks with using Tiled. It took me a while to learn.
Good luck in your development.
Simple Tiled Implementation - STI v1.2.3.0
Re: Simple Tiled Implementation - STI v1.2.3.0
P. S. I tried using your map with the example in the STI GitHub page and also got a blank window. I suggest starting with that code.
https://github.com/karai17/Simple-Tiled-Implementation
https://github.com/karai17/Simple-Tiled-Implementation
Re: Simple Tiled Implementation - STI v1.2.3.0
I don't believe infinite maps / chunked maps currently work with STI. You will need to change your map properties to have a fixed 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é
Re: Simple Tiled Implementation - STI v1.2.3.0
Thanks everybody for the feedback! I will try fixed sized maps.
And thanks Claude for giving me the Bulldozer example, looks like a fun game. Can I do something to debug the crash I have on my MacBook Pro ? Do not really know how to provide debug information with Love2D right now.
Thanks,
And thanks Claude for giving me the Bulldozer example, looks like a fun game. Can I do something to debug the crash I have on my MacBook Pro ? Do not really know how to provide debug information with Love2D right now.
Thanks,
Re: Simple Tiled Implementation - STI v1.2.3.0
Is it a hard crash or are you getting the blue screen with white text? If the latter, you can post a screenshot of that as it should tell you where the error is occuring and give a stack trace for how that function got called. If the former, might want to pop into the LOVE Discord and @slime with more details.
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 v1.2.3.0
It's not a crash per se but the app hangs and the audio channel goes wild, have to kill the process in the task manager.
Ok, will join the discord and message @slime. Thanks.
Ok, will join the discord and message @slime. Thanks.
Re: Simple Tiled Implementation - STI v1.2.3.0
Found the problem with rock object positions being off by a factor of two: vertices are relative to the object, do not add the position of the object. Here is the section of sti/plugin/box2d.lua
Time to write the code to move the rock sprite to match the physics engine's position for the rock.
Code: Select all
elseif o.shape == "polygon" then
-- Recalculate collision polygons inside tiles
if tile then
local cos = math.cos(math.rad(o.r))
local sin = math.sin(math.rad(o.r))
for _, vertex in ipairs(o.polygon) do
-- vertex.x = vertex.x + o.x
-- vertex.y = vertex.y + o.y
vertex.x, vertex.y = utils.rotate_vertex(map, vertex, o.x, o.y, cos, sin)
end
end
local vertices = getPolygonVertices(o)
local triangles = love.math.triangulate(vertices)
for _, triangle in ipairs(triangles) do
addObjectToWorld(o.shape, triangle, userdata, tile or object)
end
- Attachments
-
- bulldozer-0.15.zip
- (2.68 MiB) Downloaded 1807 times
Re: Simple Tiled Implementation - STI v1.2.3.0
Hi,
After looking more at the Box2D plugin code, I see that static elements of a tile can be associated with the main body (the first one created in box2d_init). For those, adding the tile position is required. The code must recognize this situation; there must be cooperation between the Box2D plugin and the way the map is designed in Tiled editor.
Is there an established convention? Would this work? Mark a tile layer as collidable and static while leaving the individual tiles un-marked; the code can detect this and do the right thing. The other case is an object layer with some collidable objects marked dynamic and some marked as static. Oh, the comments at the bottom of the Box2D plugin do not mention a static property. Should static objects be marked "dynamic: false" ? We can also say that the absence of the dynamic property means static.
Thoughts?
Thanks.
After looking more at the Box2D plugin code, I see that static elements of a tile can be associated with the main body (the first one created in box2d_init). For those, adding the tile position is required. The code must recognize this situation; there must be cooperation between the Box2D plugin and the way the map is designed in Tiled editor.
Is there an established convention? Would this work? Mark a tile layer as collidable and static while leaving the individual tiles un-marked; the code can detect this and do the right thing. The other case is an object layer with some collidable objects marked dynamic and some marked as static. Oh, the comments at the bottom of the Box2D plugin do not mention a static property. Should static objects be marked "dynamic: false" ? We can also say that the absence of the dynamic property means static.
Thoughts?
Thanks.
Re: Simple Tiled Implementation - STI v1.2.3.0
Hi Karai17,
Where in the map does the draw function get the x, y, and r ? I want to update dynamic object tiles (images) and tried updating the tileInstances table, but it has no effect. I looked at the main STI function (init.lua) and had a hard time following the code.
Thanks.
Where in the map does the draw function get the x, y, and r ? I want to update dynamic object tiles (images) and tried updating the tileInstances table, but it has no effect. I looked at the main STI function (init.lua) and had a hard time following the code.
Thanks.
Re: Simple Tiled Implementation - STI v1.2.3.0
tiles get batched so you need to remove it from the batch, update the instance, then add it back to the batch
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é
Who is online
Users browsing this forum: No registered users and 8 guests