andrew-peng-144 / js-explore-game

0 stars 0 forks source link

detect the first time a collision happened #13

Open andrew-peng-144 opened 3 years ago

andrew-peng-144 commented 3 years ago

like box2d's onEnter() and onExit(). This is really good for projectiles collision but not wanting to remove the projectile, like piercing.

andrew-peng-144 commented 3 years ago

idea: track when pairs of IDs collide with each other. Cases:

andrew-peng-144 commented 3 years ago

use 2 lists of hashed IDs: "prev" and "curr", with fast add, remove, and search. then follow up with the logic in above comment

andrew-peng-144 commented 3 years ago

Did the onenter, in the form of a boolean in the handler function.

The onexit works, but still need to have a way to add a onexit function for each pair of types.