erikwatson / Bramble

A little JS game engine for jamming on prototypes.
MIT License
0 stars 1 forks source link

Collision Detection #37

Open erikwatson opened 3 years ago

erikwatson commented 3 years ago
  1. Rectangle vs Rectangle
  2. Ray vs Rectangle
  3. Dynamic Rectangle vs Rectangle
  4. Circle vs Circle
  5. ...

I'll add more later if I think I need them.

What is most important to me is that a player can collide with a tile map. I have a proof of concept of this somewhere, it works pretty nicely but I think the approach was wrong. Anyway, I'm probably going to need to do 1, 2 and 3 in order to get it working.

I think exposing the collision functions is probably useful, but what I really want is just for the user to be able to do something as simple as collide(hero, tilemap) and just have Bramble figure out how to do it. I'm not sure exactly how this will look but it needs doing.

erikwatson commented 1 year ago

I have come to think that perhaps it is not a good idea to try and handle collision response at the "engine" level and instead let each game decide how it wants to handle the collision data when it gets it.

I've got a build of AABB working nicely in another project, but I will consider merging it into Bramble soon. It does 1, 2, and 3. It doesn't do dynamic rectangles vs other dynamic rectangles. It doesn't do arbitrary polygons or circles. The rectangles can't be rotated (it's AABB, baby!)

If we want rotation and arbitrary polygons when we'll need to implement SAT too. There's no need for that just yet.

erikwatson commented 4 months ago

Added a line vs cubic bezier curve function. It probably needs some tidying up to bring it in line with the rest of the api but it's there.