Jump to content
  • Advertisement
Sign in to follow this  
Nicholas Kong

How to structure screens for different areas in a 2D game

This topic is 2116 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Suppose I was to add a simplistic approach for the character to visit one screen to the next, I want to know how I can go about doing it without doing something ugly like naming each area of the game: screen0, screen1,screen2...

 

Game is coded in Java

Psuedo code:
 
public class Screen extends Map{
  super(screenNumber);
}
 
public void update()
{
// if character reaches screenNumber load the art assets from this update method
 
}
 
public void draw()
{
// update triggers the drawing of art assets at different coordinates of the screen
}
 
public Map{
 
 
 
private int screenNumber;
   public Map(int screenNumber)
{
this.screenNumber = screenNumber;
}
 
}
 
}
Edited by warnexus

Share this post


Link to post
Share on other sites
Advertisement

The obvious question is:

How are you creating your screens?

 

Your underlying engine should have some sort of referencing mechanism, but your editor or level-generator should take care of generating these screen IDs. 

 

The only reason you should know the names in advance is if you are creating them by hand.

 

Are you using a level editor?

Edited by SillyCow

Share this post


Link to post
Share on other sites

The obvious question is:

How are you creating your screens?

 

Your underlying engine should have some sort of referencing mechanism, but your editor or level-generator should take care of generating these screen IDs. 

 

The only reason you should know the names in advance is if you are creating them by hand.

 

Are you using a level editor?

The screens are created by hand. Upon booting up the game, the screen objects will be stored in a list and later update and drawn on-screen. So if the character enters screen1 from screen0, there will be a java file in my game that will figure out " which screen the character is in" and draw all the art assets that is suppose to happen for that corresponding screen object.

 

I won't be using a level editor. I am going to do it by hand and see what the experience is like.

 

My question is whether naming the screens: screen0, screen1 fine for a 2D rpg.

 

My other question would be what would be the naming convention for screens be for larger console rpg games?

Edited by warnexus

Share this post


Link to post
Share on other sites

if it is side scrolling then yes.

If it is top view, then you should probably go with bi-directional naming like: screenX_Y as in screen1_1 is above screen1_0.

 

I would assume that all large games use an editor, or procedural generation.

Procedural generation makes it so it doesn't matter.

Editors will contain binary pointers, and the name will just be a user label which can be renamed later.

Edited by SillyCow

Share this post


Link to post
Share on other sites

if it is side scrolling then yes.

If it is top view, then you should probably go with bi-directional naming like: screenX_Y as in screen1_1 is above screen1_0.

 

I would assume that all large games use an editor, or procedural generation.

Procedural generation makes it so it doesn't matter.

Editors will contain binary pointers, and the name will just be a user label which can be renamed later.

Thanks.

Share this post


Link to post
Share on other sites

Regarding code, Screen objects should have no "screenNumber" field, because screen numbers are only the names you use to refer to screens and they aren't useful at runtime.

Pointers to Screen instances, on the other hand, make sense (for example, to map movement directions to adjacent Screens); they might be located in auxiliary data structures.

 

I suggest meaningful names (e.g. "throne_room_screen" directly below "secret_passage_behind_throne_screen") rather than arbitrary numbers or, worse, grid locations ("screen_5_4" and "screen_5_5": what if you extend a corridor and the throne room moves to column 7?); of course, such names can be useful in level files, as metadata and as unique identifiers for cross-referencing, or as variable names (but only somewhat special screens need a variable; the others can be simply reached through pointers).  

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!