Created
August 13, 2011 12:08
-
-
Save bdickason/1143781 to your computer and use it in GitHub Desktop.
Event design - world routes all events from objects to client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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