Game Development Community

dev|Pro Game Development Curriculum

Showing Bare Bones for Torque 1.4

by Anders Dahnielson · 12/30/2005 (1:32 pm) · 5 comments

I've decided to use this space on GG to chronicle my endeavours into game making as a TGE n00b. It will probably not be very novel. Just a diary over what I've done, how I'm thinking and what I'm aiming for.

Introduction

After having fixed the file system bug on Linux and compiled the TGE demo binary without file redirection enabled (see previous post for details) I was finally ready to create the base my game prototype could be built upon.

I'm no expert in Torque, scripting or modding. This is just a description of my own dabblings in creating a minimal bare bone framework to use as a starting point. So I will at this point subtract more than add to the project. I start by creating a brand new project directory and then copy all the necessary files over from the SDK's example directory, then modify and remove files from the copy.

Copying All We Need

Start by creating a directory for the project. All the files and folders we need to copy do we find in the SDK's 'example' directory.

* First we need to copy our compiled Torque binary and any necessary support libraries to our project.

* Next copy the 'common' directory and all its subdirs.

* Do the same with the 'creator' directory.

* And likewise with the 'tutorial.base', but rename it to 'game'.

* Finaly copy the 'main.cs' from the 'example' dir to our project dir.

What All That Stuff Was

A quick run through...

* The 'common' directory contain commonly shared code implemented in TorqueScript that your game and the TGE editors can use. We copy it since the editors need it, but we are free to ignore it and implement our own version of the functions we may need in our game code. (The reason for that is so we can drop in an updated version of the 'common' without having to merge it with our own modified code.)

* The 'creator' directory contain all the editors we need to create a game. Just like with the 'common' we do not have to ship it with our game.

* The 'game' directory will contain all code and resources for our game. It will contain all the files we will create or modify. This is the directory you should concentrate on exploring.

Big Ol' Main Entrance

When running the Torque binary it will look for a script called 'main.cs' in the directory the binary was executed from. That script is responsible for initialising, executing all the necessary script and setting up the engine.

I will reuse the regular 'main.cs' script and just change the folowing line...

$defaultGame = "demo";

...to read...

$defaultGame = "game";

Well, that's all for now. You can remove all the add mod and game stuff from the command line processing if you like. But that's kinda handy to keep around.

Fixing the Default Mission

Modify the 'game/main.cs' file and change the line...

$Editor::newMissionOverride = "tutorial.base/data/missions/flat.mis";

...in the onStart function to read...

$Editor::newMissionOverride = "game/data/missions/flat.mis";

So that it will find the default mission that we will use as a starting point for all the other missions we will create.

Fixing the Console Key Binding

I've seen that more people than I had problem toggling the console. The regular tilde keybinding may be alright on a US_en keyboard but on other layouts it won't work.

So find the following line in 'game/client/default.bind.cs'...

GlobalActionMap.bind(keyboard, "tilde", toggleConsole);

...and change it to something like...

GlobalActionMap.bind(keyboard, "alt backspace", toggleConsole);

Now I can press Alt + Backspace to toggle the console.

The Game File Hierarchy

Here's an overview of the current directory layout in 'game':

/game
  /client               -- all the client side scripts
    /ui                 -- all gui definitions
      /buttons          -- bitmaps for the bitmap buttons
  /data                 -- contain all game data
    /interiors          -- all the DIF files and their textures
    /missions           -- all the mission files and their terrain height maps
    /shapes             -- all the objects in a scene and their associated files
      /3dtorquelogo
      /markers
      /particles
      /player
    /skies              -- textures for the skies
    /sound              -- sound effect files
    /terrains           -- terrain textures
    /water              -- water textures
  /server               -- all the server side scripts

Ok, as you already may know the game is split up into three parts: client, server and data. The splitting the code into a client and server part is obvious if you doing a multiplayer game (and when running a dedicated server there's no need to run the client part), but it can be a good design decision even for a single player game to split it up as well.

The data part contain all the game resources, missions (TGE's name for "levels"), terrain height maps, textures, 3d objects and animations (you name it...)

Gentlemen, Start Your Engines!

Now let us start it up and see if it works (well, it is supposed to work). If you want you can continue by following the GettingStarted.pdf tutorial, or read on if you already familiar with the editors.

Cleaning Up All The GUI

When starting up the game you're presented with the main menu of the Tutorial Base. Let's start by cleaning it up. Hit F10 to enter the GUI editor.

Start by removing the gray bar an all the buttons at the top and the RSS feed displays at the bottom. We leave the background as-is, it's nice until you have some game specific background image to replace it with.

Now create two new regular GuiButtonCtrl buttons, one which says "Exit" and trigger the "quit();" and another that says "Options" and trigger "Canvas.pushDialog(optionsDlg);". And save the GUI as 'mainMenuGui.gui'.

Click on the "Options" to make sure it works, then do the same with "Exit"...

To really get rid of the RSS feed stuff open up 'game/client/ui/mainMenuGui.gui' in a text editor and remove everything below the '//--- OBJECT WRITE END ---' line.

We continue our "Operation: Clean GUI" by removing the following files:

* game/client/ui/gameonebg.jpg
* game/client/ui/gray_bar.png
* game/client/ui/buttons/*

The ui directory should now contain the minimal GUI:

* background.png -- the background image
* loadingGui.gui -- the screen for loading missions
* mainMenuGui.gui -- the main menu
* optionsDlg.gui -- the options dialog
* playGui.gui -- the game play gui

Data

Actually we won't remove any of the data since it doesn't matter that much what we keep. Some of the stuff can come handy as stand-in objects and textures. For the first time we're actually ready to add stuff. Start adding terrain textures you've created or downloaded that you think you'll need, start adding interiors you've built and start adding objects to populate your world with.

Conclusion

As promised this entry haven't contained anything novel. But it's my first step to create a game prototype. Next I will add some content to play with, create some new missions and finally start groking the TorqueScript code.

About the author

Bought his Torque Game Engine license in April 2004 and then pursued to not make very much with it.


#1
12/30/2005 (1:48 pm)
While this can be useful to a new user, this seems to be a nice article to write to TDN rather than a .plan, IMO.
#2
12/30/2005 (4:04 pm)
Yes, but this step isn't very novel and cover the same basics as the GettingStarted.pdf. Guess I can edit everything together and post something on TDN when I've written more installments of my strugles. But my .plan ;-D is to post entries here about what I've done to track the development of my game prototype.
#3
12/30/2005 (6:59 pm)
@Anders Dahnielson

I LOVE this!! Please keep this up! It's great. And I think it would make a fantastic noob's guide to torque when you are done.

What I like best is how you have not just spelled out how to do stuff with torque, but that you have taken it a further step and shown how you have changed things in torque. I find this really helpful to understanding how torque works since I can compare what was original to what you have changed it to. This is a great things for people who don't just want to get torque to do what they want, but also want to understand what torque is doing.

Can't wait for the next noob plan. :P Great job!!
#4
12/31/2005 (12:50 am)
Anders,

Fantastic plan. Keep this up and you'll be giving Ed Maurina a run for his money. (Well, you might have to do it for a few years to get to where he is... :P)

When this series is finished, I'd love to see it on TDN, too!

Great work!

Ben
#5
12/31/2005 (10:26 am)
Anders,

This is fanatastic for all us n00b's just getting into TGE. I purchased TGE in October and have been spending any time I can spare learning this behemoth. I had the same thoughts of sharing my experiences/frustrations of learning TGE but through my procrastination is seems you beat me to it. Now it would just be passe' .

I am currently experimenting with marble physics and it is a REAL learning experience for me.

Thanks for providing a source of learning/inspiration for all of us! Keep up the great work