Be a Supporter!

Questions about game structure.

  • 179 Views
  • 10 Replies
New Topic Respond to this Topic
Barzona
Barzona
  • Member since: Jan. 4, 2009
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Questions about game structure. 2013-08-10 14:26:39 Reply

I'm about to get into building levels, stages, etc.. The framework for the whole game, really.

What I want to know is, what is the best way to create different levels and in what scope to build them in? Is this where the main timeline will start to come in handy? Should I just put the preloader in the first frame, the main menu on the second frame, and the rest of the levels in all consecutive frames?

If the best way is to just keep everything on a single frame, I imagine there will be a lot of removing/adding objects dynamically every time I change a level. In that case, should I work with single "level containers" that I can just remove when the stage changes? That would take everything that's in the container with it, right?

Any advice on structuring a game will be appreciated.

nitokov
nitokov
  • Member since: May. 8, 2012
  • Offline.
Forum Stats
Member
Level 05
Programmer
Response to Questions about game structure. 2013-08-10 17:00:49 Reply

At 8/10/13 02:26 PM, Barzona wrote: Any advice on structuring a game will be appreciated.

hmmm, maybe start here: http://www.kongregate.com/forums/4-game-programming/topics/3 38054-deeper-topic-part-1-a-criticism-of-oop-in-game-develop ment


RangeError: Error #1125: The index 4 is out of range 4.

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Offline.
Forum Stats
Supporter
Level 16
Game Developer
Response to Questions about game structure. 2013-08-10 17:39:34 Reply

You'd have to rewrite a ton of code in each frame if you had one per level. You can have a level mc with a linkage name that you add and remove when needed. Or you can construct the level by specifying where things go in the code or an external text file.

Barzona
Barzona
  • Member since: Jan. 4, 2009
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to Questions about game structure. 2013-08-11 00:50:45 Reply

At 8/10/13 05:39 PM, MSGhero wrote: You'd have to rewrite a ton of code in each frame if you had one per level. You can have a level mc with a linkage name that you add and remove when needed. Or you can construct the level by specifying where things go in the code or an external text file.

Wait, rewrite code in each frame? I'm using a Document class, though. There wouldn't be any code on each frame other than maybe "stop();". I was wondering if even after using external flash files if changing the frame on the main timeline would throw anything off.

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Offline.
Forum Stats
Supporter
Level 16
Game Developer
Response to Questions about game structure. 2013-08-11 01:07:30 Reply

At 8/11/13 12:50 AM, Barzona wrote: Wait, rewrite code in each frame? I'm using a Document class, though. There wouldn't be any code on each frame other than maybe "stop();". I was wondering if even after using external flash files if changing the frame on the main timeline would throw anything off.

I'm confused at what you're actually doing, but don't use multiple frames.

nitokov
nitokov
  • Member since: May. 8, 2012
  • Offline.
Forum Stats
Member
Level 05
Programmer
Response to Questions about game structure. 2013-08-11 01:42:41 Reply

At 8/11/13 12:50 AM, Barzona wrote:
At 8/10/13 05:39 PM, MSGhero wrote: You'd have to rewrite a ton of code in each frame if you had one per level. You can have a level mc with a linkage name that you add and remove when needed. Or you can construct the level by specifying where things go in the code or an external text file.
Wait, rewrite code in each frame? I'm using a Document class, though. There wouldn't be any code on each frame other than maybe "stop();". I was wondering if even after using external flash files if changing the frame on the main timeline would throw anything off.

If you are making game in Flash pro IDE then you might whant to have "Level" movieclip and put level per frame. I would never to it like that, but i guess you are more artist than programmer so that could do the trick. Then you just call gotoAndStop(levelnumber). You dont have to remove old level and add new one every time.


RangeError: Error #1125: The index 4 is out of range 4.

Sam
Sam
  • Member since: Oct. 1, 2005
  • Offline.
Forum Stats
Moderator
Level 19
Programmer
Response to Questions about game structure. 2013-08-11 01:58:52 Reply

At 8/10/13 05:00 PM, nitokov wrote:
At 8/10/13 02:26 PM, Barzona wrote: Any advice on structuring a game will be appreciated.
hmmm, maybe start here: http://www.kongregate.com/forums/4-game-programming/topics/3 38054-deeper-topic-part-1-a-criticism-of-oop-in-game-develop ment

Really good read, thanks for posting.

Barzona
Barzona
  • Member since: Jan. 4, 2009
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to Questions about game structure. 2013-08-11 03:01:43 Reply

At 8/11/13 01:42 AM, nitokov wrote: If you are making game in Flash pro IDE then you might whant to have "Level" movieclip and put level per frame. I would never to it like that, but i guess you are more artist than programmer so that could do the trick. Then you just call gotoAndStop(levelnumber). You dont have to remove old level and add new one every time.

Hmm, okay. I guess I can arrange a class to handle transitions between levels. I can add something like "levelContainer" whenever a level starts and then just add my main character, enemies, backgrounds, etc to that. When the level ends, I can just remove that "levelContainer" and re-add it when the next one starts. The class will be able to handle the structure and specific components of each level. How does something along those lines sound?

I'm only on part 2 of the link he shared, but part 1 definitely sounded like some of what I am doing. The stuff he said about poor structure.. =/

Barzona
Barzona
  • Member since: Jan. 4, 2009
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to Questions about game structure. 2013-08-11 03:05:09 Reply

At 8/11/13 01:07 AM, MSGhero wrote:
At 8/11/13 12:50 AM, Barzona wrote: Wait, rewrite code in each frame? I'm using a Document class, though. There wouldn't be any code on each frame other than maybe "stop();". I was wondering if even after using external flash files if changing the frame on the main timeline would throw anything off.
I'm confused at what you're actually doing, but don't use multiple frames.

Just trying to figure out how I'm going to structure different transitions in a game. Transitioning between levels, menus, cut scenes, etc. I was thinking at first that using each frame on the main timeline as a means to organize the different levels would work, but after reading, it now sounds like a poor idea. Now, I'm mulling over just creating a structure for the different levels purely dynamically. I need to figure out a good way for me to do that.

MSGhero
MSGhero
  • Member since: Dec. 15, 2010
  • Offline.
Forum Stats
Supporter
Level 16
Game Developer
Response to Questions about game structure. 2013-08-11 03:48:09 Reply

At 8/11/13 03:05 AM, Barzona wrote: Just trying to figure out how I'm going to structure different transitions in a game. Transitioning between levels, menus, cut scenes, etc. I was thinking at first that using each frame on the main timeline as a means to organize the different levels would work, but after reading, it now sounds like a poor idea. Now, I'm mulling over just creating a structure for the different levels purely dynamically. I need to figure out a good way for me to do that.

For my iso rpg, I have a...system (idk what it is but it works so who cares). I have level data in some xml, like where everyone goes and their stats and all. Then I have a state manager class. I call swapStates() which will remove the current state and add/construct the new one. Like from cutsceneState to battleState. swapStates is like:

fademanager.fadeOut() // a transparent sprite is on top of everything, fades to black when called

currentState.exit() // callback when the fade is over
currState = nextState
nextState.enter()
fm.fadeIn()

Exit removes all the unnecessary stuff that hangs around in memory. Enter constructs the level (adds tiles, places units, etc). In enter, it finds the proper xml data then loops through everything to build the level.

nitokov
nitokov
  • Member since: May. 8, 2012
  • Offline.
Forum Stats
Member
Level 05
Programmer
Response to Questions about game structure. 2013-08-11 05:27:26 Reply

At 8/11/13 03:05 AM, Barzona wrote:
At 8/11/13 01:07 AM, MSGhero wrote:
At 8/11/13 12:50 AM, Barzona wrote: Wait, rewrite code in each frame? I'm using a Document class, though. There wouldn't be any code on each frame other than maybe "stop();". I was wondering if even after using external flash files if changing the frame on the main timeline would throw anything off.
I'm confused at what you're actually doing, but don't use multiple frames.
Just trying to figure out how I'm going to structure different transitions in a game. Transitioning between levels, menus, cut scenes, etc. I was thinking at first that using each frame on the main timeline as a means to organize the different levels would work, but after reading, it now sounds like a poor idea. Now, I'm mulling over just creating a structure for the different levels purely dynamically. I need to figure out a good way for me to do that.

but for example, if you would use famous blitting for rendering background (good for preformance) you could just change source bitmapdata for different level, thats best what i can think of.


RangeError: Error #1125: The index 4 is out of range 4.