Game Development Community

SOLVED: Adding new .cc files, more to it than drag and drop?

by Jonathan R Hopkins · in Torque Game Builder · 03/09/2010 (6:18 pm) · 7 replies

This has been solved. I've updated the post to clearly point out to others how to edit the source.

See "Solution" Below

So I know the solution is probably something really simple, but I've come at this from every angle I can think of and can't get it to work.

Problem: I am trying to add a .cc file to my game (this file actually: http://www.torquepowered.com/community/resources/view/10656) but when I run my game it won't acknowledge the new Console Methods.


What I did:
- I downloaded the file
- I dropped it into engine/source/T2D (I've tested it in many different locations within engine/source to no avail)
- Within Visual Studio 2008 C++ I went to (Project > Add Existing Item) and added the file.

But no matter how I play with it, it won't see the console methods.

Important note:

I have made modifications to existing engine source code (changing lines, etc.) successfully for other things, but adding an independent file like this just won't take for some reason.



So... What am I missing?

Thank you for your time.

Solution


To make changes to the TGB Source Code:


  1. Set up the compiler
  2. Update Windows SDK: Make sure your Windows SDK is up to date Windows SDK Update
  3. Update the source code: If you are using a version of Visual Studio later than 2005, you may have to upgrade the TGB code within Visual Studio. Visual Studio will automatically prompt you for this, and from my experience it should not cause any problems.
  4. Make changes: If you are simply editing files already in the source, all you need to do is edit them within Visual Studio. If you want to add new files, make sure you copy them to your source code directory (see "where is my source code" below) and (I'm not sure if this is necessary): you may need to go to (Project > Add Existing Item) to add .cc, .h files and so on. If you want to make a new script choose "Add new Item" instead. Make sure you add them to the right project. (See "Navigating the source code within Visual Studio" below)
  5. Build the solution: In Visual Studio choose (from the menu at the top) choose "Build > Build Solution" to have it build the parts you made changes to (Rebuild will rebuild everything)
  6. Copy the new executable: Once your solution is built, if you copied the executable for your game to your game's directory, you need to go into (".>tgb>gameData>T2DProject>") and copy "TGBGame.exe" to the directory for your game.

Additional notes:

  • Configuring Torsion: If you are using Torsion for your game, you have to make sure Torsion is configured to use the right file. To do this, open Torsion go to "Project > Properties" and select configurations. Then add a new configuration (or edit your default) and change the executable path to point to TGBGame.exe in your directory.
  • 64-bit Windows: If you are on a 64-bit installation of Windows, then Torque Game Builder installs by default in Program Files(x86)
  • The difference between source code and Torque code: The code you write in Torque Game Builder through Torsion or Torque Game Builder, is interpreted by the engine. The engine is made up of the source code, which you can get by getting TGB Pro. Torque code is a scripting language, making it a bit slower and less efficient in some cases, which is why some people choose to code most of their game within the source or engine.
  • Where is the source code located?: When you are making changes, most of the files you are changing are going to be in the directory wherever you installed Torque Game Builder. i.e. (X:>Program Files>Garage Games>engine>source)
  • Navigating the source code within Visual Studio: Within visual studio there are two "projects" to focus on. (See Solution Explorer on the left-hand-side) The very top of that window has the "solution" T2D SDK, then below that you have a list "glu2d3d" and so on. TGBGame is where your game runtime is, and TorqueGameBuilder refers to the interface for editing your game (Torque Game Builder itself. If you are making changes to your game, generally you need to focus on TGBGame. You'll notice the files and folders in this section pretty much correspond to the contents of the folder "engine>source" in the previous step.
  • Where is my torque script? Wherever you saved your project, look under (game > gameScripts) to find the scripts for your game. There are also some scripts under (common > gameScripts) that affect other behaviors you might not notice, but may want to change.

I think this list is fairly comprehensive and should help anyone who is confused on a Windows based machine :)

#1
03/09/2010 (10:28 pm)

Have you added it to the right project? There's two projects there that both compile Torque, one for the Builder and one for the game runtime. Maybe you have inadvertently added it to the Builder?
#2
03/10/2010 (12:25 am)
Also, if you copied the executable to your game directory and are running it from there, you'll need to copy it first from the tgb/gameData/T2DProject directory where it puts it.
#3
03/10/2010 (12:31 pm)
@ William: Aha! That was it. I had to copy the new executable over. I'm curious, I have one .exe that uses the name of my game (game.exe) and then I have the TGBgame.exe. What's the difference? Do I need both?

@ Rene: I did put in the Runtime Project (TGB Game), but thank you for pointing that out cause I wasn't 100% sure it mattered before.


#4
03/10/2010 (12:42 pm)
It's exactly the same file, just renamed. I put a post-build step in VS to copy TGBGame.exe over into my directory with my game's name. If you do that, just make sure the game isn't running when you build, because the copy won't happen. (Talk about a pain to figure out why nothing happened!)
#5
03/10/2010 (12:59 pm)
Ooh that sounds like a helpful shortcut :) And thanks for the advice.

Ps - I've updated the original post to show a detailed process for properly setting up and changing the source code.
#6
03/11/2010 (10:22 am)
We are looking for a lead programmer in a new title. Any interest?
#7
03/11/2010 (11:14 am)
@ Brian, I've emailed you about your offer.