State Pattern Demo for Scene Object in Projects
Shri

Waders,

 

I put a little demo of how to implement a state pattern for a scene object in Wade.

It is up in the projects section titled - State Pattern Demo

 

The robot has three states - Idle, Walk and Fire.

You control the robot with the keyboard:

a and d to rotate left and right, w to go forward and space bar to fire.

I only did keyboard controls to keep things simple.

 

If you look at the two .js files, it should be pretty easy to understand.

 

The code and animations could be tweeked a little to improve them,

but this gives you an example of how you could implement a state pattern in a behavior file in Wade.

The state pattern should be easier to maintain than an FSM or a bunch of conditional statements.

You could easily extend the example to include more states and functionality

 

For some reason, the keyboard controls don't work unless you run the project in full screen mode.

 

The robot animations are courtesy of Skorpio at opengameart.org under the CC-by-SA 3.0 license.

 

 

cheers,

Shri

No Comments Yet
Post a reply
Add Attachment
Submit Reply
Login to Reply