Game Development Community

Script/directory structure "best practices"?

by Nicolas Stohler · in Torque Game Builder · 03/27/2006 (1:42 am) · 2 replies

Hello

I did the spaceshooter tutorial a few weeks ago. then i moved to a new house and had little to no time to spend with TGB.

but now i really want to get into it. so I wondered if there are some "best practices"/guidelines on how to create an efficient and maintainable directory/script structure.

- how many main.cs do I really need?
- what default initialisations should I make first?
- how do I modularize my code efficiently with torqueScript (I'm a C++ programmer)?
- where to put all my game art/levels/sound effects?
- is there a torquescript editor that you can recommend?

I mean, basically a game starts, displays a first menu (play, options, ...) and then starts the game-part (+options in pause menu). an option to quit is also needed I think ;-)
so, is there some "reference model" or sample that I should start from?

It's my first TGB game I'm making, I've got lots of ideas in my head (and on paper) and really want to get things running so I can verify what works and what doesnt so I can refine my core gameplay.

thanks

#1
03/27/2006 (2:09 am)
Quote:
- what default initialisations should I make first?
Default initialisations are all already done before your first script is called, so you only need to worry about your own initialisations.

Quote:
- where to put all my game art/levels/sound effects?
If you have the latest version (TGB 1.1 beta 2) there already is a directory structure that makes much sense.

Quote:
- is there a torquescript editor that you can recommend?
I used netMercs CodeWeaver but it often crashed so switched back to jEdit + TIDE plugin. Take a look here:tdn.garagegames.com/wiki/TorqueScript/IDE/Guide

Quote:
I mean, basically a game starts, displays a first menu (play, options, ...) and then starts the game-part (+options in pause menu). an option to quit is also needed I think ;-)
so, is there some "reference model" or sample that I should start from?

It's not a reference model but I can tell you how I do it. I use "game states" to control the games flow. I have the game states "main menu", "overworld map", "level", "in game options screen", and so on. Every one of them is a scriptObject and has got four methods:
- initialize()
- wake(%pars)
- sleep(%pars)
- shutDown()

Initialize() and shoutDown() are called on creation and destruction to setup everything needed and then clean up again. wake() does everything necessary when you switch to a game state and sleep() does everything necessary when switching away from it.

Then there is a function setGameState(%newGameState, %wakePars, %sleepPars) that calls the above methods appropriatly. This way you can switch between main menu, in-game sequences, option screens in a organized and clean way. You just have to make sure that wake() and sleep() don't make any assumptions which state preceeded/is following (or convey this via %pars).

-Michael
#2
03/27/2006 (2:47 am)
Thanks a lot for the response. I have to download the latest version and check on the dir structure then.
I was thinking of using game states too, now I know I'm going to use them in a similar way you are using them. can't wait to get home and start coding!