hey...new to torque
by linkbob · in General Discussion · 08/05/2009 (5:01 pm) · 1 replies
Im new to torque and im doing the fish game tutorial. for some reason the fish wont move even thought the code seems to be right. please let me know if you see anything wrong
this is what i have...
IN MY PLAYER.CS FILE
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 );
}
funtion fishPlayerLeft ()
{
$FishPlayer.setLinearVelocityX ( -30 );
}
funtion fishPlayerRight()
{
$FishPlayer.setLinearVelocityX ( -30 );
}
function fishPlayerUpStop()
{
$FishPlayer.setLinearVelocityY ( 0 );
}
function fishPlayerDownStop()
{
$FishPlayer.setLinearVelocityY ( 0 );
function fishPlayerLeftStop()
{
$FishPlayer.setLinearVelocityY ( 0 );
}
function fishPlayerRightStop()
{
$FishPlayer.setLinearVelocityY ( 0 );
AND MY GAME.CS FILE
//---------------------------------------------------------------------------------------------
// Torque Game Builder
// 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)
{
exec("./player.cs");
Canvas.setContent(mainScreenGui);
Canvas.setCursor(DefaultCursor);
new ActionMap(moveMap);
moveMap.push();
$enableDirectInput = true;
activateDirectInput();
enableJoystick();
sceneWindow2D.loadLevel(%level);
}
//---------------------------------------------------------------------------------------------
// endGame
// Game cleanup should be done here.
//---------------------------------------------------------------------------------------------
function endGame()
{
sceneWindow2D.endLevel();
moveMap.pop();
moveMap.delete();
}
this is what i have...
IN MY PLAYER.CS FILE
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 );
}
funtion fishPlayerLeft ()
{
$FishPlayer.setLinearVelocityX ( -30 );
}
funtion fishPlayerRight()
{
$FishPlayer.setLinearVelocityX ( -30 );
}
function fishPlayerUpStop()
{
$FishPlayer.setLinearVelocityY ( 0 );
}
function fishPlayerDownStop()
{
$FishPlayer.setLinearVelocityY ( 0 );
function fishPlayerLeftStop()
{
$FishPlayer.setLinearVelocityY ( 0 );
}
function fishPlayerRightStop()
{
$FishPlayer.setLinearVelocityY ( 0 );
AND MY GAME.CS FILE
//---------------------------------------------------------------------------------------------
// Torque Game Builder
// 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)
{
exec("./player.cs");
Canvas.setContent(mainScreenGui);
Canvas.setCursor(DefaultCursor);
new ActionMap(moveMap);
moveMap.push();
$enableDirectInput = true;
activateDirectInput();
enableJoystick();
sceneWindow2D.loadLevel(%level);
}
//---------------------------------------------------------------------------------------------
// endGame
// Game cleanup should be done here.
//---------------------------------------------------------------------------------------------
function endGame()
{
sceneWindow2D.endLevel();
moveMap.pop();
moveMap.delete();
}
About the author
Torque 3D Owner Ted Southard