10 years ago by stcredzero
Howdy,
I'm writing a multiplayer game on the desktop. I've written a websockets HTML5 game before. (currently at http://emergencevector.com) However, that game had a roll-your-own game loop. With ImpactJS, I'm a little confused as to where I should put my websockets event functions. I currently have them in the game's init. I find this problematic because of the weird semantics around the this keyword in Javascript. I don't want my websocket object accidentally stuck into another object that invoked the init() on the game. I've also thought about establishing my own global websocket management object, and having each entity register for callbacks by UUID. Any thoughts? Does the way ImpactJS put together allow me to stick properties on 'this' at init() time and not worry about values being stuck onto the caller?
I'm writing a multiplayer game on the desktop. I've written a websockets HTML5 game before. (currently at http://emergencevector.com) However, that game had a roll-your-own game loop. With ImpactJS, I'm a little confused as to where I should put my websockets event functions. I currently have them in the game's init. I find this problematic because of the weird semantics around the this keyword in Javascript. I don't want my websocket object accidentally stuck into another object that invoked the init() on the game. I've also thought about establishing my own global websocket management object, and having each entity register for callbacks by UUID. Any thoughts? Does the way ImpactJS put together allow me to stick properties on 'this' at init() time and not worry about values being stuck onto the caller?