Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
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 1709 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.

Lethal Running - a RPG about a deadly game show held in a futuristic dystopian society.
Pages: [1]
  ignore  |  Print  

EgonOlsen (78 views)
2018-06-10 19:43:48

EgonOlsen (58 views)
2018-06-10 19:43:44

EgonOlsen (78 views)
2018-06-10 19:43:20

DesertCoockie (260 views)
2018-05-13 18:23:11

nelsongames (158 views)
2018-04-24 18:15:36

nelsongames (157 views)
2018-04-24 18:14:32

ivj94 (898 views)
2018-03-24 14:47:39

ivj94 (162 views)
2018-03-24 14:46:31

ivj94 (811 views)
2018-03-24 14:43:53

Solater (175 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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‑
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!