Jump to content

Game States and Game State Manager


Recommended Posts


I am trying to make my game state flow these days; I was wondering if Babylonjs has something ready to manage game states?

An instance of game state flow would be:

MainMenu --> LevelSelection --> LoadingScreen(Level1) --> Gameplay --> WinningScreen --> LoadingScreen(Level2) --> Gameplay --> WinningScreen --> LoadingScreen(Level3) --> Gameplay --> PauseMenu --> MainMenu --> Exit


More documentation on what I mean here: http://gamedevgeek.com/tutorials/managing-game-states-in-c/ or https://rareelementgames.wordpress.com/2017/04/21/game-state-management/


Here are examples of game engines that implemented this pattern:

- LibGDX: https://github.com/libgdx/libgdx/wiki/Extending-the-simple-game (they named the states Screens, and the mananager is Game)

- Phaser 2: http://perplexingtech.weebly.com/game-dev-blog/using-states-in-phaserjs-javascript-game-developement

- Phaser 3 (renamed Scenes): https://phaser.io/phaser3/contributing/part5


Any thoughts? How do you manage your game states with Babylonjs?

Link to comment
Share on other sites

Currently there's not such a thing per se in BJS. I intended to implement one but didn't find the time up now.

I did a first simple proto in the game StarFighter. You could get the code here https://github.com/jbousquie/OfficeGames/blob/master/StarFighter/StarFighter.js#L1480 

the scene orchestration logic (scene linking, what's different from a game to another one ) is to be implemented here  https://github.com/jbousquie/OfficeGames/blob/master/StarFighter/StarFighter.js#L1505


Then the object is created and used from here only in the following lines : https://github.com/jbousquie/OfficeGames/blob/master/StarFighter/StarFighter.js#L1552



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...