Skip to content

Instantly share code, notes, and snippets.

@bdickason
Created August 13, 2011 12:08
Show Gist options
  • Save bdickason/1143781 to your computer and use it in GitHub Desktop.
Save bdickason/1143781 to your computer and use it in GitHub Desktop.
Event design - world routes all events from objects to client
class enemy extends EventEmitter
load: ->
emit 'load'
move: (location) ->
# moves an enemy across the game
emit 'move', location
class world extends EventEmitter
enemy.on 'load'
emit 'loaded', enemy
enemy'on 'move'
emit 'moved', enemy
class client extends EventEmitter
world.on 'loaded', object
# load object data
world.on 'moved', object
# show enemy moving to the client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment