User error or 1.1.1 tutorial bug?
by Jon Mitchell · in Torque Game Builder · 08/22/2006 (8:13 pm) · 10 replies
I am running through the basic tutorials again since installing 1.1.1 and I am up to part 4 of the basic tutorial (the side shooter) http://tdn.garagegames.com/wiki/TGB/BasicTutorial4 and I can not seem to get my missiles to fire for the life of me.
I have gone back through and replaced my code with that from TDN just to be sure, but still no luck. Everything else to that point is working fine, and I double checked the dynamic field to make sure I had put in "missileSpeed".
Has anyone else gone back through the tutorials and found out if this works? I tried to search, but only found people running into problems in older versions.
Also to note, one typo in the instructions at the bottom of getting the player to fire:
"All it does is call the enemy's spawn function when it is triggered. Save your files (if you haven't already) and go into your game.cs file ***This should be main.cs*** and make your exec statements look like this:
// Exec game scripts.
exec("./gameScripts/game.cs");
exec("./gameScripts/player.cs");
exec("./gameScripts/enemy.cs");
exec("./gameScripts/playerMissile.cs"); // Add this line to the end of the exec statements.
That is all the code you need to get your enemy ready to die - the rest of the work is done in the Level Builder."
I have gone back through and replaced my code with that from TDN just to be sure, but still no luck. Everything else to that point is working fine, and I double checked the dynamic field to make sure I had put in "missileSpeed".
Has anyone else gone back through the tutorials and found out if this works? I tried to search, but only found people running into problems in older versions.
Also to note, one typo in the instructions at the bottom of getting the player to fire:
"All it does is call the enemy's spawn function when it is triggered. Save your files (if you haven't already) and go into your game.cs file ***This should be main.cs*** and make your exec statements look like this:
// Exec game scripts.
exec("./gameScripts/game.cs");
exec("./gameScripts/player.cs");
exec("./gameScripts/enemy.cs");
exec("./gameScripts/playerMissile.cs"); // Add this line to the end of the exec statements.
That is all the code you need to get your enemy ready to die - the rest of the work is done in the Level Builder."
#2
08/23/2006 (10:26 am)
I will post that tonight when I get home, and compare it to the demo code, which I would have never though of checking :-p
#3
08/23/2006 (10:30 am)
I ran through the tutorials provided with 1.1.1 and can confirm that the shooter tutorial definitely works. The scripts added should be exec'd in /gameScripts/game.cs. There's no need to add anything to main.cs.
#4
comparing it to the demo code is a great idea too. I did that several times. Are you using Torisn to make you scripts? If so, when you forget a % or $ the var's are a different color. That's saved me some sanity a few times. :) So you've got the tutorials in the pdf, the sample code & the stuff on TDN. Three time the redundency!
plus you don't need to shutdown/restart TGB to compile scripts which makes check your errors as easy as saving the script.
08/23/2006 (11:14 am)
He's looking at the tut's on tdn. i think those are just slightly outdated is all.comparing it to the demo code is a great idea too. I did that several times. Are you using Torisn to make you scripts? If so, when you forget a % or $ the var's are a different color. That's saved me some sanity a few times. :) So you've got the tutorials in the pdf, the sample code & the stuff on TDN. Three time the redundency!
plus you don't need to shutdown/restart TGB to compile scripts which makes check your errors as easy as saving the script.
#5
In the demo for the fire binding it looks like this:
moveMap.bindCmd(keyboard, "space", "$pShip.isFiring();", "$pShip.notFiring();");
In the tutorial it looks like this:
moveMap.bindCmd(keyboard, "space", "$pship.createMissile();", "");
The function for firing the missile is a lot different from the tutorial from the demo compared to the one on TDN.
And I am using ultra edit 32 for the coding, and to compare code to look for mistakes I use a rather odd ball method. I copy and paste the code into macromedia fireworks, then make a new image layer then copy and paste the tutorial code then move one layer over the other, if the code does not line up I know where to look for an error :-)
Anyhow, here is the create missile function:
function playerShip::createMissile(%this)
{
%this.playerMissile = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = playerMissile;
missileSpeed = %this.missileSpeed;
player = %this;
};
%this.playerMissile.fire();
}
And last but not least fire missile:
function playerMissile::fire(%this)
{
%this.setWorldLimit( kill, "-11.241 -5.836 489.518 366.542" );
%this.setLinearVelocityX(%this.missileSpeed);
%this.setPosition(%this.player.getPosition());
%this.setImageMap(playerMissileImageMap);
%this.setSize(22, 10);
%this.setCollisionActive(true, true);
%this.setCollisionPhysics(false, false);
%this.setCollisionCallback(true);
}
08/23/2006 (4:04 pm)
One thing I noticed when comparing the code in the demo to the tutorial.In the demo for the fire binding it looks like this:
moveMap.bindCmd(keyboard, "space", "$pShip.isFiring();", "$pShip.notFiring();");
In the tutorial it looks like this:
moveMap.bindCmd(keyboard, "space", "$pship.createMissile();", "");
The function for firing the missile is a lot different from the tutorial from the demo compared to the one on TDN.
And I am using ultra edit 32 for the coding, and to compare code to look for mistakes I use a rather odd ball method. I copy and paste the code into macromedia fireworks, then make a new image layer then copy and paste the tutorial code then move one layer over the other, if the code does not line up I know where to look for an error :-)
Anyhow, here is the create missile function:
function playerShip::createMissile(%this)
{
%this.playerMissile = new t2dStaticSprite()
{
scenegraph = %this.scenegraph;
class = playerMissile;
missileSpeed = %this.missileSpeed;
player = %this;
};
%this.playerMissile.fire();
}
And last but not least fire missile:
function playerMissile::fire(%this)
{
%this.setWorldLimit( kill, "-11.241 -5.836 489.518 366.542" );
%this.setLinearVelocityX(%this.missileSpeed);
%this.setPosition(%this.player.getPosition());
%this.setImageMap(playerMissileImageMap);
%this.setSize(22, 10);
%this.setCollisionActive(true, true);
%this.setCollisionPhysics(false, false);
%this.setCollisionCallback(true);
}
#6
Basically, don't use TDN for the tutorials right now. They're generally outdated, broken, or just contain bad programming habits. The PDF tutorials in the documentation folder of your TGB install are far, far better.
08/23/2006 (4:25 pm)
Oh I didn't notice you're using the TDN tutorials.Basically, don't use TDN for the tutorials right now. They're generally outdated, broken, or just contain bad programming habits. The PDF tutorials in the documentation folder of your TGB install are far, far better.
#7
08/23/2006 (5:43 pm)
Ha ha, that is good to know. I guess I had better start this tutorial over from scratch :-) Thank you for the info on TDN.
#8
08/23/2006 (8:14 pm)
Do you have the correct var's named & assigned in the level editor to your ship?
#9
As far as I could tell I did have the variables correct and assigned. But I have since started over with the up to date tutorial that came with 1.1.1 :-)
Thank you all for the help though!
08/29/2006 (10:13 am)
Hi Stephen,As far as I could tell I did have the variables correct and assigned. But I have since started over with the up to date tutorial that came with 1.1.1 :-)
Thank you all for the help though!
#10
If you have any further questions feel free to ask, btw thx to everyone in the community for helping him, I love our community :)
P.S. You'll notice that the demos are somewhat to very different than the tutorials. The demos have a whole lot more functionality and serve as a great reference point if you complete the tutorial and want to move on.
08/29/2006 (12:42 pm)
TDN currently is out of date. It is mainly a community driven documentation solution, though we are working on developing an 'official' part of TDN in which we can easily keep docs like this in sync :)If you have any further questions feel free to ask, btw thx to everyone in the community for helping him, I love our community :)
P.S. You'll notice that the demos are somewhat to very different than the tutorials. The demos have a whole lot more functionality and serve as a great reference point if you complete the tutorial and want to move on.
Torque Owner Stephen Howe
i had that same non-firing thing when i first did hte turorial. ends up i made a typo. That's how i found a few typo's (or just not updated text, not sure which) but they work now. i'd check the code sample's that game with the 1.1.1 download. I found those to be 100% right, more so then the tutorial.
could you post your playerShip::createMissile, & your playerMissile::fire functions?