Game Development Community

Keyboard not functioning with game (newbie)

by Karim AbdelWahab · in Torque Game Builder · 04/06/2010 (9:52 am) · 4 replies

Hello,

am trying to follow the fish tutorial, everything works in the first tutorial but the 2nd one where you add keyboard movements like "w" "s" "a" "d" they dont work, not sure how to track the problem, i checked the script letter by letter and everything is correct, am working on a macbook pro, i saved my game in the documents folder under "games"

are there any suggestions i should try or do? i searched for FAQ section but couldn't find so i thought to post my problem maybe someone out there can help :-)


Thanks in advance

About the author

http://www.simplyhire.me

Recent Threads


#1
04/06/2010 (9:56 am)
if you check tdn try adding the shooter controls behavior to your fish.. and the tutorials on making behaviors. they are much cleaner to use for control schemes with out your code i cant say why its not working
#2
04/06/2010 (10:08 am)
Thanks Micheal for the quick reply, well i was actually learning from a book called "2d game building for teens" its based on tgb, i followed up the tutorial in it but when it came to the part that i should test the game, nothing worked, so i thought to go and follow the fish game to see if there is something wrong with the book or no, but when i tried the fish, i got same results with the keyboard, basically they exec the script player.cs in the game.cs the code included in the player script is

===============
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 BattyPlayerUpStop()
{
$BattyPlayer.setLinearVelocityY(0);
}
function BattyPlayerDownStop()
{
$BattyPlayer.setLinearVelocityY(0);
}
function BattyPlayerLeftStop()
{
$BattyPlayer.setLinearVelocityX(0);
}
function BattyPlayerRightStop()
{
$BattyPlayer.setLinearVelocityX(0);
}
function BattyPlayerUp()
{
$BattyPlayer.setLinearVelocityY(-15);
}
function BattyPlayerDown()
{
$BattyPlayer.setLinearVelocityY(15);
}
function BattyPlayerLeft()
{
$BattyPlayer.setLinearVelocityX(-25);
}
function BattyPlayerRight()
{
$BattyPlayer.setLinearVelocityX(25);
}
============

should i be ignoring this book and the fish tutorial? am trying to learn the tgb basics so that i can develop kids games somehow :-)

i appreciate your help and advise

Thanks.
#3
04/06/2010 (10:19 am)
You've assigned the global variable $MeBatty to the object that should move in onLevelLoaded, but in the movement functions you have $BattyPlayer instead. Change $MeBatty to $BattyPlayer.
#4
04/06/2010 (10:29 am)
Wow :-) you're my hero :p

i didnt see that coming, i was just following the book :s

Thanks a lot for your help