TGB tutorial – Stacker Clone
by Patrick - (RollerJesus) · 05/21/2009 (3:41 pm) · 8 comments
Hello GG Community,
It’s been quite a while since I’ve posted a blog but that doesn’t mean that I haven’t been busy. Quite the contrary actually... My latest work is a simple tutorial for TGB that aims to take someone from zero knowledge of TGB to a working game that is a simplified clone of the arcade hit “Stacker”. A little programming knowledge would be helpful but not necessary as I walk through every step of the process with code examples and screen shots.

When thinking about what I wanted to accomplish with this, I went through my development notebooks and looked for recurring sticking points from when I was just getting started with TGB. Many of these issues were ground floor problems that had a significant impact on my motivation for creating games with TGB as well as cutting into what little time I had to devote to learning how TGB works. Hopefully this tutorial will help someone work their way through these trouble spots in a way that hasn’t already been covered in other tutorials.
The tutorial is divided into the following section:
• Project Setup
• Importing Assets
• Scripting
The Project Setup section is brief and covers how to properly setup a project within the TGB editor with screenshots for each step of the way. Short and sweet but I found TGB a little overwhelming at first and I found that this fundamental lesson is overlooked in many of the existing TGB tutorials. Since not everyone has Torsion (even though they should…) I decided not to include setting up a Torsion project in this section but if there is interest in that, I’d be happy to provide a supplement to this on that topic.
The next section, Importing Assets, shows how to add the images to the project we just created. I walk through the process step by step, showing screenshots along the way. Pretty straightforward stuff here…
The last section is the main course of the tutorial. It’s the longest and most demanding but also the most rewarding as that’s where we make the project and the images we setup in the previous steps actually behave like a game.
In this section I cover, and briefly explain many concepts including:
•Bringing assets to the stage
•Naming assets for accessing them in script
•Creating new script files
•Global and local variables
•Functions
•Comments
•Action maps (binding commands to the keyboard)
•tileLayers
•Dynamic fields
•Timers
•General programming concepts

The tutorial can be downloaded here.
The assets used in the tutorial can be downloaded here.
A finished exampled can be downloaded here.
Special thanks to Ronny Bangsund and my wife Lyndsay for the editing help. Please let me know if you like it, hate it, found mistakes, or just want to drop me a line. Happy trails fellow TGB developers!
Oh yeah, almost forgot to harass Phil and Melv… What’s up with the new TGB? I mean, how much T3D news can we possibly take? :)
Best,
Patrick
www.bedpanmedia.com
It’s been quite a while since I’ve posted a blog but that doesn’t mean that I haven’t been busy. Quite the contrary actually... My latest work is a simple tutorial for TGB that aims to take someone from zero knowledge of TGB to a working game that is a simplified clone of the arcade hit “Stacker”. A little programming knowledge would be helpful but not necessary as I walk through every step of the process with code examples and screen shots.

When thinking about what I wanted to accomplish with this, I went through my development notebooks and looked for recurring sticking points from when I was just getting started with TGB. Many of these issues were ground floor problems that had a significant impact on my motivation for creating games with TGB as well as cutting into what little time I had to devote to learning how TGB works. Hopefully this tutorial will help someone work their way through these trouble spots in a way that hasn’t already been covered in other tutorials.
The tutorial is divided into the following section:
• Project Setup
• Importing Assets
• Scripting
The Project Setup section is brief and covers how to properly setup a project within the TGB editor with screenshots for each step of the way. Short and sweet but I found TGB a little overwhelming at first and I found that this fundamental lesson is overlooked in many of the existing TGB tutorials. Since not everyone has Torsion (even though they should…) I decided not to include setting up a Torsion project in this section but if there is interest in that, I’d be happy to provide a supplement to this on that topic.
The next section, Importing Assets, shows how to add the images to the project we just created. I walk through the process step by step, showing screenshots along the way. Pretty straightforward stuff here…
The last section is the main course of the tutorial. It’s the longest and most demanding but also the most rewarding as that’s where we make the project and the images we setup in the previous steps actually behave like a game.
In this section I cover, and briefly explain many concepts including:
•Bringing assets to the stage
•Naming assets for accessing them in script
•Creating new script files
•Global and local variables
•Functions
•Comments
•Action maps (binding commands to the keyboard)
•tileLayers
•Dynamic fields
•Timers
•General programming concepts

The tutorial can be downloaded here.
The assets used in the tutorial can be downloaded here.
A finished exampled can be downloaded here.
Special thanks to Ronny Bangsund and my wife Lyndsay for the editing help. Please let me know if you like it, hate it, found mistakes, or just want to drop me a line. Happy trails fellow TGB developers!
Oh yeah, almost forgot to harass Phil and Melv… What’s up with the new TGB? I mean, how much T3D news can we possibly take? :)
Best,
Patrick
www.bedpanmedia.com
About the author
#2
05/22/2009 (1:01 pm)
Mmmh, doesn anyone with a MAC tried to load this project? My TGB crashes when I try to load it.
#4
05/22/2009 (3:08 pm)
Latest, 1.74 Pro
#5
05/22/2009 (3:33 pm)
I have a Mac around here, I'll give it a test.
#6
Thanks for the great tutorial!!!
05/23/2009 (2:18 am)
Excellent job Patrick. This is the kind of information that us TGB folks need more of. Just a quick question and nothing I see being done wrong as far as I can tell. Why were the exec functions for executing the addtional scripts put into main.cs? Most of the tutorials show them being put into game.cs. And I'm not saying that's the wrong thing to do. I just was wondering what the thinking behind that was and I'll be honest, I would love to see a common standard being used for the tutorials instead of telling folks to do it differently each time. That would help us out more learning this program.Thanks for the great tutorial!!!
#7
To be honest, I didn't really put much thought into where I placed the exec statements. I simply searched for the exec statements that were already there...
I'd also like to be aware if there is a common standard, or if it's bad practice to put them in main.cs.
Again, thanks for checking it out!
05/23/2009 (2:40 am)
Thank Stephen, I appreciate it.To be honest, I didn't really put much thought into where I placed the exec statements. I simply searched for the exec statements that were already there...
// Load up the in game gui.
exec("~/gui/mainScreen.gui");... and lo and behold, main.cs is what came up.I'd also like to be aware if there is a common standard, or if it's bad practice to put them in main.cs.
Again, thanks for checking it out!
#8
That fixed the biggest problem. Now the game works about half the time, hehe
I went through your finished files and compared them side by side and couldn't find any thing different from my .cs files. Leads me to believe I didn't do something right inside the editor... Ah well, still learned a ton! Thank you sir!!
09/09/2009 (4:07 am)
Thanks for the tut! I had a couple issues that I was able to partially fix myself. The main one was the light wasn't displaying at all. I went through the tut a few times and switched from your completed project to my project to compare and found that you have your light sources class set to 'Light' but you don't tell us to do that in the tutorial. That fixed the biggest problem. Now the game works about half the time, hehe
I went through your finished files and compared them side by side and couldn't find any thing different from my .cs files. Leads me to believe I didn't do something right inside the editor... Ah well, still learned a ton! Thank you sir!!
Torque Owner Michael Hartlef