Program control question
by Andy Hawkins · in Torque Game Engine · 06/07/2005 (7:57 am) · 7 replies
I'm slowly working through all the mods in the forums (whats a -mod anyway? compared to a -game???) and I've started to realise I haven't even looked into program control for my game idea.
Sure I have found code to put in vehicles, weapons, particle, lightening etc, but what I want to know is how can I control all this?
How do I go about doing this program control stuff - for example using this crude pseudocode...
Start scene
Move Everything
Process AI
Do Scores
Do Sounds
Update "scripted" events (such as big robot suddenly appears from behind building)
Draw Everything
Tick Scene
End Scene
Am I supposed to do this in C++ or should I just do all this via .cs files? I'm sure someone else must have encountered this issue - maybe there's a thread someone can refer me to please?
Sure I have found code to put in vehicles, weapons, particle, lightening etc, but what I want to know is how can I control all this?
How do I go about doing this program control stuff - for example using this crude pseudocode...
Start scene
Move Everything
Process AI
Do Scores
Do Sounds
Update "scripted" events (such as big robot suddenly appears from behind building)
Draw Everything
Tick Scene
End Scene
Am I supposed to do this in C++ or should I just do all this via .cs files? I'm sure someone else must have encountered this issue - maybe there's a thread someone can refer me to please?
#2
TGE isn't a game SDK, nor is it simply an API. It's a fully functional simulation that does every single thing you mentioned for you--automatically. You don't need to do anything that you mentioned--it's too low level for common development effort, and it's already polished and taken care of for you!
Once you get used to how development works in an environment like this, you'll find yourself worrying simply about gameplay (which is good!), instead of having to worry about engine internals (which can be a huge waste of time until such time as you absolutely must change something--and 80%++ games won't ever need to do any of that).
06/07/2005 (8:38 am)
Kirk described a good startup tactic exceptionally well, so I only wanted to add one thing:TGE isn't a game SDK, nor is it simply an API. It's a fully functional simulation that does every single thing you mentioned for you--automatically. You don't need to do anything that you mentioned--it's too low level for common development effort, and it's already polished and taken care of for you!
Once you get used to how development works in an environment like this, you'll find yourself worrying simply about gameplay (which is good!), instead of having to worry about engine internals (which can be a huge waste of time until such time as you absolutely must change something--and 80%++ games won't ever need to do any of that).
#3
06/07/2005 (3:39 pm)
*sigh* back to the books then.... thanks guys :)
#4
Oh and the "scripting" bit I mentioned was about how can I make the game tick along as normal and then sequence events to happen, such as in 10 minutes a big robot appears, in 15 minutes a drop ship appears, but if you destroy the robot another appears. Is there an event handler in particular I can use that allows me to stage a lot of the action in my game in some sort of predesigned fashion?
06/07/2005 (3:42 pm)
Erm... what about staged events then? For example, first I want to do the front end screen (already done by Torque as I can see) then I want the player to pick their characters, weapons etc. Then the game proper starts(done). Then they die or win, or a cutscene is shown. How are these events handled? Neither the racing or the fps have the extra steps of cutscenes, death screens or character selection.Oh and the "scripting" bit I mentioned was about how can I make the game tick along as normal and then sequence events to happen, such as in 10 minutes a big robot appears, in 15 minutes a drop ship appears, but if you destroy the robot another appears. Is there an event handler in particular I can use that allows me to stage a lot of the action in my game in some sort of predesigned fashion?
#5
You may also want to do a bit of research on game state flow (not necessarily here on the web site) to give some thoughts on how to manage a finite state machine for your state by state flow. For example, much of your character selection prior to logging in to server, etc. is all done via guis, and state flow between them.
06/07/2005 (4:21 pm)
Research the "schedule" function, as well as how callbacks work (in the case of your destroy the robot another appears), etc.You may also want to do a bit of research on game state flow (not necessarily here on the web site) to give some thoughts on how to manage a finite state machine for your state by state flow. For example, much of your character selection prior to logging in to server, etc. is all done via guis, and state flow between them.
#6
06/09/2005 (1:38 pm)
Looking at the execute() and executef() functions in console.cc is a good place to start to understand how scripts functions are called from the codebase. A good place to see how this is used in scripting is to look in ./common/server/clientConnection.cs. In clientConnection.cs there are script side examples covering extending the engine objcects like NetObject in code and in script. Check out the script extensions to the GameConnection example game class (aka mod class). If your game paradigm is different you can also see how you can create a new one by altering the script file framework and extending the engine in code as done in the example mod classes GameConnection, GameBase, GameBaseData, etc.
#7
06/09/2005 (3:39 pm)
Excellent.... more, More, I want MORE!!!!!!
Torque Owner Kirk Haynes
Let's assume that you want to make a first person shooter game. I strongly suggest that you go through every single script file (.cs) in the 'common' folder and the 'starter.fsp' folder and subfolders. I know this seems like a lot of work, but it WILL answer your 'program control' questions and provide answers to questions that you haven't even thought to ask. It will also answer your questions about mods, and show you how the scripting setup in starter.fps is designed to work as a mod.
When you run the torqueDemo_DEBUG.exe, it will generate a console.log file. This console.log file can be your best friend while getting started. You can enter echo commands in these script files to help you trace their execution. These trace comments will be output to the console.log file. If you go into the script (.cs) files and enter code like echo( "Begin initCommon() in ./common/main.cs."); at the start of the initCommon function in the man.cs file in the common folder and echo( "End initCommon() in ./common/main.cs."); at the end of the initCommon function, these will be output in the console.log file and will help you trace the mod execution through the scripts. One note: You should close the console.log file before each execution of the game otherwise the file will not be written to and you won't see your updated echo output.
Studying the scripts will also expose you to how packages are used through a working example mod.
The scripting system can be thought of as an extention to the C++ code base. You can create C++ objects in script, extend the C++ objects in script, etc. This allows for quick prototyping of games and is a good place to start learning all of the built-in features of the engine like the GUI editor, Terrain Editor, Mission Editor, etc. There is a lot to learn so don't think you can learn it all in a weekend.
You can create a .bat file to launch whichever mod or edit the Command line field in your IDE.
A .bat file with commands could look like this:
torqueDemo_DEBUG.exe -windowed -openGL -log 6 -mod starter.fps
Using the Search feature of the website is your best tool for answering your getting started questions. Almost everything you may think of has been covered in the past 3 years in either the forums or resources.
Best Regards