Game Development Community

Beginning tutorial

by Bryan Moscato · in General Discussion · 02/19/2008 (8:18 am) · 5 replies

Yesterday I ran through the Torque 1.5 tutorial but for some reason when I collide with the logos they disapear but do not add to my score.

I set up a guiTextCtrl and named it 'ScoreCounter', set text to 'Score: 0' and changed the font to GuiBigTextProfile.

I edited the file 'GameOne/server/logoitem.cs':



//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------

datablock StaticShapeData(TorqueLogoItem)
{
category = "Items";
shapeFile = "~/data/shapes/3dtorquelogo/torque_logo.dts";
}


function TorqueLogoItem::onCollision(%this, %obj, %col)
{
if(%col.getClassName() $= "Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);

%obj.delete();
%logoCount = logos.getCount();
if(%logoCount > 0)
return;
// otherwise display victory screen
commandToClient(%client, 'ShowVictory', %client.score);
}
}


Then I created the file 'GameOne/client/clientGame.cs':



function clientCmdSetScoreCounter(%score)
{
ScoreCounter.setText("Score:" SPC %score);
}

function clientCmdShowVictory(%score)
{
MessageBoxYesNo("You Win!",
"Would you like to restart the game ?",
"loadMyMission();",
"quit();");
}


Then I added 'exec("./client/clientGame.cs");' to the 'Client scripts' section of GameOne/main.cs:



// Client scripts
exec("./client/optionsDlg.cs");
exec("./client/missionDownload.cs");
exec("./client/serverConnection.cs");
exec("./client/loadingGui.cs");
exec("./client/playGui.cs");
exec("./client/clientGame.cs");



Did I miss something?

#1
02/19/2008 (1:01 pm)
Nothing jumps at me... Have you tried running DeleteDSOs.bat? If you entered the code with an intermediate step the previous DSO could be the problem.

I've had this one bite me a couple of times.
#2
02/21/2008 (5:36 am)
Anyone else have any ideas? I started from scratch with the tutorial and I get the same results; objects on collision are removed but never update the score.
#3
02/21/2008 (7:17 am)
Are you getting any errors in your console.log?
#4
02/21/2008 (8:23 am)
Hey Mike,

Thanks for the direction. After looking in the log file I noticed that 2 of my functions where unknown. I ended up naming the file clientGame.cs improperly in the client directory, I made it plural (clientGames.cs) on accident. All works fine now.

Bryan
#5
02/21/2008 (7:28 pm)
That's great. :-)
It's always a good thing to check your console.log when you get errors. It's a great debugging tool.