13.Feb.07 Lecture 3.
Gui Builder and Full Circle Games with Torque Game Builder

Final Projects and Contest

Only 84 Days Remaining - How far along are you? I estimate it will take you 20 full days to create a real game. Don't wait until the last week, start planning now.

Why are you here?

Do you want to be a game developer and create games?

Do you love to make games?

Ask yourself if you really love to make games?

Now ask yourself how much time you spent over the past week creating games? Do your actions match up with your words or are you just trying to get a passing grade in this class and say you are a game developer? The passing grade is easy, creating real games is going to take a serious time commitment. You should be working towards your final game project every day of this semester. Actions are the REAL you.

Now, wouldn't it be nice to be in the final week before the contest and already having a complete game , you are adding a small obscure feature to the interface? Or would you rather be putting in all nighters the last week frustrated by easy bugs and stressed about the deadline? Which game do you think is going to be better under those conditions?

Complete the Shooter Tutorial

After ten students are complete, we will move on. If you are one of the ten early finishers, please help another student so we can create more games.

Full Circle Games

So far all the tutorials have done is show us how to create a simple game mechanic, not a full game. As we talked about before, the purpose of this class is to create full circle games. Meaning, they have to have a splash screen, a main menu, and a game mechanic that returns to the main menu. It should also have an installer and we will discuss that later in the semester. Without those elements we are not creating games! We need to think about that stuff up front as that is where a significant amount of the time developing the game will be spent.

Splash Screens

Think of the various moments of the game as modes like Splash, Main Menu, Play, Game Over. This could also be called a State and understood from mathematics using Finite State Machines. The way to move from one 'mode' to another in TGB (and TGE) is using levels. We will have a level for our splash screen, a level for our main menu and a level for our individual game levels.

We will start with a splash screen that moves directly into the games we have already been creating. This could be one of the tutorials, or a game of your own construction. First create a new level and add some items on the splash screen. Give one (and only one) of the items the class name of: SplashTitle

Next add the following code to the game.cs file, or a splash.cs file that is exec'd inside the game.cs file.

 

function SplashTitle::onLevelLoaded(%this,%sceneGraph)
  {
  // schedule something 2 seconds out
  %this.timerschedule = %this.schedule(2000, "endSplash");
  }

function SplashTitle::endSplash(%this)
  {
  %sg = %this.getSceneGraph();
  echo("loading level after splash sg=" @ %sg);
  %sg.loadLevel("MyGame/data/levels/firstlevel.t2d");

  // in reality, firstlevel should probably be a main menu
  // since that is where you want to go after the splash
  }

This code will execute with the level is loaded and create a single timer that lasts 2 seconds (2000 milliseconds). When the time is up, it will call the method endSplash. The endSpash method will load the first level and the game will begin. The splash should really load a main menu level, but we will be building that next.

GUIs

Remember the F10 key I warned you about last week. The GUI is one of the most confusing parts of the Torque Engine and doesn't seem to be well documented. The best place to start is by adding a score and time GUI to your existing game level. Use this tutorial.

http://tdn.garagegames.com/wiki/TGB/MiniTutorials/GUIScoreAndTime

Wood's cheatsheet for creating a popup GUI

File/New GUI

Select GUI Control in tree view

Chanage profile to: GuiModelessDialogProfile

Select New Controle/Gui Control

Change Gui Control profile to GuiWindow

Right click on the Gui Control to give it yellow outline, subsequent adds will add the obejct to the GuiControl

Items of interest: GuiTextCtrl and GuiButtonCtrl

What are GUI files?

Try opening a GUI file with a text editor. They are located in games/gamename/gui.

Notice that this file is just a bunch of Torque Script. You could easily create and modify this file using a text editor. This could be useful when making small changes to the file.

To multi-file or not to multi-file

Most of the tutorials have you creating multiple files to store your scripts in. They are usually stored by level or object type. Is this really necessary?

The answer is no, it is not necessary. You could easily keep all of your scripts in the game.cs file. Many would argue that this is not good coding practice, but I don't think it's good development practice on small applications. I'm going to suggest you keep everything (organized similar use code together in the same area) in the game.cs file until the file reaches more than 1000 lines. Once it starts getting bigger, take one of the larger sections out and place it in a separate file. Having all of your code in one file will increase your development time.

Before you release a real game I would also suggest that you separate out all your code into separate files. Returning to a game you have not worked on in months or years will probably be easier to understand if it is organized by file.

I will try and maintain a good file separation by functionality, but you are welcome to put all you scripts in the game.cs file as long as you keep the different types of code well separated.

Creating and importing art for a splash screen

Paint Shop Pro overview.

Springer Sample

A full circle game example called Springer. Not much of a game, but shows the full cycle in action.

Gui Tutorials

There are three great tutorials on tdn mini-tutorials website.

Your First Gui

Score And Time Gui

Main Menu With Simple Buttons

CPSC240 - Games Development
Chapman University
Instructor: W. Wood Harter
(c) copyright 2006-2007 - W. Wood Harter - All Rights Reserved
Screen shots on banner (c) copyright their resprective owners