gamemash / platformer

0 stars 1 forks source link

Collidable stream #12

Closed oponder closed 8 years ago

oponder commented 8 years ago

_experimental _

Collidable now exposes a stream which can be used to handle collisions between objects in a functional reactive programmy way.

much wip. Still needs more clean up. buggy but funny

Allows for stuff like this:

function isMario(collision) { return (collision.entity.name == "MARIO"); }
function cameFromAbove(collision) { return (collision.direction == "above"); }

this.collisionStream.filter(isMario).filter(cameFromAbove).onValue(() => { 
  console.log("I got hit from above by Mario!");
};

Now we're thinking with portals functions

dorsath commented 8 years ago

noice

oponder commented 8 years ago

Going to close this for now, and revisit the concept at a later date.