Basic Tutorial Help
by Torin Rudeen · in Torque Game Builder · 06/02/2006 (11:22 pm) · 13 replies
I'm having trouble with the basic tutorial. I have triple checked all the instructions, butI can't get my ship to move. The code in player.cs is exactly like it is in the tutorial, I remembered to link to player.cs from main.cs, I set the dynamic variables to the right names, my ship has the instance and class names used in the tutorial, and my ship still won't move. I'm at a loss. Please help me.
#2
The following will show you.
function startGame(%level)
{
exec("./player.cs");
You dont say above on page 11 in the pdf did you click on the player ship then click Edit tab. Open Scripting and enter "pShip" in Name field and "playerShip" in Class field. You said above I set the dynamic variables to the right names, if you put pShip and playerShip in dynamic field that are in the wrong place.
06/03/2006 (12:50 pm)
Torin, your player.cs need be gameScripts folder and need be exec in game.cs in gameScripts folder. The following will show you.
function startGame(%level)
{
exec("./player.cs");
You dont say above on page 11 in the pdf did you click on the player ship then click Edit tab. Open Scripting and enter "pShip" in Name field and "playerShip" in Class field. You said above I set the dynamic variables to the right names, if you put pShip and playerShip in dynamic field that are in the wrong place.
#3
Example
player.cs
TGB will not read it if name is like these player.txt.cs or player.txt.
With the information you gave me this all I can tell you. If you want me read your cs for problem email or post them.
I will definte stay out of others games folder unless you know what you are doing or tutorial direct you to when doing a tutorial. My code is the same as Basic Tutorial and it work find.
06/03/2006 (1:14 pm)
I just check out the basic tutorial, If you are following the tutorial the code should work. What are using to create the cs file, if you using notepad you need change the extension from txt to cs Be sure that when you do create your file you add that .cs extension.Example
player.cs
TGB will not read it if name is like these player.txt.cs or player.txt.
With the information you gave me this all I can tell you. If you want me read your cs for problem email or post them.
I will definte stay out of others games folder unless you know what you are doing or tutorial direct you to when doing a tutorial. My code is the same as Basic Tutorial and it work find.
#4
06/03/2006 (1:33 pm)
#5
While the basic tutorial is roughly based on some features of the scroller demo, the scroller demo is written for more advanced users. If you are not familiar with Torquescript enough yet, it's no doubt quite confusing.
In your example of the key bindings, the bindCmd function is telling the engine that when the "w" key is pressed down to run the pShipUp() function and when released to run pShipUpStop(). The scroller demo "w" key is running the playerShip::playerMovement() function when pressed down and passing this function the string "up". When released it is running the playerShip::playerMovement() function as well but this time sending the string "stopUp". (remember the $pShip= %this in the onLevelLoaded function is referencing the player ship with the $pShip variable)
End result is exactly the same, it's simply two different ways of enabling player movement.
I went through the tutorial and can make things move no problem, trust me, it was tested before being given out to to everyone. :)
If you are really stuck, zip up the project folder you named the tutorial and you can email it to me at lilligreen (at) gmx (dot) net. I can take a look and see if anything is wrong with it.
06/03/2006 (2:14 pm)
Mathias,While the basic tutorial is roughly based on some features of the scroller demo, the scroller demo is written for more advanced users. If you are not familiar with Torquescript enough yet, it's no doubt quite confusing.
In your example of the key bindings, the bindCmd function is telling the engine that when the "w" key is pressed down to run the pShipUp() function and when released to run pShipUpStop(). The scroller demo "w" key is running the playerShip::playerMovement() function when pressed down and passing this function the string "up". When released it is running the playerShip::playerMovement() function as well but this time sending the string "stopUp". (remember the $pShip= %this in the onLevelLoaded function is referencing the player ship with the $pShip variable)
End result is exactly the same, it's simply two different ways of enabling player movement.
I went through the tutorial and can make things move no problem, trust me, it was tested before being given out to to everyone. :)
If you are really stuck, zip up the project folder you named the tutorial and you can email it to me at lilligreen (at) gmx (dot) net. I can take a look and see if anything is wrong with it.
#6
For the record, I'm working on a MacBook Pro 2GHz, 1GB RAM, 256MB video RAM.
06/04/2006 (8:57 pm)
I'm having the exact same issue as Torin. I've tried beginning from scratch about 5 times now, always with the same result (the ship displays, but will not move).For the record, I'm working on a MacBook Pro 2GHz, 1GB RAM, 256MB video RAM.
#7
Thank you for your help.
I looked again at the pdf and now i know that i have printet out an old one.
If i use the new one from the RC1 release it work now for me.
Maybe i have some mistakes too but now after complete rewriting the scripts i can fly around nicely and be happy :)
Mathias
06/05/2006 (1:01 am)
@Michael and MikeThank you for your help.
I looked again at the pdf and now i know that i have printet out an old one.
If i use the new one from the RC1 release it work now for me.
Maybe i have some mistakes too but now after complete rewriting the scripts i can fly around nicely and be happy :)
Mathias
#8
06/05/2006 (8:11 am)
You welcome I am glad you have it working. TGB is alot fun to play with and make games.
#9
When i typed it out I got no movement but if I cut and pasted it worked fine. It turned out to be an issue of my editor (ultraedit) auto-correcting my instances of "true" and "false" into "TRUE" and "FALSE". I edited my worldlist file to keep this from happening, then went back and manually changed each instance into lower case and everything worked fine. Other people having problems might check for similar case sensitivity issues. They can get you if you're not careful.
Allen
06/05/2006 (3:58 pm)
I had a similar problem going through the tutorial. When i typed it out I got no movement but if I cut and pasted it worked fine. It turned out to be an issue of my editor (ultraedit) auto-correcting my instances of "true" and "false" into "TRUE" and "FALSE". I edited my worldlist file to keep this from happening, then went back and manually changed each instance into lower case and everything worked fine. Other people having problems might check for similar case sensitivity issues. They can get you if you're not careful.
Allen
#10
Did you catch what the difference was? I've been working from the RC1 PDF and a 2 day old printout of the TDN pages, and I'm obviously missing something.
@Mike Lilligreen
I just took you up on your offer to look at the project files. I've been over the scripts and tutorial with a fine-toothed comb and can't find the problem. That usually means it's something blatantly obvious to someone who hasn't been staring at the code for 8 hours. :)
06/05/2006 (5:00 pm)
@Mathias StolleyDid you catch what the difference was? I've been working from the RC1 PDF and a 2 day old printout of the TDN pages, and I'm obviously missing something.
@Mike Lilligreen
I just took you up on your offer to look at the project files. I've been over the scripts and tutorial with a fine-toothed comb and can't find the problem. That usually means it's something blatantly obvious to someone who hasn't been staring at the code for 8 hours. :)
#11
06/05/2006 (6:57 pm)
Doh! I've just figured out my problem. It seems that I'd somehow managed to write code that only lets me move if two non-opposing keys are pressed (aka: diagonally).
#12
I think you figured it out on your own, but just in case... :)
In the cPlayer::updateMovement function you had this:
06/06/2006 (1:16 pm)
Hi Theo,I think you figured it out on your own, but just in case... :)
In the cPlayer::updateMovement function you had this:
if(!%this.moveUp && !%this.moveDown)
{
%this.setLinearVelocityX( 0 );
}
if(!%this.moveLeft && !%this.moveRight)
{
%this.setLinearVelocityY( 0 );
}The problem here is that you are telling the engine that if moveUp and moveDown are false to set the speed in X to zero. LinearVelocityX is for the left/right movement though! The same thing is happening with up/down movement, so have the end of your updateMovement function look like this:if(!%this.moveLeft && !%this.moveRight)
{
%this.setLinearVelocityX( 0 );
}
if(!%this.moveUp && !%this.moveDown)
{
%this.setLinearVelocityY( 0 );
}
#13
Yeah, figured it out. Like I'd said in the email, it was probably something blatantly simple that I was missing. I've gotten some better working movement code worked out at this point, but I'm having issues trying to force movement in 1/2 tile increments at the moment. Have some ideas, but I was happy to get basic movement working last night.
Thanks for the help, though.
06/06/2006 (2:45 pm)
@Mike LilligreenYeah, figured it out. Like I'd said in the email, it was probably something blatantly simple that I was missing. I've gotten some better working movement code worked out at this point, but I'm having issues trying to force movement in 1/2 tile increments at the moment. Have some ideas, but I was happy to get basic movement working last night.
Thanks for the help, though.
Torque Owner M. Stolley
Default Studio Name
I just use the pdf that comes with the rc1.
I just look at the player script from the scroller demo and it look different on many parts.
For me as a beginner in scrippting this is a little confusing.
It would be good to test the documentation before give them out so that beginners can really lern the fundamentals fast at the beginning.
I work thru other tutorials without a problem, but now it i am a little frustrated becouse i will understand what and why i use the parts of the script and not only copy them from here to there.
i.e. this is the script from the pdf for keybinding
----------------------------
moveMap.bindCmd(keyboard, "w", "pShipUp();", "pShipUpStop();");
moveMap.bindCmd(keyboard, "s", "pShipDown();", "pShipDownStop();");
moveMap.bindCmd(keyboard, "a", "pShipLeft();", "pShipLeftStop();");
moveMap.bindCmd(keyboard, "d", "pShipRight();", "pShipRightStop();");
-----------------------------
and this from the demo scroller for keybinding
-----------------------------
moveMap.bindCmd(keyboard, "w", "$pShip.playerMovement(up);", "$pShip.playerMovement(stopUp);");
moveMap.bindCmd(keyboard, "s", "$pShip.playerMovement(down);", "$pShip.playerMovement(stopDown);");
moveMap.bindCmd(keyboard, "a", "$pShip.playerMovement(left);", "$pShip.playerMovement(stopLeft);");
moveMap.bindCmd(keyboard, "d", "$pShip.playerMovement(right);", "$pShip.playerMovement(stopRight);");
-----------------------------
Mathias