Game Development Community

Tutorial Disparity Dilemma

by Aaron Moore · in Torque Game Builder · 04/25/2006 (6:48 am) · 8 replies

Tutorials say game.cs should look like this:

function setupT2DScene()
{
// Create our scenegraph
new t2dSceneGraph(t2dScene);
// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dScene );
// Add custom game code here...
}





Mine looks like this:

function startGame(%level)
{
// Set The GUI.
Canvas.setContent(mainScreenGui);
Canvas.setCursor(DefaultCursor);

moveMap.push();
sceneWindow2D.loadLevel(%level);
}
function endGame()
{
sceneWindow2D.endLevel();
moveMap.pop();
}

#1
04/25/2006 (10:39 pm)
The Tutorials suck.
#2
04/25/2006 (10:44 pm)
I see you found the private forums :)



Moving on...

I suppose I should give a point to my post above. I'm looking for information about how to compile the scripts with the changes since the tutorials were first released. I've tried putting the code in various places, and from viewing it through the editor I can actually get datablocks to show up within the editor, but they won't show up on the screen when I place them (yes, at appropriate coordinates).

I've tried many ways to no avail.

without going into a long explanation basically I'm trying to get a random number of a specific object to show up onto the screen. Even trying to place one at a specific point using the exact same code as the tutorial (just changing the image) will not work.
#3
04/26/2006 (8:11 am)
The tutorials don't suck, they're just outdated. This is a beta release so it is to be expected that all the tutorials and documents are still being updated :) We are currently updating them though, so just hang tight and ask questions when needed.

I'm not 100% what you mean Aaron. the "startGame()" function gets called when you press that play level button in the level builder. So if you put exec statements there it should run anytime you play your level. You can go a directory higher and put it in the "initalizeProject" function as well.

Which tutorial are you using?
#4
04/26/2006 (2:14 pm)
The basic tutorial that is on TDN works. I was able to get it running when reading carefully. After that, you can experiment with the concepts you have learned.

I was really disapointed by the tutorials too but believe me its out of frustration because you somewhat expect instant gratification but it doest happen :)

give it some time.. start by modding the spaceshooter code if you cant get the basic tutorial running right away.
#5
04/26/2006 (8:06 pm)
Function startGame(%level)
{
// Set The GUI.
Canvas.setContent(mainScreenGui);
Canvas.setCursor(DefaultCursor);



moveMap.push();
sceneWindow2D.loadLevel(%level);

datablock t2dImageMapDatablock(playershipImageMap)
{
imageMode = full;
imageName = "~/data/images/playerShip";
};

$player = new t2dStaticSprite() { scenegraph = t2dScene; };
$player.setPosition("-35 0");
$player.setSize( "14 7" );
$player.setImageMap( playershipImageMap );


}

seems to be what the tutorial says, but it won't work, and variations of it that I try won't work...any insight from the community on what I'm misunderstanding here?
#6
04/26/2006 (8:17 pm)
Dont use the pdf file. use thew tutorial on tdn


tdn.garagegames.com/wiki/Torque_2D/Getting_Started/T2DBasicTutorial1

before you add anything your file should look like this , as explained in the tdn tutorial

//---------------------------------------------------------------------------------------------
// Torque 2D.
// Copyright (C) GarageGames.com, Inc.
//---------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------
// startGame
// All game logic should be set up here. This will be called by the level builder when you
// select "Run Game" or by the startup process of your game to load the first level.
//---------------------------------------------------------------------------------------------
function startGame(%level)
{
// Set The GUI.
Canvas.setContent(mainScreenGui);
Canvas.setCursor(DefaultCursor);

//moveMap.push();
//sceneWindow2D.loadLevel(%level);
setupT2DScene();
}

//---------------------------------------------------------------------------------------------
// endGame
// Game cleanup should be done here.
//---------------------------------------------------------------------------------------------
function endGame()
{
sceneWindow2D.endLevel();
moveMap.pop();
}



//---------------------------------------------------------------------------------------------
// setupT2DScene
// This function is the starting point for all game specific code.
//---------------------------------------------------------------------------------------------
function setupT2DScene()
{
// Create our scenegraph
new t2dSceneGraph(t2dScene);

// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dScene );

// Set the current camera position
sceneWindow2D.setCurrentCameraPosition("0 0 100 75");


///////////////////////// add you datablock and sprite drawing code here //////////////////////////

datablock t2dImageMapDatablock(playershipImageMap)
{
imageMode = full;
imageName = "~/data/images/playerShip";
};

$player = new t2dStaticSprite() { scenegraph = t2dScene; };
$player.setPosition("-35 0");
$player.setSize( "14 7" );
$player.setImageMap( playershipImageMap );

///////////like so /////////////////////////////


}


i did not test it but it should be fine
#7
04/26/2006 (8:37 pm)
Oh okay, I see.

Problem was that it didn't have the scene set up before hand. I was thinkign it was doing that in loading the level file.

It works, thanks a ton for your help.

oh, is there a way to use straight C# or C++ within this?

EDIT: I've read that there is, I just dont know if it needs to be in a seperate file or wrappers or whatever in order to get it to work and I've been looking for the tutorials for it but I've missed it somewhere in the works
#8
04/26/2006 (10:32 pm)
Good , i am glad its working ! :D i have absolutly no knowledge in c++ tho... good luck !