It is now trivially easy to implement entities which are finite-state machines with jsGameSoup. Some examples of entities that could be modelled as finite-state machines:
* A non-player character which wanders around and then starts chasing the player once they come in range.
* A door which switches between closed, opening (animated), and open states.
* A spacecraft under player control which has an proximity-triggered docking procedure.
<http://mccormick.cx/news/entries/finite-state-machines-in-jsgamesoup>
Cheers,
Chris.
-------------------
http://mccormick.cx
It is now trivially easy to implement entities which are finite-state machines with jsGameSoup.
--bcaec547ca45a3572904a
On Sun, Aug 07, 2011 at 10:47:32AM +0200, Atom Gape wrote:
> 2011/8/7 Chris McCormick <ch...@mccormick.cx>
> > It is now trivially easy to implement entities which are finite-state
> > machines with jsGameSoup.
>
> Do you plan to implement state changes based on timing, e.g. the
> enemy chills down after a minute anyway? (Yeah I can use counters for this.
> I've tried it and worked OK.)
I have now implemented a new method on jsGameSoup called "schedule" which lets you specify a number of frames and a callback which gets run that number of frames in the future.
If you specifically want time-based callbacks you might as well use the setTimeout() function which is built into Javascript.
<http://mccormick.cx/projects/jsGameSoup/jsdocs/symbols/JSGameSoup.html#schedule>
<http://mccormick.cx/projects/jsGameSoup/tests/schedule.html>
> By the way, I've noticed the screenshot of an isometric-like alignment
> (water, little islands and one player) in your post; is that an actual game
> you're working on? Seems really great so if you'd have some spare time to
> create a tutorial for that, it'd be really great.
That was a Ludum Dare entry I wrote a while back but I never finished it off - just the graphics. It did not actually use jsGameSoup as I had not yet written the sprite engine, but I pulled the code for the sprite engine in from that demo. With that kind of thing the important part is the drawing order of the elements. You want to draw the lowest elements and the elements furthest back from the screen first. You can use the 'priority' property of your jsGameSoup entities to ensure this.
> I don't know how to create
> games like that so I started with a top-view alignment. I'd like to create
> that quasi-isometric view if I could. I'm really interested on how do you
> generate the "tiles" like that and moreover how do you handle the
> collisions? In my little game I worked hard to create a routine that can
> tell which side of the objects was hit; in an isometric view it seems to be
> even more hard.
In terms of collisions you can use circular collisions and when drawing multiply by some factor that changes the circles into the side-on ovals.
Incidentally, I am working on a new module for jsGameSoup which will be able to import tiled TMX format maps:
I am trying to make this very quick and easy for game developers so you can basically create a map in the tool and then instantly pull it into your game.
I have now implemented a new method on jsGameSoup called "schedule" which lets you specify a number of frames and a callback which gets run that number of frames in the future.
With that kind of thing the important part is the drawing order of the elements. You want to draw the lowest elements and the elements furthest back from the screen first. You can use the 'priority' property of your jsGameSoup entities to ensure this.
In terms of collisions you can use circular collisions and when drawing multiply by some factor that changes the circles into the side-on ovals.
Incidentally, I am working on a new module for jsGameSoup which will be able to import tiled TMX format maps:
<http://www.mapeditor.org/>
On Mon, Aug 22, 2011 at 11:10:06PM +0200, Atom Gape wrote:
> 2011/8/20 Chris McCormick <ch...@mccormick.cx>
> Incidentally, I am working on a new module for jsGameSoup which will be able
> > to import tiled TMX format maps:
> >
> > <http://www.mapeditor.org/>
>
> Wow it really blowed my mind. :) After my holiday I'm going to try some more
> serious stuff. :-)
Oh I think I forgot to mention in my first email that this will support the type of isometric views you were asking about in your original email.
<http://images.mapeditor.org/tiled-qt-screenshot-4.png>
I want to get both the side/top view an isometric views working. Will post more here when it is working.
Have fun!