Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by AutoDMC

So how do you guys handle gamestates? The game I'm working on has a few game states. As an RPG, I've got a few:

Title Screen
Map Screen
Equipment Screen
Item Use Menu Screen
Battle System
Story Cutscene Player State

With the various transitions thereof.

So, I've happily created a title screen program. Looks cool. Made a mapscreen out of a level and some entities... nice.

But I'm a PHP web developer, not a game developer (yet!), but I need a way to handle switching between states, and I'm not sure where to start.

So is there an easy way to handle gamestates in ImpactJS? I found Boneheadmed's Director, which can handle switching between maps (a requirement in the Map state above, can't wait to use it)... but I need something even more meta than that.

Still researching, and I'm finding some neat general info, but it seems like such a core thing for a game I can't imagine there isn't already a best practice for this already...

1 decade ago by fugufish

all my gamestates are in my main.js

it's a quick and dirty approach:

//main.js

	showStats:function(){
            this.font.draw('Statistics page',x,y);
            // more stuff here
        },

	showMap:function(){
            this.font.draw('Map page',x,y);
            // draw map here
        },


the functions above are triggered by certain keys: m for maps, s for statistics. They can also be event-triggered.

1 decade ago by MikeL

Hi AutoDMC. For a very simple version of game states have a look at the code for YOSS (recommend downloading it, because the indentation doesn't look right on Github which makes it confusing). Look at main.js you'll see that I have several states:
STATE: {
    GAMEOVER: 0,
    GAMEPLAYING: 1,
    PLAYERELIMINATED: 2,
    LEVELTRANSITION: 3
  },

These are manipulated in the update and draw functions.
Page 1 of 1
« first « previous next › last »