Closed mpizenberg closed 6 years ago
Handling of collisions is done in two steps:
Data.Game.allCollisions
.Data.Game.processCollision
.It is an approximation because collisions are not recomputed for elements altered by previous collisions in the list.
It mostly works well. There are some issues left for player/ball collisions where players can get "trapped" in a ball.
A bit intertwined with game logic but hey, deserves its own issue ;)
The idea is probably to have it's own module, and describe the effects of collisions with a data type. This type could be used as a return value of functions of this module to describe the result of checking for collision so that the caller code can decide on what to do. You probably have alternative ideas on how to do that, experiment freely ^^.
For the physical models of things, I guess a simple implementation would be to consider only:
lines for the field limits
squares for blocks
disks for players and bullets. For now, visual representation of those are triangles with points on the circle centered at the player
pos
, so we could use the same circle / disk for collision estimation I guess.player / player -> cannot go further?
player / wall -> cannot go further
player / block -> cannot go further
player / bullet -> stun
player / ball -> ?
bullet / bullet -> destroyed both
bullet / wall -> destroyed
bullet / block -> destroyed + block hit
bullet / ball -> depends