acleverpun / letsgoonanadventure

Adventure game prototype built from our skeleton
0 stars 0 forks source link

More powerful events system #16

Open rosshadden opened 9 years ago

rosshadden commented 9 years ago

I figure it's going to be extremely common to be all:

events: {
    use: function(entity) {
        if (entity.id === 'player') { ... }
    }
}

So instead of having to worry about stuff like that, let's make the event system more powerful. I want it to support a css-ish seletor syntax, and essentially translate it to the above.

An example of some things I want to support:

events: {
    'use#player': function(entity) { ... },
    'enter.enemy': function(entity) { ... },
    'leave.enemy[health<=50]': function(entity) { ... },
    'enter.item, enter[health], enter#player': function(entity) { ... }
}