Code Snippets

TGB Level Loader

Posted by admin on March 15, 2010 at 5:38 pm

So working with a new board selection class for La Box and I came across a nice little piece of code for loading levels. This is not my code and I don’t remember whose it is but it works wonders for me.
function loadNewLevel(%levelFile, %delay)
{
// Prevents a crash
if (%delay $= “”) %delay = 100;
// If [...]

Dynamic Position Particle Effects

Posted by admin on March 10, 2010 at 7:09 pm

So when I was working on some of the power ups for La Box I needed a way to display several particle effects on the screen at the same time. So what i did was create a function to do this for me.
function CreateGroundPountEffect(%pos)
{
%particle = new t2dParticleEffect();
%particle.addToScene($sceneGraph);
%particle.loadEffect(”~/data/particles/SmokePuff.eff”);
%particle.Position = %pos;
%particle.playEffect();
}
Use this function and pass in the [...]

TGB Audio Setup

Posted by admin on March 10, 2010 at 7:06 pm

Here is a sample audio setup class for torque game builder. Simply create a new script file. Add in the following.
new AudioDescription(AudioNonLooping)
{
volume = 1.0;
isLooping = false;
isStreaming = true;
};
new AudioDescription(AudioLooping)
{
volume = 1.0;
isLooping = true;
isStreaming = true;
};
new AudioProfile(AudioSpaceBass)
{
filename = “~/data/audio/SpaceBass.wav”;
description = “AudioLooping”;
preload = true;
};
Execute the script in game.cs. then use alxPlay(AudioSpaceBass); anywhere you want to play the [...]