Having Problems Incredibly New to Torque
by Shaine · in Torque Game Builder · 11/21/2011 (9:14 pm) · 7 replies
Ok so Im in my communications technology class and my teacher has allowed me to develop a game using the Torque Game Builder 2D, however I know nothing of it. No C programming background, only a Java programming background. And the only thing i know is the torque documentation and platformer tutorials.
So im trying to make a platformer and currently trying to make the movement code. Im also trying to implement a ladder feature. Im having struggles with this for a couple months now and half the semester has gone by. I tried everything looked at every platformer tutorial but most seem out of date and dont work for my game. i could only create a small base of one of the platformer tutorials.
Do take into consideration that im extremely new at this and that i cannot turn back from this project...
This is my player movement methods for horizontal and vertical movement:
function playerClass::updateHorizontal(%this)
{
if ($player.moveLeft == $player.moveRight)
{
$player.setLinearVelocityX(0);
return;
}
if ($player.moveLeft)
{
if (!$player.againstLeftWall)
{
$player.againstRightWall = false;
$player.setLinearVelocityX(-50);
}
}
if ($player.moveRight)
{
if (!$player.againstRightWall)
{
$player.againstLeftWall = false;
$player.setLinearVelocityX(50);
}
}
}
function playerClass::updateVertical(%this)
{
%yVelocity = %this.getLinearVelocityY();
%this.setLinearVelocityY(5);
%collision = %this.castCollision(0.005);
%normalX = getWord(%collision, 4);
%normalY = getWord(%collision, 5);
//no collision
if(%collision $= "")
{
%this.againstRightWall = false;
%this.againstLeftWall = false;
%this.ladder=false;
climb.setCollisionCallback(true);
%this.airborne = true;
%this.setConstantForceY(100);
%this.setLinearVelocityY(%yVelocity);
return;
}
//collide left wall
if(%normalX == 1 && %normalY == 0)
{
%this.againstLeftWall = true;
%this.setLinearVelocityX(0);
%this.setLinearVelocityY(%yVelocity);
return;
}
//collide right wall
if(%normalX == -1 && %normalY == 0)
{
%this.againstRightWall = true;
%this.setLinearVelocityX(0);
%this.setLinearVelocityY(%yVelocity);
return;
}
//collide ground
if(%normalX == 0 && %normalY == -1)
{
%this.againstRightWall = false;
%this.againstLeftWall = false;
%this.airborne = false;
%this.setConstantForceY(0);
%this.setLinearVelocityY(%yVelocity);
return;
}
//collide ceiling
if(%normalY == 1)
{
%this.airborne = true;
%this.setLinearVelocityX(0);
%this.setConstantForceY(100);
%this.setLinearVelocityY(%yVelocity);
return;
}
}
So im trying to make a platformer and currently trying to make the movement code. Im also trying to implement a ladder feature. Im having struggles with this for a couple months now and half the semester has gone by. I tried everything looked at every platformer tutorial but most seem out of date and dont work for my game. i could only create a small base of one of the platformer tutorials.
Do take into consideration that im extremely new at this and that i cannot turn back from this project...
This is my player movement methods for horizontal and vertical movement:
function playerClass::updateHorizontal(%this)
{
if ($player.moveLeft == $player.moveRight)
{
$player.setLinearVelocityX(0);
return;
}
if ($player.moveLeft)
{
if (!$player.againstLeftWall)
{
$player.againstRightWall = false;
$player.setLinearVelocityX(-50);
}
}
if ($player.moveRight)
{
if (!$player.againstRightWall)
{
$player.againstLeftWall = false;
$player.setLinearVelocityX(50);
}
}
}
function playerClass::updateVertical(%this)
{
%yVelocity = %this.getLinearVelocityY();
%this.setLinearVelocityY(5);
%collision = %this.castCollision(0.005);
%normalX = getWord(%collision, 4);
%normalY = getWord(%collision, 5);
//no collision
if(%collision $= "")
{
%this.againstRightWall = false;
%this.againstLeftWall = false;
%this.ladder=false;
climb.setCollisionCallback(true);
%this.airborne = true;
%this.setConstantForceY(100);
%this.setLinearVelocityY(%yVelocity);
return;
}
//collide left wall
if(%normalX == 1 && %normalY == 0)
{
%this.againstLeftWall = true;
%this.setLinearVelocityX(0);
%this.setLinearVelocityY(%yVelocity);
return;
}
//collide right wall
if(%normalX == -1 && %normalY == 0)
{
%this.againstRightWall = true;
%this.setLinearVelocityX(0);
%this.setLinearVelocityY(%yVelocity);
return;
}
//collide ground
if(%normalX == 0 && %normalY == -1)
{
%this.againstRightWall = false;
%this.againstLeftWall = false;
%this.airborne = false;
%this.setConstantForceY(0);
%this.setLinearVelocityY(%yVelocity);
return;
}
//collide ceiling
if(%normalY == 1)
{
%this.airborne = true;
%this.setLinearVelocityX(0);
%this.setConstantForceY(100);
%this.setLinearVelocityY(%yVelocity);
return;
}
}
#2
as in it moves left, right, can jump, but when u get to a wall and jump along side it the jump is literally three times its height... im using a circle collision because if i use polygon it looks like every time it hits a wall it goes inside and then bak out and this looks extremely weird... so when i change the collision to circle tht problem is fixed however when object is near a wall and the object jumps it literally climbs the wall and stays on the ceiling still touching the wall... i didnt want the object to climb the wall... i have certain objects labelled in order for the object to know when to climb or not...
i hope this helps...
11/22/2011 (8:20 pm)
o sorry :( well the movement works but it is extremely buggy...as in it moves left, right, can jump, but when u get to a wall and jump along side it the jump is literally three times its height... im using a circle collision because if i use polygon it looks like every time it hits a wall it goes inside and then bak out and this looks extremely weird... so when i change the collision to circle tht problem is fixed however when object is near a wall and the object jumps it literally climbs the wall and stays on the ceiling still touching the wall... i didnt want the object to climb the wall... i have certain objects labelled in order for the object to know when to climb or not...
i hope this helps...
#3
11/22/2011 (8:57 pm)
Edited - Posted in the wrong thread
#4
11/22/2011 (9:29 pm)
I kno that much for programming, i have a java background :/ and even if there were mistakes in the code the compiler would catch it no?
#5
11/22/2011 (10:12 pm)
If you have your Torsion project set up properly, it should catch the issue. Visual Studio will not catch the errors, since it does not know the TorqueScript language.
#6
Let me review your code and provide the correct reply.
11/23/2011 (9:49 am)
@Shaine - My apologies. The reply must have made no sense, because I posted in the wrong thread. The reply was meant to go to this thread.Let me review your code and provide the correct reply.
#7
11/24/2011 (10:47 am)
ok its fine thanks :)
Employee Michael Perry
ZombieShortbus