A Finite State Machine implementation for use with Javascript games

Currently I’m working on a new Javascript/WebGL game called ChuClone. It’s been a lot of fun to work on so far. Having a good editor has been a key in that, as it allows you to write javascript in a more application like style, than strictly a series of DOM manipulation functions.

For this game I wanted to use a Finite State Machine to handle my gameplay states.

An example of such a system is if you think of your game as a connection of screens, for example:

Continue reading A Finite State Machine implementation for use with Javascript games

Component based game entities in javascript

I’m creating a javascript/webgl based game and would like you guys to take a look at the current entity component system which I created for it, and perhaps weigh in some opinions.

On caveat I don’t like is that, sometimes a component needs to call the attachedEntities version of a function it has overridden. For example handleInput, it might call the attachedEntities handleInput functions and then with the new movementVector multiply them by negative 1 so now all input while this component is active is reversed.

When I intercept the properties, currently I wrap intercepted function calls into a closure ( see BaseComponent.intercept() ) so that the ‘this‘ object can refer to the component itself. Without that the ‘this’ object was still being referred to as the attachedEntity (from within the components version of that function), so to get the components properties I had to run a query.

So I’m curious what others think of this implementation.

Things I used as reference:

Continue reading Component based game entities in javascript