Game Development Community

Tutorial blues

by Ryan Bartig · in Torque Game Builder · 03/19/2005 (12:50 pm) · 11 replies

Ye flipping gods. Trying to work my way through the tutorial and am not having good success with os x. The debug statements aren't even working. I've pasted the small bit of source from the tutorial below, any pointers would be more than helpful. I've double checked the tutorial vs. the source and am coming up with zilch. If it is bombing on a line X how do you get it to pipe up and scream "HEY, LINE X IS WHACKED!"?

The enemy missile only fires from the middle of the screen and for some reason and the scrolling isn't working. I did copy the files and double checked the paths. Boy do I feel dumb right now.

TIA.


function CreateTileMap() {

%scrollerMap = new fxTileMap2D() { scenegraph = t2dSceneGraph; };

%scrollerMap.loadTileMap("~/client/maps/scroller.map");

%skyLayer = %scrollerMap.getTileLayer( 0 );

%skyLayer.setPosition( "0 -10" );
%skyLayer.setTileSize( "25 25" );
%skyLayer.setWrap( true, false );
%skyLayer.setAutoPan( "10 0" );
}

function CreateEnemy() {

%enemy = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
%enemy.setImageMap( enemyship1ImageMap );
%enemy.setSize( "14 7" );
%enemy.setPosition("40" SPC (-30 + (getRandom() * 60)));
%enemy.setWorldLimit( kill, "-60 -40 60 40" );

%enemy.setLinearVelocityX(-20);

%enemy.setGroup( 2 );
%enemy.setLayer( 2 );
%enemy.setCollisionActive( true, true );
%enemy.setCollisionMaterial( standardMaterial );
%enemy.setCollisionPolyCustom( 5, "-0.9 0 0 -0.6 1 -0.3 1 0.3 0 0.5" );
%enemy.setCollisionMasks( BIT(1), BIT(1) );
%enemy.setCollisionCallback( true );

%enemyFire = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
%enemyFire.setPosition( %enemy.getPosition() );
%enemyFire.setSize( "3 1.5" );
%enemyFire.setImageMap( enemymissileImageMap );
%enemyFire.setLinearVelocityX( -35 );
%enemyFire.setWorldLimit( kill, "-60 -40 60 40" );

%enemyFire.setGroup( 2 );
%enemyFire.setLayer( 2 );
%enemyFire.setCollisionActive( true, true );
%enemyFire.setCollisionMaterial( standardMaterial );
%enemyFire.setCollisionScale("0.9 0.5");
%enemyFire.setCollisionMasks( BIT(1), BIT(1) );
%enemyFire.setCollisionCallback( true );

schedule(2000, 0, "CreateEnemy");
}

About the author

Recent Threads


#1
03/19/2005 (12:55 pm)
The console.log file will you where problems are with your scripts.

If there's an error, the compile will fail and T2D will use the last compiled version (the .dso file).
#2
03/19/2005 (1:00 pm)
Ryan, yes, please paste your console.log file (or, preferably, not the whole thing but any errors reported) and we can help you solve them.
#3
03/19/2005 (2:13 pm)
I wasn't aware of the console.log file (I'm so new to this that I just broke through the shell). I checked it out and found the following error:

Compiling T2D/client/client.cs...
T2D/client/client.cs Line: 113 - Syntax error.
>>> Advanced script error report. Line 113.
>>> Some error context, with ## on sides of error halt:
^// Create images for the tilemap datablock
^fxImageMapDatablock2D(bgBlankSkyImageMap) {##
##^^mode = full;
^^textureName = "~/client/images/bg_blank_sky";
^};
>>> Error report complete.

I changed

// Create images for the tilemap datablock
fxImageMapDatablock2D(bgBlankSkyImageMap) {
mode = full;
textureName = "~/client/images/bg_blank_sky";
};

to

// Create images for the tilemap datablock
datablock fxImageMapDatablock2D(bgBlankSkyImageMap) {
mode = full;
textureName = "~/client/images/bg_blank_sky";
};

and everything worked great! I'm finding the basic tutorial extremely helpful (except the collision section). Thanks for the info.
#4
03/19/2005 (5:23 pm)
Glad you got it working, the console.log file is extremely usefull, also when you are in engine, after you start up, if something doesn't work right, hit the "~" tilde key and see the console text... here that whole section that it errored out on with the "##" would be in red text while the rest would be in black... now every time I work in Torque (2D or 3D) first thing I do when I fire up the engine is hit the console key and scroll up and down real quick to look for red text :)
#5
03/19/2005 (8:31 pm)
I'm still having the problem that all enemy missiles are created in middle of the screen. Enenmy ships are correctly spawned at random locations. My code to set the missile position at launch is:
%enemyFire = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
%enemyFire.setSize( "3 1.5" );
%enemyFire.setImageMap( enemymissileImageMap );
%enemyFire.setLinearVelocityX( -35 );
%enemyFire.setWorldLimit( kill, "-60 -40 60 40" );
%enemyFire.setPosition( $enemy.getPosition() );

I had hoped the setposition line would give the correct starting position for the missile but they always spawn at the same position.

thanks.
#6
03/19/2005 (8:40 pm)
Shouldn't

%enemyFire.setPosition( $enemy.getPosition() );

be

%enemyFire.setPosition( %enemy.getPosition() );
#7
03/19/2005 (9:31 pm)
Yes it should!!!!!!!! I looked at that line a million times and never saw i typed a $ instead of a %

thanks Matthew!

john
#8
03/19/2005 (9:33 pm)
Np... sometimes it takes a different set of eyes :)

EDIT: and as I'm sure you guessed, receiving false location data it just defaulted to the worlds origin of 0,0
#9
03/20/2005 (8:17 am)
I know % is in reference to an object, but what's $ used for?
#10
03/20/2005 (8:21 am)
% - local variable (within a function or the like)
$ - global variable
#11
03/20/2005 (8:36 am)
Makes sense now, thanks.