Monday, January 22, 2007

Controllers improved

The old engine used hardcoded c++ controllers for handling incoming control requests. For example, when a user pressed the space key, the game client would notice this and send a packet to the server about what had happened. On the server side the controllers would make an actor associated to the controller do something e.g. jump or shot.

I've changed this a a little bit. Now the controller is to be derived in scripting and no actor is associated to a controller per default. This is because that not all type of games has a specific actor associated. The controller may be controlling several actors, or perhaps no actor at all. This is game type dependent and should be described in scripts. Therefore, I've create a derived controller in script that will (for my game type) create a n actor an remember it. When the controller later on receives a "keypress" it will ask the actor to do something e.g. jump or shot. Exactly the same as before but now customizable through scripting and much more flexible.

At some point the keypress from the client side should simply be a RMI call as I've shown can be done from the console. But for now this is adequate. I still need some debugging before creating the shot and the bug character though.

No comments: