Sign in to follow this  
Followers 0
icetimux

How to organise game worlds?

4 posts in this topic

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?

Share this post


Link to post
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. 

Share this post


Link to post
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.

breed likes this

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.