TGB/Tutorials/Fill Battle/The Engine That Could

From TDN

This page is a Work In Progress.

Contents

Engine Tip

I considered myself highly proficient in C++ when I first looked at the TGE in 2001. I'm still finding out cool things the engine can do. When looking at the code, remember these two things:

  1. Don't let the code intimidate you.
  2. Nothing is magic. If you can't tell where something is happening, you just need to search deeper.

The Engine That Could

Run Visual C++ 2008 Express Edition.

File -> Open Project/Solution... Browse to c:\Torque2D\FillBattle\engine\compilers\VisualStudio 2008.

Rename T2D SDK.sln to FillBattle.sln. Open FillBattle.sln.

"TorqueGameBuilder" will be bolded in the "Solution Explorer" (typically on the left) to show it as the main project. Right click on "TGBGame" and select "Set as StartUp Project". Now, if you need to debug, this will be the main project.

At the top of the screen you’ll see "Debug". Change this to "Release". These are configurations set up by Garage Games. Unless you run into a bug, you’ll always use "Release".

Browse the menus to Build -> Build Solution. This will take a while, but it’s re-building the entire engine.

After it’s done, look in your tgb directory. You’ll see that TorqueGameBuilder.exe has the current date and time. Success! Unfortunately, the game is in tgb/gameData/T2DProject as TGBGame.exe. To automatically get this into your game, let’s add a post-built step:

Right-click on TGBGame in the "Solution Explorer" and select "Properties". Expand to Configuration Properties -> Build Events -> Post-Build Event. In Command Line, click the little "..." and type in the following as a single line:

copy c:\Torque2D\FillBattle\tgb\gameData\T2DProject\TGBGame.exe c:\Torque2D\FillBattle\games\FillBattle\FillBattle.exe

NOTE: Remember to use your paths.

Because the post-build event doesn’t force anything to re-build, we need to do something just this once. Under TGBGame, open the folder "game" and the file "main.cc". Erase any character and replace it.

Build -> Build Solution.

Now, if you go to FillBattle\games\FillBattle, you’ll see the new executable with the current date and time. The copy was a success!

Image:Alert.png WARNING!

HUGE WARNING! You cannot be running your game when you build or the copy will not happen! If this happens, you’ll need to modify a file (add a space and then delete it). This will force the engine to rebuild and the post-build copy will then happen.

Image:Alert.png WARNING!

HUGE WEIRDNESS! Sometimes the build will fail, but not in the code. Just try rebuilding… it almost always works.

Your Biggest Friend

The find-in-files search will be your biggest friend. Ctrl-Shift-F. Abuse it.

Change the "Look in:" to be "Current Project". Try searching for "t2dVectorAdd" and double-click on the search result for the ConsoleFunction. You may not understand the magic there now, but you will very soon!


Complete!

Return to the Fill Battle Home!