Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Transitioning from Main Menu to entirely different games  (Read 640 times)
0 Members and 1 Guest are viewing this topic.
Offline tom_mai78101
« Posted 2013-12-02 06:32:09 »

I use the Test-Driven Development framework to develop my game. Whenever I start off developing, the first thing I have to do is to get a game to work, and skip the visuals until I'm sure the game is working as intended.

Starting from scratch, when I develop a game, I head straight to the game core mechanics. Basically, when I start debugging, I go straight to the game, not straight to the main menu. The game core mechanics are glued tightly together with the outer game framework (i.e., a JFrame object wrapping a GameComponent that envelopes the core game, and nothing in between).

And then after I finish developing the core gameplay, I begin working on the main menu. And this is where I usually end up messing the code structure up. When I try to work on transitioning, the code that was anchored in to the GUI layer (the GameComponent wrapping around the main core game) now becomes hard to separate. I then have to create tons of Boolean flags, add new variables, delete some deprecated codes, and then try to mash them all up without even glancing at how the code structure should be, because I know the structure itself is in shambles from the moment I start adding in the visuals. It's really frustrating knowing that by adding in a middle layer between GameComponent and the core game, I remove the relationships between them two Objects, and tying them up with a temporary container that strings through the middle layer and connect those two Objects.

And that's not all. After stringing the middle layer in-between the two Objects, adding more core games to that mess can make the job tougher than ever. It's so messy, that I don't feel like working on it.

What do you do after that? What do you do that can prevent this from happening?
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #1 - Posted 2013-12-02 06:37:48 »

Separate menu logic from the game logic.

Usually if you plan a game out first, it becomes easier to make your game modular. I prevent making tangled messes by making sure that each of my code sections are separated into "screens". In my games, the "main menu screen" is separate from the "game screen" which is separate from the "options screen". Each one of my screen is accessible via a switch statement.

I did a lot of BASIC, where programming is a big script. If you don't separate the logic and make it easy to tell it apart, you end up with a jungle that can't be tamed.

Offline Nouht

Senior Newbie





« Reply #2 - Posted 2013-12-06 18:40:43 »

I'd use a state based method to transition. Create a super class Screen, for example, and then have you games extends from that. E.g. MarioGameScreen or DungeonCrawlerScreen etc. And in your main loop just type screen.render()  or whatever. To switch screens create a method called setScreen(Screen screen). In this method you will change your current screen (this.screen) to the new screen. You might also want to create another object called lastScreen which when the new screen is set will set the old screen to the lastScreen. Just in case you want to revert.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 65K
« Reply #3 - Posted 2013-12-06 19:21:19 »

Hard to comment without further details/examples as starting out just with core should give you pretty good preconditions for a separation of visuals and the game core.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

SHC (21 views)
2014-11-25 15:00:59

SHC (19 views)
2014-11-25 14:53:45

Norakomi (18 views)
2014-11-25 14:26:43

Gibbo3771 (21 views)
2014-11-24 22:59:16

trollwarrior1 (36 views)
2014-11-22 15:13:56

xFryIx (74 views)
2014-11-13 15:34:49

digdugdiggy (52 views)
2014-11-13 00:11:50

digdugdiggy (46 views)
2014-11-13 00:10:15

digdugdiggy (41 views)
2014-11-13 00:09:33

kovacsa (67 views)
2014-11-07 22:57:14
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-10 01:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-03 01:36:02

List of Learning Resources
by Longor1996
2014-08-16 13:40:00

List of Learning Resources
by SilverTiger
2014-08-05 22:33:27

Resources for WIP games
by CogWheelz
2014-08-01 19:20:17

Resources for WIP games
by CogWheelz
2014-08-01 19:19:50

List of Learning Resources
by SilverTiger
2014-07-31 19:29:50

List of Learning Resources
by SilverTiger
2014-07-31 19:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!