Hi,
I have really searched around the Internet to know how to have simple collisions working with my little game. I want to use STI because it's so simple to implement, but how to make simple collisions without using box2d? If this subject is already well responded can you guys refer me to the topic, because right now I'm a little bit strugling. I'm coming form pico-8 so all of this is new to me
STI and collision
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- JuanjoSalvador
- Prole
- Posts: 26
- Joined: Wed Nov 27, 2019 9:19 pm
- Location: Almeria, ES
- Contact:
Re: STI and collision
It's funny, I switched from Love2D to PICO-8 few years ago, and then back to Love2D again.
I think I already answered this on Reddit too, but in a nutshell, using Box2D plugin is your best choice, imho. If you don't need gravity, you can set gravity to 0 when creating the World object.
I think I already answered this on Reddit too, but in a nutshell, using Box2D plugin is your best choice, imho. If you don't need gravity, you can set gravity to 0 when creating the World object.
itch.io profile - When I'm uploading my works and devblogs
GitHub - All my code is here!
Horchata - A set of Lua modules I wrote to make some task easier
GitHub - All my code is here!
Horchata - A set of Lua modules I wrote to make some task easier
Re: STI and collision
Honestly that's funny because 2 years ago I tried love2d found it too complicated and then switched to pico-8 ha ha ha. Should I draw the tilemap myself, would it be easier for me to test collisions?
Re: STI and collision
For axis-aligned rectangles (AABBs), I recommend the Bump library, https://github.com/kikito/bump.lua
STI contains a plugin for bump, no idea how they're used together though. I haven't used STI myself.
STI contains a plugin for bump, no idea how they're used together though. I haven't used STI myself.
Last edited by pgimeno on Sat May 02, 2020 12:13 pm, edited 1 time in total.
- JuanjoSalvador
- Prole
- Posts: 26
- Joined: Wed Nov 27, 2019 9:19 pm
- Location: Almeria, ES
- Contact:
Re: STI and collision
Depending of the complexity of your tileset, but I would say no. Can you provide a .love file or something we can see?
itch.io profile - When I'm uploading my works and devblogs
GitHub - All my code is here!
Horchata - A set of Lua modules I wrote to make some task easier
GitHub - All my code is here!
Horchata - A set of Lua modules I wrote to make some task easier
Re: STI and collision
Actually I have found the perfect solution. The cartographer library! It is capable of doing the same thing as what pico-8 is capable, it's really great. I've had somme issues so I created my own function in cartographer that allow me to quickly put a map, a tile_number and a property and that returns true or false, exactly like fget in pico-8. I'm really happy with it. This is what I added :JuanjoSalvador wrote: ↑Sat May 02, 2020 12:06 pmDepending of the complexity of your tileset, but I would say no. Can you provide a .love file or something we can see?
Code: Select all
function pget(map,gid,propertyName)
local prespect
if gid == false or gid == nil then
prespect = false
return false
else
prespect = map:getTileProperty(gid,propertyName)
if prespect then
return true
else
return false
end
end
end
- JuanjoSalvador
- Prole
- Posts: 26
- Joined: Wed Nov 27, 2019 9:19 pm
- Location: Almeria, ES
- Contact:
Re: STI and collision
Perfect
itch.io profile - When I'm uploading my works and devblogs
GitHub - All my code is here!
Horchata - A set of Lua modules I wrote to make some task easier
GitHub - All my code is here!
Horchata - A set of Lua modules I wrote to make some task easier
-
- Prole
- Posts: 16
- Joined: Wed May 15, 2019 12:41 am
- Location: Valparaiso, Chile.
Re: STI and collision
Love2D documentation have a nice list of tutorials:
https://love2d.org/wiki/Category:Tutorials
The first in the list have a very nice explication about 2D collisions:
https://sheepolution.com/learn/book/13
It have too a very compressive introduction to tiles and collisions:
https://sheepolution.com/learn/book/18
U can learn it and then implement a solution for ur problem, love requiere a little more work than PICO but the flexibility is certainly bigger. The documentation is your best friend in any code adventure.
https://love2d.org/wiki/Category:Tutorials
The first in the list have a very nice explication about 2D collisions:
https://sheepolution.com/learn/book/13
It have too a very compressive introduction to tiles and collisions:
https://sheepolution.com/learn/book/18
U can learn it and then implement a solution for ur problem, love requiere a little more work than PICO but the flexibility is certainly bigger. The documentation is your best friend in any code adventure.
-
- Prole
- Posts: 3
- Joined: Fri Nov 27, 2020 10:02 pm
Re: STI and collision
Could you please give an example of how to use this?ZephB wrote: ↑Sat May 02, 2020 4:44 pmActually I have found the perfect solution. The cartographer library! It is capable of doing the same thing as what pico-8 is capable, it's really great. I've had somme issues so I created my own function in cartographer that allow me to quickly put a map, a tile_number and a property and that returns true or false, exactly like fget in pico-8. I'm really happy with it. This is what I added :JuanjoSalvador wrote: ↑Sat May 02, 2020 12:06 pmDepending of the complexity of your tileset, but I would say no. Can you provide a .love file or something we can see?
Code: Select all
function pget(map,gid,propertyName) local prespect if gid == false or gid == nil then prespect = false return false else prespect = map:getTileProperty(gid,propertyName) if prespect then return true else return false end end end
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 4 guests