Professional Documents
Culture Documents
)
Game Maker
) C
)
)
)
)
Torque Game Builder
$ # ) resolution
)
)
Open Project ) )
games/TutorialBase project.t2dProj
)
Resolution
#Torque Game Builder$ TGB )
:
#EditPreferences$ preferences )
Scene Editor
Sprites library
)
$ GarageGames logo # )
resolution )
resolution 800%600 )
resolution )
Scene Editor
Resolution
)
Resolution 800%600 )
resolution ) 1024%768 ) )
resolution )
GarageGames logos )
Games logos Garage )
resolution )
Camera Tool
CTRL
)
SHIFT
)
CRTL SHIFT
)
selection tool )
GarageGames logo
) )
Resolution
800%600)
10
TGB resource pack Project->Resources...
) ) resources
resources
) splite $ checkersArt #
Add To Project save )
checkersArt )
checkersArt )
11
TGB
ImageMap
) ) Animation Builder
)
imageMap ) Select )
12
)
) )
)
13
Save
Animated Sprites )
Image Map
TGB )
) imagemap
)
imagemap
( )
)
14
) camera tool
)
) Project
t2dSceneGraph )
15
16
#zoom out$ )
View )
#Scene Editor$
)
17
Edit
TGB ) 32 $ 0
# $ 31
# )
Dynamic Fields
Dynamic fields )
Dynamic
Field . )
Field Name 15 )
18
vSpeed
)
)
;%this.vSpeed = 20
)
$ scene # )
19
: )
)
20
21
TGB
) create )
Scripting Name
22
script
!
Edit)
)( echo)
Echo )
)
~ ) ) ~
)
)
24
)
;)echo("The %this object is " @ %this
)
main
) cs)
main.cs
main
Tools->Folder Options )
25
Folder Options )
View)
Hide extensions for known file types
OK )
main.cs )
New Text Document )
26
game.cs
game/gameScripts/ )
;)"exec("./aScript.cs
aScript )
Create Text Object )
) Edit ))) )
28
Collision Edit ) )
Receive Collision Send Collision
Detection mode
POLYGON )
( )
29
Collision Editor )
)
30
)
)" )"
) )
) X/Y
)
1.000 1.000 )
) )
)
)
0 )$ #
31
32
0 $ #
)
Show Convex Violations )
33
)
' 1 0 )
) 3
4 )
34
5 0 )
35
)
) )
36
) )
)
redo undo)
Display Scene Background
$ #
)
37
Particle Effect
Particle Effect )
particle Particle Effect Create )
particle )
particle Edit)
Particle
Effect )
Save Effect Load Effect
)
Edit Effect Graph effect )
38
$ effect #
time effect )
39
$ # $ #
$ # )
Current Field ) Size X
Life effect)
world limits
world limits )
)
zoom out)
) Selection toolbar
Enter )
World Limit
)
) world limit )
world limit Edit)
Limit Mode OFF ) Limit
Mode )( onWorldLimit )
Limit Mode)
:OFF )
40
Mounting
link ) link
)
)
41
Linkpoint )
) Linkpoint )
)
42
Linkpoint )
Linkpoint
)
)
Linkpoint
)
43
Linkpoint
)
Linkpoint )
44
$ Control #
$ Shift # $ Alt # )
( tilemap !)
Create)
Tilemaps Tilemaps
tilemap )
45
newLayer
46
)
)
)
file open project games\BehaviorPlayground
BehaviorPlayground )
) !
)
47
48
( Sprite)
Create )
)
edit)
) Behaviors)
49
)
)
Input Flee Mouse ' )
)
) Damping Impulse
)
50
F5 )
)
)
51
) )
documentation\content\documentation\Tutorials\Feature
)
imageMap1234ImageMap
Save )
52
53
Create a new Animation )
imageMap1234ImageMap
Use Selected
imageMap )
Animation Builder )
)
:Frames Per Second )
:Start Frame )
54
:Total Time )
:Cycle Animation
)
:Name )
)
Save)
FlourSack ) Create Create a new
Animation ) FlourSackImageMap
)
55
Save Create animated sprite
) )
56
57
CollisionTutorial
asteroid )
Edit)
Physics Constant
Force Y 40 )
) )
asteroid collision Edit
)
58
) asteroid )
collision Response ) asteroids )
collision Response CLAMP)
)
:BOUNCE )
:CLAMP )
:STICKY )
:KILL )
:RIGID )
)
59
) Edit
Debug Rendering ) Collision Bounds )
$ 'collision bounds' ) #
)
)
60
asteroid )
)
$ Edit POLYGON )#
61
asteroid
) )
62
)
) Rotation Edit
)
63
Edit
Particle
Effect )
'emitters' 'effects' ) ' 'effects
' ' 'emitters ) ''emitters
particle effect
64
newEffect ) spritenewEffect
Image particles1ImageMap )
newEffect )
& ) ''emitter
)
save
simpleExplosion.eff )
!
Graph Editor
$
! # Graph Editor
) )
Current Field emitter )
65
Size X Life ) )
)
1 0 )
) 0 Size X Life )
0,3.5 )
$ select #)
66
Graph Editor
)
)
Visibility Life ) ) )
67
Current Field
Quantity Scale )
)
Emitter
Emitter ) ) Smoke
Create Emitter Emitter )
68
Emitter
Animation
flamesAnimation ) )
emitter's graph editor Size X Base
0,5 ) Quantity Base 0, 20 Speed Base 0,
0.5 )
graph editor ) Speed Variance
0, 0.5 ) )
Visibility Life
)
69
70
path
create Path )
)
)
path )
)
Selection toolbar )
path
71
) GarageGames logo
Mount this object )
) )
) path )
)
) )
GarageGames logo Edit Pathing)
72
:Start Node )
:End Node )
Loops $ # ) -1 Loops
End Node )
:Speed )
:Move Forward )
:Orient To Path )
:Rotation Offset )
:Loops ) (1
)
:Follow Mode ) $ Wrap
$ Reverse' # )$ Restart #
)#
Path )
Path
73
Path )
:Linear )
:Bezier $
# )
:catmull )
:custom )
Path )
)
74
function t2dPath::onUpdatePath(%this,%object,%from,%to)
{
//%this is the path object.
//%object is the object following the path.
//%from is the position of the most recently passed node.
//%to is of the node being moved toward.
}
Scroller
games\TutorialBase
Scroll
) )
75
dusk_skyImageMap )
76
edit 30 )
create )
edit )
77
Resolution 1024x768
)
78
79
)
create scroller
dusk_farScrollImageMap )
80
scroller )
81
Torque
TorqueScript c++ )
)
Variables
TorqueScript ) global local local
)
local
)
local )
global )
)
;%local_var = value
;$global_var = value2
)
TorqueScript )
' )_(
)
TorqueScript '
)123 (Integer
)1.234 (floating point
)1234e-3 (scientific notation
)0xc001 (hexadecimal
82
TorqueScript )
)(string
)(tagged string
""abcd
''abcd
" " )
tagged strings
)
TorqueScript
false true)
)true (1
)false (0
true false )
83
]$MyArray[n
)(Single-dimension
)$MyMultiArray[m,n] (Multi-dimension
)$MyMultiArray[m_n] (Multi-dimension
TorqueScript
) )
)
] $MyArray[1
84
switch
switch(%val)
{
case 1:
echo(The value is 1);
case 2:
echo(The value is 2);
default:
echo(The value is something else);
}
switch$
switch$(%val)
{
case Hello:
echo(The string is Hello);
case World:
echo(The string is World);
default:
echo(The string is something else);
}
) #switch$$ #switch$
For
for(%i = 0; %i < 10; %i++)
{
echo(%i @ / @ 10);
}
85
While
;%i = 0
)while (%i < 10
{
;)echo(%i @ / @ 10
;%i++
}
%i 10 $
# %i 10 )
while %i < 10
)
" : local $
global)
()Functions
)function myFunction(%arg1, %arg2
{
;%result = %arg1 + %arg2
;return %result
}
) return
)
#return$ )
()Objects
86
Torque
t2dSceneGraph t2dSceneObject
t2dStaticSprite ) new )
)%object = new t2dSceneObject(MyObject
{
;Position = 10 10
;Size = 5 15
;Rotation = 45
;OtherField = 10
;}
t2dSceneObject MyObject
%object
) t2dSceneObject
) #10 20$ )
;)%object.setPosition(10, 20
#1010 $
x=5 ,
y=15
45 )
TGB Reference)
dynamic field
) )
()Methods
)function t2dSceneObject::move(%this, %amount
{
;)(%position = %this.getPosition
;)%newPosition = t2dVectorAdd(%position, %amount
;)%this.setPosition(%newPosition
;return %newPosition
}
87
) )
t2dSceneObjects ) %object t2dSceneObject )
)
;)%object.move(10 5
%object 10 5 x y ) %this
object )
%object ) %this
Rainy Day
)
)
88
Image
Builder)
Save )
89
Save )
90
Collision
) 16 Height Width
91
Save )
)
)
linkpoints )
92
linkpoint )
)
TGB )
93
particles
) 360 ) particles
) 0.000 0.000
particles
)
Emission Angle Base
0.000 180.000
) )
Particle Life Base 0.000 10.000
10 )
94
95
if (!isObject(MovementBehavior))
{
%template = new BehaviorTemplate(MovementBehavior);
%template.friendlyName = "Movement Behavior";
%template.behaviorType = "Movement Styles";
%template.description = "Shooter style movement control";
%template.addBehaviorField(upKey, "Key to bind to upward
movement", keybind, "keyboard up");//
96
"Speed
when
function MovementBehavior::onBehaviorAdd(%this)
{
if (!isObject(moveMap))
return;
// bind our keys to the keyboard
moveMap.bindObj(getWord(%this.upKey,0),
getWord(%this.upKey, 1), "moveUp", %this); //
moveMap.bindObj(getWord(%this.downKey,0),
getWord(%this.downKey, 1), "moveDown", %this); //
moveMap.bindObj(getWord(%this.leftKey,0),
getWord(%this.leftKey, 1), "moveLeft", %this); //
97
moveMap.bindObj(getWord(%this.rightKey,0),
getWord(%this.rightKey, 1), "moveRight", %this); //
// set the default values to 0
%this.up = 0;
%this.down = 0;
%this.left = 0;
%this.right = 0;
}
function MovementBehavior::onBehaviorRemove(%this)
{
if (!isObject(moveMap))
return;
%this.owner.disableUpdateCallback();
// remove the keybinds
moveMap.unbindObj(getWord(%this.upKey,0),
getWord(%this.upKey, 1), %this); //
moveMap.unbindObj(getWord(%this.downKey,0),
getWord(%this.downKey, 1), %this); //
moveMap.unbindObj(getWord(%this.leftKey,0),
getWord(%this.leftKey, 1), %this); //
moveMap.unbindObj(getWord(%this.rightKey,0),
getWord(%this.rightKey, 1), %this); //
%this.up = 0;
%this.down = 0;
%this.left = 0;
98
%this.right = 0;
}
function MovementBehavior::updateMovement(%this)
{
// make the player move
%this.owner.setLinearVelocityX((%this.right - %this.left) *
%this.horizontalSpeed); //
%this.owner.setLinearVelocityY((%this.down - %this.up) *
%this.verticalSpeed); //
}
function MovementBehavior::moveUp(%this, %val)
{
%this.up = %val;
%this.updateMovement();
}
99
;%this.left=%val
;)(%this.updateMovement
}
)function MovementBehavior::moveRight(%this, %val
{
;%this.right = %val
;)(%this.updateMovement
}
File Save
MovementBehavior.cs
Behaviors )
TGB
Edit Behaviors)
Movement Behavior )
!
100
)
) New File
)
if (!isObject(PlantGrowthBehavior))
{
%template = new BehaviorTemplate(PlantGrowthBehavior);
%template.friendlyName = "Plant Growth Behavior";
%template.behaviorType = "Management";
%template.description = "Controls the growth of the plants";
%template.addBehaviorField(Moisture, "", float, 10.0);
%template.addBehaviorField(minMoisture,
"The
lowest
amount of moisture for the plant", float, 0.0); //
%template.addBehaviorField(maxMoisture, "The
amount of moisture for the plant", float, 10.0); //
largest
%template.addBehaviorField(LowMoistureThreshold, "The
threshold that causes it to start growing or dying", float, 5.0); //
101
PlantGrowthBehavior.cs Behaviors
)
PlantGrowthBehavior )
102
function PlantGrowthBehavior::onAddtoScene(%this)
{
%this.dieAnim = %this.owner.getAnimation();
%j = 0;
for (%i = getWordCount(%this.dieAnim.animationFrames) - 1; %i >= 0;
%i--)//
{
%growAnim=setWord(%growAnim,%j,
getWord(%this.dieAnim.animationFrames, %i)); //
%j++;
}
%this.growAnim = new t2dAnimationDatablock()
{
animationCycle = %this.dieAnim.animationCycle;
animationFrames = %growAnim;
animationTime = %this.dieAnim.animationTime;
imageMap = %this.dieAnim.imageMap;
randomStart = %this.dieAnim.randomStart;
startFrame = %this.dieAnim.startFrame;
};
%this.owner.enableUpdateCallback();
{
) %this.dieAnim
)
) )
)
)
103
function PlantGrowthBehavior::onUpdate(%this)
{
if (%this.moisture < %this.lowMoistureThreshold)
{
104
moisture level
%this.watering
) moisture
moisture
) %this.watering
function PlantGrowthBehavior::startWatering(%this)
{
%this.watering = true;
}
function PlantGrowthBehavior::endWatering(%this)
{
%this.watering = false;
105
}
) T2DTriggerObject
Save ) Trigger
) New File
if (!isObject(WateringBehavior))
{
%template = new BehaviorTemplate(WateringBehavior);
%template.friendlyName = "Watering Behavior";
%template.behaviorType = "Trigger";
%template.description = "Defines when to begin watering";
}
function WateringBehavior::onEnter(%this, %object)
{
%object.startWatering();
}
function WateringBehavior::onLeave(%this, %object)
{
%object.endWatering();
}
) WateringBehavior.cs ) watering
Project -> Reload Project TGB ) update
) particle effect )
particle effect
)
106
Create Trigger )
Mount this object to another object
) )
Trigger
Behavior Edit
Watering
Trigger
Behavior ) )
Leave Callback )
107
Trigger ! $
# )
)
108
Paste Copy
) )
)
: Shooter
player's ship )
)
)
)
109
:
)
Camera Tool )
zoom out
)
CTRL ) )
110
Selection
)
111
)
sky )
)
! )
30 )
112
113
$ # )
)
)
Scripting Edit )
Class Name
) name ' )
class ) Name pShip
Class playerShip )
114
)
) )
" * games/ * " /gameScripts )
game.cs )
script ) text
player.cs ) .cs )
)
: //
)
115
%this )
s, d )
)
116
w, a,
)
true updateMovement(), )
)( updateMovement 8 )
117
118
player.cs
) )( startGame game.cs )
;)"exec("./player.cs
player.cs )
player.cs updateMovement
)
;) %this.setLinearVelocityX( $pShip.hSpeed
;) %this.setLinearVelocityY( -$pShip.vSpeed
vSpeed velocity )
Dynamic Fields edit)
) hSpeed 100
vSpeed 80 )
119
)
)
) world limits ) world limits)
120
CLAMP )
world limit
) Create enemy ship )
121
TGB )
800x600 TGB
) TGB
800x600
)
)
)
Edit eShip enemyShip ) gameScripts
text enemy.cs
)
122
enemy.cs )
minSpeed
maxSpeed x )
dynamic fields )
)
gameScripts game.cs
;)"exec("./player.cs
;)"exec("./enemy.cs
enemy.cs )
123
dynamic fields
maxSpeed minSpeed )
(175
(255 )
) )
)
!
#spawn$ )
)
world limit ) world limit
)
124
)
world limit )
maxY minY )
dynamic fields ) Y
Y )
Y Scene Object )
125
) enemy.cs
{
%this.enemyMovement();
}
%this.startX = %this.getPositionX();
) X
)
) world limit
function enemyShip::spawn(%this)
{
%this.setLinearVelocityX(getRandom(%this.minSpeed, %this.maxSpeed));
%this.setPositionY(getRandom(%this.minY, %this.maxY));
%this.setPositionX(%this.startX);
}
127
#spawn $
maxSpeed minSpeed )
Y maxY minY
x )
)
)
)
) x $
# )
) )
dynamic field missileSpeed 1000 )
)
) '
TGB
player.cs
gameScripts ) onLevelLoaded )
) createMissile space
) createMissile
function playerShip::createMissile(%this)
{
%this.playerMissile = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = playerMissile;
missileSpeed=%this.missileSpeed;
player = %this;
};
%this.playerMissile.fire();
}
)
) ) scenegraph
) playerMissile
)
playerMissile.cs gameScripts
)
function playerMissile::fire(%this)
{
%this.setWorldLimit( kill, "-85 -115 155 50" );
%this.setLinearVelocityX(%this.missileSpeed);
%this.setPosition(%this.player.getPosition());
%this.setImageMap(playerMissileImageMap);
%this.setSize(12, 2);
129
world limit
world limit )
missileSpeed
) )
) )
) 12 2 )
) collision physics collision callbacks
)
130
enemyShip
explode )
)function playerMissile::explode(%this
{
;)(%this.safeDelete
}
)
explode
) enemy.cs )
)function enemyShip::explode(%this
{
;)(%this.spawn
}
game.cs ) $
#
;)"exec("./player.cs
;)"exec("./enemy.cs
;)"exec("./playerMissile.cs
131
Collision Poly )
selection )
edit Collision ) )
132
)
!
)
)
edit
133
Collision
( 500 ) missileSpeed
)
gameScripts
)
) ) enemy.cs
function enemyShip::fireMissile(%this)
{
%this.enemyMissile = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = enemyMissile;
missileSpeed = %this.missileSpeed;
enemy = %this;
};
134
%this.enemyMissile.fire();
}
)
) fireMissile ) fire
) )
) enemyShip::spawn()
function enemyShip::spawn(%this)
{
%this.setLinearVelocityX(getRandom(%this.minSpeed, %this.maxSpeed));
%this.setPositionY(getRandom(%this.minY, %this.maxY));
%this.setPositionX(%this.startX);
%this.fireMissile();
}
)
)
playerMissile enemyMissile.cs gameScripts
)
function enemyMissile::fire(%this)
{
%this.setWorldLimit( kill, getWords(%this.enemy.getWorldLimit(), 1, 4) );
%this.setLinearVelocityX(%this.missileSpeed);
%this.setPosition(%this.enemy.getPosition());
%this.setImageMap(enemyMissileImageMap);
%this.setSize(12, 2);
%this.setCollisionActive( true, true );
%this.setCollisionPhysics(false, false);
%this.setCollisionCallback(true);
135
}
' fire enemy.cs ) playerMissile
) world limit
world limit )
' )
onCollision ) )
)
)function enemyMissile::explode(%this
{
;)(%this.safeDelete
}
)
) player.cs )
136
) player.cs
) )
) player.cs onLevelLoaded
! false
createMissile
)
)
function playerShip::createMissile(%this)
{
%this.playerMissile = new t2dStaticSprite()
{
137
scenegraph = %this.scenegraph;
class = playerMissile;
missileSpeed=%this.missileSpeed;
player = %this;
};
%this.playerMissile.fire();
}
function playerShip::createMissile(%this)
{
if(!%this.isDead)
{
%this.playerMissile = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = playerMissile;
missileSpeed=%this.missileSpeed;
player = %this;
};
%this.playerMissile.fire();
}
}
)
)
)
138
onCollision
) isDead true)
true )
)( explode )
)function playerShip::explode(%this
{
;%this.isDead = true
;)%this.setEnabled(false
;)"%this.schedule(2000, "spawn
}
isDead false ) )
startY startX ( )
) startY startX )
player.cs onLevelLoaded ) )
)function playerShip::onLevelLoaded(%this, %scenegraph
139
{
//set the player's ship name to the instance
$pShip = %this;
%this.isDead = false;
//These commands bind our keys to our functions
moveMap.bindCmd(keyboard, "w", "pShipUp();", "pShipUpStop();");
moveMap.bindCmd(keyboard, "s", "pShipDown();", "pShipDownStop();");
moveMap.bindCmd(keyboard, "a", "pShipLeft();", "pShipLeftStop();");
moveMap.bindCmd(keyboard, "d", "pShipRight();", "pShipRightStop();");
moveMap.bindCmd(keyboard, "space", "$pShip.createMissile();", "");
}
) isDead
startY startX
)
) onLevelLoaded
140
%this.isDead = false;
exec("./player.cs");
exec("./enemy.cs");
exec("./playerMissile.cs");
exec("./enemyMissile.cs");
)
) )
)
141
particle
)
Edit Particle Effects )
142
particle effects
'
)
)
)
143
)
Edit particle effect )
! particle builder)
144
particle builder )
)
emmiter emmiter ) Emitter Graph )
Size X Life )
'
!
145
mount point )
) )
player.cs )( explode )
explode )
)function playerShip::explode(%this
{
;%this.isdead = true
;)%this.setEnabled(false
;)"%this.schedule(2000, "spawn
}
explode )
146
function playerShip::explode(%this)
{
%this.isdead = true;
%explosion = new t2dParticleEffect()
{
scenegraph = %this.scenegraph;
};
%explosion.loadEffect("~/data/particles/big_explosion.eff");
%explosion.setEffectLifeMode("KILL", 1);
%explosion.setPosition(%this.getPosition());
%explosion.playEffect();
%this.setEnabled(false);
%this.schedule(2000, "spawn");
{
explode
enemy.cs
)
function enemyShip::explode(%this)
{
%explosion = new t2dParticleEffect()
{
scenegraph = %this.scenegraph;
};
%explosion.loadEffect("~/data/particles/big_explosion.eff");
%explosion.setEffectLifeMode("KILL", 1);
%explosion.setPosition(%this.getPosition());
%explosion.playEffect();
147
;)(%this.spawn
}
)
)
)
edit Mounting )
148
149