garrettgsb / sooper-maria-sisters

They can do it if they try~
MIT License
0 stars 0 forks source link

Mortal Mobs, Murderous Mobs #19

Open garrettgsb opened 6 years ago

garrettgsb commented 6 years ago

TL;DR

Summary

Now that dying is a thing that objs can do, they should be able to compel each other to do it. This will involve the collisionCallback that each obj has.

The easiest thing to do would be rock-scissors-paper style collisions: if (obj.name === 'rock' && this.name === 'paper') { this.die() } or whatever. But we want things a little more sophisticated than that: If the player is on top of the mob, the mob dies. Otherwise, the player dies. That might involve reading which points did the colliding, or it might just mean comparing the y coord of the objs. At any rate, these can all be handled in the collision callback function.

What we usually care about the most is player-obj collisions (as opposed to obj-obj collisions that don't involve the player)... So I think the easiest thing to do is for the non-player to do most of the logic when there's a collision. Otherwise, the player obj will end up with a mess of switch statements that will get difficult to maintain.

Notes