Game Development Community

Basic Tutorial no movement

by Yashvardhan · in General Discussion · 09/18/2010 (6:14 am) · 4 replies

hey guys, i'm an absolute beginner to tge, and wanted to make a simple environment where a little hearse i made should move according to keyboard input. I basically took this example from 2d game programming for teens, and after following complete instructions in the book, my car just won't move :(. he asks me to update the game.cs by adding exec("./player.cs"); to it, and the player.cs is as given below. Please help me out...

function BattyPlayer::onLevelLoaded(%this, %scenegraph)
{
$MeBatty = %this;
moveMap.bindCmd(keyboard, "w", "BattyPlayerUp();", "BattyPlayerUpStop();");
moveMap.bindCmd(keyboard, "s", "BattyPlayerDown();",
"BattyPlayerDownStop();");
moveMap.bindCmd(keyboard, "a", "BattyPlayerLeft();",
"BattyPlayerLeftStop();");
moveMap.bindCmd(keyboard, "d", "BattyPlayerRight();",
"BattyPlayerRightStop();");
}
function BattyPlayerUp()
{
$BattyPlayer.setLinearVelocityY(-15);
}
function BattyPlayerDown()
{
$BattyPlayer.setLinearVelocityY(15);
}
function BattyPlayerLeft()
{
$BattyPlayer.setLinearVelocityX(-25);
}
function BattyPlayerRight()
{
$BattyPlayer.setLinearVelocityX(25);
}
function BattyPlayerUpStop()
{
$BattyPlayer.setLinearVelocityY(0);
}
function BattyPlayerDownStop()
{
$BattyPlayer.setLinearVelocityY(0);
}
function BattyPlayerLeftStop()
{
$BattyPlayer.setLinearVelocityX(0);
}
function BattyPlayerRightStop()
{
$BattyPlayer.setLinearVelocityX(0);
}

About the author

Recent Threads


#1
09/18/2010 (9:19 am)
Yashvardhan, have you given your character the BattyPlayer class name in the IDE?
#2
09/18/2010 (9:23 am)
yes i did, it is a static sprite, in the scripting field i've put the name as Me and class BattyPlayer.
ps. i'm using the latest version of tge.
#3
09/19/2010 (9:23 am)
TGE or TGB?
#4
09/20/2010 (10:12 am)
Right at the beginning you're setting up $MeBatty -- but after that in all the functions you're referring to $BattyPlayer. Change that $MeBatty to $BattyPlayer and see what happens.

And before using code from that book, see all the errata at this site: http://TorqueNation.com

Jay Jennings