Game Development Community

Is there a more basic tutorial

by BrianS · in Torque Game Builder · 03/04/2006 (7:49 pm) · 17 replies

I purchased T2D with great expectations and still have much expectation to being able to develop some cool casual games quickly.

I am not shy about coding as I've been a C++ software engineer 15 years -- my issue in getting started with T2D is the lack of good tutorials or even general How To manual.
I started the checker board tutorial but found it was a bit all over ... is there a small write up anywhere on the general contruction/layout needed in developing a T2D game? For example the directory layout, files expected etc.

About the author


#1
03/04/2006 (8:27 pm)
The Basic Tutorial is a great start... The Checker's Tutorial is mainly targeted at setting up a turn based network game, though its still a good framework for a game. TDN has a good section for T2D tutorials, especially the Platformer, Strategy, and Tetris ones.
#2
03/05/2006 (4:54 am)
I did find the Basic Tutorial.pdf but cannot get past the very first sprite addition ... I don't know if it is the folder hierarchy or what but suspect something with the path statement in line

datablock t2dImageMapDatablock(playershipImageMap)
{
imageMode = full;
imageName = "~/data/images/playerShip";
};

I'll give it another few days but was really in need of a basic prototyping tool for testing game play before commiting project resources.

Is there a document anywhere describing the folder hierarchy and what pieces need to be where or even a process flow diagram of how it all fits together -- something that paints a high level look at the environent?
#3
03/05/2006 (6:28 am)
What error are you getting BrianS? If you drop down the console and look for any RED text it will indicate which file and line in script the problem is occuring at.

I've just checked the beta dir and looking in T2D/data/images/ there is no playerShip file, instead theres a file called "ship" so perhaps that is your problem.

Either way, check the console or the console.log file (which is just a plain text file) and find the error. That way you'll know what to look for if you have any further problems.
#4
03/05/2006 (6:32 am)
You are correct -- the incorrect naming of playeShip and ship was wrong and did flag an error in console.log
I've corrected that and now have no error showing up in console.log but still no sprite on the screen :-(
#5
03/05/2006 (6:41 am)
If you copy over the images from the SpaceScroller data folder, there is a playerShip image, and that's the one you would want for the tutorial.

If you look down the tutorial to "Creating a Sprite", the screenshot there shows the playerShip image from the SpaceScroller demo. :)
#6
03/05/2006 (6:47 am)
@BrianS: Not trying to make any excuses here, but you've come in to TGB during a period of incredibly huge amounts of modifications and flux.

A couple of months ago (after all of the tutorials were written), the community almost unanimously requested that we provide point releases of code as it was being worked on, instead of the traditional major releases (with major changes and functionality adds), so we began releasing alpha (and now beta) code releases extremely rapidly...sometimes even two in one week.

Unfortunately, this also means that the tutorials simply haven't caught up yet. They will be I assure you, but currently they simply are behind the code base, and need some time to catch up. If you can be patient for just a few more weeks, I know that things are going to get better on the learning side of TGB!
#7
03/05/2006 (6:57 am)
From Stephen Zepp
@BrianS: Not trying to make any excuses here, but you've come in to TGB during a period of incredibly huge amounts of modifications and flux.


Thanx Stephen -- as a seasoned C++ Software Engineer (15+ years) I can certainly understand the need to pre-release. However in general SDLC governed processes the normal would be beta then alpha with an understanding at the community level of a purchased release being alpha.

It has not been a good weekend ... all I wanted was a quick to do framework to help prototype some game mechanics for testing likeability factor.

My first mistake was buying the wrong Torque product (game engine i think) so there was a first 100 dollars I had to eat. Then when I did find the right product and purchased it (another 100 dollars) I find a day later it is really still knee deep in development. As I said I certanly understand the need to release for testing but do also understand I am now 200 in the hole on a budget of my own time and money and the only winner here is Garage Games with two sales and some free QA testing from me and others.


Sorry I am sounding negative above when I should also point out the positive...I do want to say thanx Stephen for looking at this on a weekend -- that says a mountain amount for Garage Games in terms of Support.
#8
03/05/2006 (7:01 am)
The basic tutorial is slightly out of date. As Tom mentioned, grab all the images from games/spacescroller/data/images. Copy them into your games/t2d/data/images folder. Then in your game.cs file the setupT2Dscene() function should look like this:

function setupT2DScene()
{
   // Create our scenegraph
   new t2dSceneGraph(t2dScene);

   // Associate Scenegraph with Window.
   sceneWindow2D.setSceneGraph( t2dScene );
   
   // Set the current camera position
   sceneWindow2D.setCurrentCameraPosition("0 0 100 75");
   
   datablock t2dImageMapDatablock(playershipImageMap)
   {
   imageMode = full;
   imageName = "~/data/images/playerShip";
   };
   
   $player = new t2dStaticSprite() { scenegraph = t2dScene; };
   $player.setPosition("-35 0");
   $player.setSize( "14 7" );
   $player.setImageMap( playershipImageMap );
}

I just tried it out, it renders the sprite on the screen.
#9
03/05/2006 (7:03 am)
Without even trying I think I see the error -- all the code is in the setupT2DScene when in my case that was not the case.
BTW in your post how did you seperate the code from the posted message ? What bbCode did you use?
#10
03/05/2006 (7:09 am)
It's [ code ] and [ /code ] (as well as [ quote ] and [ /quote ]) but without the spaces.

FYI on the license issue: I've forwarded off your email to the appropriate folks, but unfortunately as you noticed it is a weekend! I then noticed yesterday that you went ahead and bought TGB anyway, so I'm honestly not sure how we'll be able to work that out, but hopefully you'll get a response tomorrow.

EDIT: P.S.: I've posted some troubleshooting steps to your current issue BrianS in this thread...if we can consolidate there hopefully we can get you sorted out.
#11
03/05/2006 (7:35 am)
Quote:FYI on the license issue: I've forwarded off your email to the appropriate folks, but unfortunately as you noticed it is a weekend! I then noticed yesterday that you went ahead and bought TGB anyway, so I'm honestly not sure how we'll be able to work that out, but hopefully you'll get a response tomorrow.

Yup that is me -- if you look at the transaction times you will see I found out almost immediately I had bought the wrong one. I had clicked on a banner I thought said T2D but after receiving the email saw that it was some other Torque product. I wanted to get started and went ahead revisted the page and place the right order. I do hope I can get the 100 back. Thanx for your help

I was able to get the Sprite up and running.

I changed my code from :

function setupT2DScene()
{
    // Create our scenegraph
    new t2dSceneGraph(t2dScene);

    // Associate Scenegraph with Window.
    sceneWindow2D.setSceneGraph( t2dScene );

    // Set the current camera position
    sceneWindow2D.setCurrentCameraPosition("0 0 100 75");
}


datablock t2dImageMapDatablock(playershipImageMap)
{
    imageMode = full;
    imageName = "~/data/images/playerShip";
};


$player = new t2dStaticSprite() { scenegraph = t2dScene; };
$player.setPosition("-35 0");
$player.setSize( "14 7" );
$player.setImageMap( playershipImageMap );

To

function setupT2DScene()
{
    // Create our scenegraph
    new t2dSceneGraph(t2dScene);

    // Associate Scenegraph with Window.
    sceneWindow2D.setSceneGraph( t2dScene );

    // Set the current camera position
    sceneWindow2D.setCurrentCameraPosition("0 0 100 75");


    datablock t2dImageMapDatablock(playershipImageMap)
    {
	    imageMode = full;
	    imageName = "~/data/images/playerShip";
    };


    $player = new t2dStaticSprite() { scenegraph = t2dScene; };
    $player.setPosition("-35 0");
    $player.setSize( "14 7" );
    $player.setImageMap( playershipImageMap );
}

That was all I needed to do - now onto other work of putting a button on the screen and responding to a click event.
#12
03/05/2006 (7:44 am)
BTW -- what is the coordinate system ? Looks to be polar or rather the origin is center screen 0,0 ??

Two quick questions:

How do you edit a .gui within the editor? I can do a New and Save but once created I can only edit from notepad?

Also I have button sprites I am now trying to add to the screen - their image size is just 54x54 pixels but calling setSize produces a much larger than expected image.

// setup cells
    $btn00 = new t2dStaticSprite() { scenegraph = t2dScene; };
    $btn00.setPosition("0 0");
    $btn00.setSize( "54 54" );
    $btn00.setImageMap( Cell );
#13
03/05/2006 (7:48 am)
That can be done in several ways...primarily via creating a GUIObject using the GUI editor by making a GUIBitMapButton class (old school technique), or you can explore the ability to actually click on t2dSceneObjects themselves via the ability of a t2dSceneWindow to both pass mouse events to objects, and "pick" objects via mouse click.

I highly suggest you run through the TDN Gui Button Tutorial (note: slightly older tutorial, somewhat outdated, but gives the general jist) for the first technique, and the very useful Object Selection 1 and Object Selection 2 tutorials--I've used these myself in just the last week, and they were cut/paste tutorials into my project. Some very minor issues (in the second tutorial occasionally the object gets very far away, and takes quite a while to move to the mouse pointer), but they are very demonstrative of several fundamental TGB techniques.
#14
03/05/2006 (7:52 am)
If you look at the call to setup camera you'll see it uses "0 0 100 75". This tells t2d to setup a coord system where 0,0 is the center of the screen with a width of 100 and height of 75. So -50 to 50 in x and -37.5 to 37.5 in y.

For the sizing, "54 54" would set the image to 54x54 units not 54x54 pixels. T2D works with an abstracted coord system (100x75 units) basically so you don't have to worry about resolution changes.
#15
03/05/2006 (7:59 am)
Regarding coordinate systems, Melv has a very nice explanation here in the forums.

For the most part you are correct, 0,0 is the center of the sceneWindow.

For your images, you are probably confusing the concept of a t2dSceneObject's "size" parameter (in world units), with the cellSize parameter of the imageMap itself.

To set the imageSize (cell size), you change the values in the imageMap definition:

datablock t2dImageMapdatablock(CellImageMap)
{
	imageName = "~/data/images/cell";
	imageMode = cell;
	cellWidth = 54;
	cellHeight = 54;	
};

Then, your instantiation would be:

// setup cells    
  $btn00 = new t2dStaticSprite() { scenegraph = t2dScene; };    
  $btn00.setPosition("0 0");    
  $btn00.setSize( "1 1" );    
  $btn00.setImageMap( CellImageMap );

By the way, based on your naming convention, I'm guessing here that what you are really trying to do is what we call a tilemap, so if my guess is correct, I suggest you take a look at theTDN Tilemap Editor Tutorial.
#16
03/05/2006 (8:09 am)
Quote:
If you look at the call to setup camera you'll see it uses "0 0 100 75". This tells t2d to setup a coord system where 0,0 is the center of the screen with a width of 100 and height of 75. So -50 to 50 in x and -37.5 to 37.5 in y.

For the sizing, "54 54" would set the image to 54x54 units not 54x54 pixels. T2D works with an abstracted coord system (100x75 units) basically so you don't have to worry about resolution changes.

I thought as much and used similar in the past -- I assume there is a conversion rate constant to use for translating pixel size/coordinates to Torque Units?

I think the problem I am seeing in the screen being larger than the image has to do with it running within the TDK Window instead external to the TDK Window. The TDK Window is set to 1280x768 while the application is just 640x480 so everything is stretched out.
#17
03/05/2006 (9:19 am)
I gave your suggestion a try and the image came in at a 1 1 pixel width and height which with units 0 0 100 75 seems completely odd. I retried .setSize("54 54") and that looked to be scaling relative to 0 0 100 75 -- confusing. I will have to read up on the scaling article you recommended.
This is a tic tac toe game I am putting together to learn the basics so I have nine buttons that respond to a mouse click displaying an X or O sprite.


Quote:
Regarding coordinate systems, Melv has a very nice explanation here in the forums.

For the most part you are correct, 0,0 is the center of the sceneWindow.

For your images, you are probably confusing the concept of a t2dSceneObject's "size" parameter (in world units), with the cellSize parameter of the imageMap itself.

To set the imageSize (cell size), you change the values in the imageMap definition:


datablock t2dImageMapdatablock(CellImageMap){ imageName = "~/data/images/cell"; imageMode = cell; cellWidth = 54; cellHeight = 54; };

Then, your instantiation would be:


// setup cells $btn00 = new t2dStaticSprite() { scenegraph = t2dScene; }; $btn00.setPosition("0 0"); $btn00.setSize( "1 1" ); $btn00.setImageMap( CellImageMap );

By the way, based on your naming convention, I'm guessing here that what you are really trying to do is what we call a tilemap, so if my guess is correct, I suggest you take a look at theTDN Tilemap Editor Tutorial.