Game Development Community

Hello all, i'm new and looking for some help

by Alex Rodriguez · in Torque Game Builder · 06/03/2007 (8:11 pm) · 4 replies

Hey there everyone.

I've been messin around with the TGB trial version to get a feel for it before i decide to buy it.
i started working on this tutorial
Basic Platformer Mechanics

i have gotten to the player movement section , i get all the code there and all i can do is jump. so i decided to trudge on and work with it so i added the reset code for the jump function. with even copying and pasting the code straight from the tutorial , nothing seems to work ; other then the little jump.

here is my code :

function playerClass::onLevelLoaded(%this, %scenegraph)
{
$pGuy = %this;

moveMap.bindCmd(keyboard, "left", "playerLeft();", "playerLeftStop();");
moveMap.bindCmd(keyboard, "right", "playerRight();", "playerRightStop();");
moveMap.bindCmd(keyboard, "space", "playerJump();", "");
%this.setCollisionMaxIterations(2);
}
function playerLeft()
{
$pGuy.moveLeft = true;
}

function playerLeftStop()
{
$pGuy.moveLeft = false;
}

function playerRight()
{
$pGuy.moveRight = true;
}

function playerRightStop()
{
$pGuy.moveRight = false;
}

function playerJump()
{
if(!$pGuy.airborne)
{
$pGuy.setLinearVelocityY(-225);
$pGuy.airborne = true;
}
}
function playerClass::updateHorizontal(%this)
{
if(%this.moveLeft)
{
%this.setLinearVelocityX(-60);
}

if(%this.moveRight)
{
%this.setLinearVelocityX(60);
}

if(!%this.moveLeft && !%this.moveRight)
{
%this.setLinearVelocityX(0);
}
}
function playerClass::updateVertical(%this)
{
%yVelocity = %this.getLinearVelocityY();

if(%this.airborne)
{
%this.setLinearVelocityY(0);
%collision = %this.castCollision(0.005);

if(%collision !$= "")
%this.setLinearVelocityX(0);
}

%this.setLinearVelocityY(100);
%collision = %this.castCollision(0.005);

if(%collision $= "")
{
%this.airborne = true;
%this.setConstantForceY(100);
}
else if(%yVelocity < 0 && %this.airborne)
{
%this.setConstantForceY(100);
}
else
{
%this.airborne = false;
%this.setConstantForceY(0);
}

%this.setLinearVelocityY(%yVelocity);
}

function playerClass::updateMovement(%this)
{
%this.updateHorizontal();
%this.updateVertical();
}
function PlatformerSceneGraph::onUpdateScene()
{
if (isObject($pGuy))
$pGuy.updateMovement();
}


i'm at a complete loss, i want to buy this programs to start plotting out my game ideas, but if i cant get it to work...i'm not sure what else to do.

any help would be great!

thanks a million

~Alex.

About the author

Recent Threads

  • New to TGB

  • #1
    06/03/2007 (9:32 pm)
    I think there have been changes since that tutorial was written. Rumor has it that eventually there will be a platformer kit to help make these games easy...but right now a platformer is not so simple to make with TGB.
    #2
    06/03/2007 (10:01 pm)
    Thanks for the response Joe!


    doh , ok thanks. i guess while i'm here is there a good place to find updated tutorials, or a place to get a good idea how to script for TGB correctly?
    i'm starting with 2d to get a good idea on game development , and once i feel comfortable with Torque ill upgrade to the 3d engine.

    but as of now i dont wanna take the plunge if i cant get anything to work correctly.

    i had the same trouble with the scroller tutorial, i got everything to work, but my missiles would not fire at all.

    so far i'm having some bad luck.


    any help with a good place to start with updated material would be great!
    #3
    06/05/2007 (8:05 pm)
    Well the most up to date place to look would be TDN. People in the community were supposed to update it as things changed but that doesn't seem to be happening as well as we all may have hoped. So, many things on there are now outdated and might not work. I'd say the only examples guaranteed to work are the ones that come with your distribution.
    #4
    06/20/2007 (11:13 am)
    @Alex Rodriguez,
    I have the same problem if I don't have a sceneGraph object named "PlatformerSceneGraph", or I your can update your code below:

    //function PlatformerSceneGraph::onUpdateScene(){
    function t2dSceneGraph::onUpdateScene(){