Jump to content

How to organise game worlds?


icetimux
 Share

Recommended Posts

Hi everyone. I have experience with phaser making small arcade like games. But I now want to make a larger platformer with worlds. I cant figure out how to organise my code for each world and how to switch between worlds.

Can anyone provide me with some guidance on how I can do this?

Link to comment
Share on other sites

You are going to need stages. When you end one world - call a stage that sets up the data for the gameplay stage, and then calls the gamestage who's create function build the world currently loaded for it. But I am new at phaser and just cause it works does not make it the best way. 

Link to comment
Share on other sites

What I typically do is have a game state that corresponds to your main gameplay loop, IE when your user is actually playing the game.  Then, I feed this gameplay state a data object that represents the level that the player will be playing on, with information such as where the character spawns, where the goal object(s) spawn, where enemies spawn, gameplay triggers, ect.  The main loop can parse out this data and actually calculate the logic on the fly.  This way, you create degrees of separation between your gameplay logic and the data that represents your "worlds" and it'll be much easier to add more worlds or change mechanics later.

Then, when it comes time to switch to a new world, you just have to restart the state again with a new "world" data object.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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