My problem with "Fish game tutorial
by Firas · in Torque Game Builder · 07/08/2006 (8:32 am) · 6 replies
I'm trying to implement the "Fish game tutorial" I'm in the second part of this tutorial "moving a fish" I have implement the script just like the parts say but I don't why it's not working :(
what I notice is that when I start the TGB and start the level there is no player.cs.dso file (the compiled vesrion of the player.cs)
I sure I have add a call to it in game.cs like this:
exec("./player.cs");
and this is the implementation of the player.cs:
function PlayerFish::onLevelLoaded(%this, %scenegraph)
{
$FishPlayer = %this;
moveMap.bindCmd(keyboard, "w", "fishPlayerUp();", "fishPlayerUpStop();");
moveMap.bindCmd(keyboard, "s", "fishPlayerDown();", "fishPlayerDownStop();");
moveMap.bindCmd(keyboard, "a", "fishPlayerLeft();", "fishPlayerLeftStop();");
moveMap.bindCmd(keyboard, "d", "fishPlayerRight();", "fishPlayerRightStop();");
}
function fishPlayerUp()
{
$FishPlayer.setLinearVelocityY( -15 );
}
function fishPlayerDown()
{
$FishPlayer.setLinearVelocityY( 15 );
}
function fishPlayerLeft()
{
$FishPlayer.setLinearVelocityX( -30 );
}
function fishPlayerRight()
{
$FishPlayer.setLinearVelocityX( 30 );
}
function fishPlayerUpStop()
{
$FishPlayer.setLinearVelocityY( 0 );
}
function fishPlayerDownStop()
{
$FishPlayer.setLinearVelocityY( 0 );
}
function fishPlayerLeftStop()
{
$FishPlayer.setLinearVelocityX( 0 );
}
function fishPlayerRightStop()
{
$FishPlayer.setLinearVelocityX( 0 );
}
and I have add the "PlayerFish" to the fish in class field in the scripting part in TGB.
please help
thanks in advance.
what I notice is that when I start the TGB and start the level there is no player.cs.dso file (the compiled vesrion of the player.cs)
I sure I have add a call to it in game.cs like this:
exec("./player.cs");
and this is the implementation of the player.cs:
function PlayerFish::onLevelLoaded(%this, %scenegraph)
{
$FishPlayer = %this;
moveMap.bindCmd(keyboard, "w", "fishPlayerUp();", "fishPlayerUpStop();");
moveMap.bindCmd(keyboard, "s", "fishPlayerDown();", "fishPlayerDownStop();");
moveMap.bindCmd(keyboard, "a", "fishPlayerLeft();", "fishPlayerLeftStop();");
moveMap.bindCmd(keyboard, "d", "fishPlayerRight();", "fishPlayerRightStop();");
}
function fishPlayerUp()
{
$FishPlayer.setLinearVelocityY( -15 );
}
function fishPlayerDown()
{
$FishPlayer.setLinearVelocityY( 15 );
}
function fishPlayerLeft()
{
$FishPlayer.setLinearVelocityX( -30 );
}
function fishPlayerRight()
{
$FishPlayer.setLinearVelocityX( 30 );
}
function fishPlayerUpStop()
{
$FishPlayer.setLinearVelocityY( 0 );
}
function fishPlayerDownStop()
{
$FishPlayer.setLinearVelocityY( 0 );
}
function fishPlayerLeftStop()
{
$FishPlayer.setLinearVelocityX( 0 );
}
function fishPlayerRightStop()
{
$FishPlayer.setLinearVelocityX( 0 );
}
and I have add the "PlayerFish" to the fish in class field in the scripting part in TGB.
please help
thanks in advance.
About the author
#2
please check your gamescripts folder do you have a file called player.cs.dso (the compiled version of player.cs)?
I'm asking this beacuse in my console window I have the following message:
Executing MyFishGame/GameScripts/player.cs
but I can't see a compiled version of that file (I mean player.cs.dso), any ideas why this problem happen??
thanks in advance
07/08/2006 (11:58 pm)
Yes thats right it's not hitting the function and I can't find a reason why that happen?please check your gamescripts folder do you have a file called player.cs.dso (the compiled version of player.cs)?
I'm asking this beacuse in my console window I have the following message:
Executing MyFishGame/GameScripts/player.cs
but I can't see a compiled version of that file (I mean player.cs.dso), any ideas why this problem happen??
thanks in advance
#3
07/09/2006 (1:41 am)
You won't get a 'player.cs.dso' file, it runs without creating a " ".dso Please don't ask me why:) I just did the 'MyFishGame' Tutorial and I don't have one.
#4
07/09/2006 (1:48 am)
Have you tried first deleting your old 'game.cs.dso' and then try running the game?
#5
When I ran the project, it created a .dso. Out of curiosity, I deleted it and ran the project again. It recreated the .dso file and functioned properly.
Dunno what the problem would be. I'd say start a new project and cut and paste your code in. If it doesn't work again, the problem is of a different scope altogether.
07/09/2006 (10:28 am)
Cut and pasted your code into an empty MyFishGame project and it works fine when I hit play.When I ran the project, it created a .dso. Out of curiosity, I deleted it and ran the project again. It recreated the .dso file and functioned properly.
Dunno what the problem would be. I'd say start a new project and cut and paste your code in. If it doesn't work again, the problem is of a different scope altogether.
#6
mattl AT garagegames DOT com
07/10/2006 (5:19 pm)
Feel free to zip up your working directory and e-mail me it and I'll take a look :)mattl AT garagegames DOT com
Torque Owner Matthew Zulawski
One thing that I found in the reference is that you can use an echo command to output text to the console (which you can bring up by hitting ~ when the game starts). So change your up function to the following:
function fishPlayerUp() { echo("Up Detected"); $FishPlayer.setLinearVelocityY( -15 ); }Start your game up and hit w. Then, hit ~, and if "Up Detected" isn't the last line there, then the game isn't hitting your function.