Game Development Community

Problem with move code

by Chris Farley · in Torque Game Builder · 11/30/2006 (5:37 pm) · 3 replies

I have tried a million times. iv even coppied the exact code from the sample but there is still and error.

it says both Syntax error and "parse error in line 1"


heres my code:

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 );
}


no matter what it just wont work! i cant figure it out. iv even tried to use the shooter code for it instead and i still come back with the same results! its CRAZY!


please help

#1
11/30/2006 (6:02 pm)
Two things I can think of (besides the .txt problem from the other post):

-Your script isn't being re-executed because you either don't have exec in the startGame function or you haven't reloaded TGB.

-Try copying the player.cs script from the exampleFishDemo project in the games folder - see if that works after you edit out the stuff that you haven't gotten to in the tutorial yet..
#2
11/30/2006 (6:16 pm)
Don't see anything wrong with that code, so here is a crazy suggestion:

Create a new file and type it in. I have seen this before where I see absolutely nothing
wrong with my code but maybe I copied/pasted and somehow its as if there is an
invisible character that wrecks things.

Maybe there is a more logical answer thats torque related, so I'll leave that to the pros to suggest.
John
#3
12/03/2006 (10:50 am)
Thanks