Game Development Community

dev|Pro Game Development Curriculum

Game Starter Kit For Torque X 2D

by Henry Shilling · 01/15/2010 (11:53 am) · 25 comments

I recently got iTGB so I can start making iPhone games, if you have not tried objective C its worth it just to feel the smugness come through even in code. I have been using TorqueX for XNA and was pretty impressed with how well it streamlined the process.

Learning iTGB I was impressed with the library of included behaviors that made the process quick and easy to get a decent prototype up and running in no time. I had a bit of a library of TX2D components from my experiments and thought it would be great to have a similar toolkit, besides making it easier for me to move stuff to the iPhone. So here is my first pass at a game starter kit for TX2D. I basically cloned some of the behaviors from TGB for TX2D.

You can grab the files and get started, I have written some documentation at the top of each file that describes in some sense how it works. You can also read on where I will try and do a better job of documenting.

I have split the files into three folders, three different types of components. AI: Basic enemy stuff, Gameplay: Stuff that makes games, Input: stuff to control your player.

AI: This is all stuff for your targets, your enemies, or other things that are not under player control.
ai_DirectVelocity: The object will move at a speed in a straight line, you can also rotate the way the object faces so that it doesnt have to move in the direction it's facing.
ai_FaceObject: The object will rotate at a set speed to face a named object, like the player, maybe to watch you or possibly shoot you.
ai_MoveTowards: Moves towards a named object, like the player, see where we are going with this?
ai_RandomVelocity: This is a cool one, I used it in the asteroids demo. Variable range of direction, speed and rotation. I am certain you will come up with other uses for this one.
ai_SpawnArea: Drag a blank scene object onto the screen, add this component and it becomes a configurable spawn machine. It can spawn stuff from the center, randomly anywhere within the area, from the edges, from one edge.
ai_SpawnOnRemove: When the object is killed or whatever it will spawn a number of other objects, or even a clone of itself if you are so inclined. Blow up the spaceship and it can spawn a number of escape pods, lots of cool stuff. This one taught me that _OnUnregister is called when you unload a scene. If you look at the code you can see how I got around that issue.
ai_TimerShoots: The object will shoot repeatedly based on a timer, with a variance tossed in for fun.

Input: There is so much more you can do than just use the default movement component. I have also added a checkbox to automatically attach the camera to the player, plus added shooting controls.
in_AlignToMovement: Pretty much your standard steer with the stick and the object goes where you are pointing movement.
in_AsteroidsControls: Stick left and right rotates the player, forward and back accelerates forward and backward. Like Asteroids, get it?
in_ShooterControls: Move your player around without rotation, like the old school shooters.
in_TankControls: Asteroids controls without the constant acceleration. Let go of the control and the player stops.

GamePlay: These are necessary for game play, I'd advise against removing them. I have a static random that is used by other components, as well as other delegates used by the components.
gp_DealsDamage: The object will damage whatever it hits, like for a bullet or missile.
gp_TakesDamage: The object takes damage when hit by a damage dealing object.
miscDelegates: The damage dealing delegate lives here, I have also added a delegate to to do world limit wrapping. This also contains the random function I use everywhere else, don't remove this file.
gp_PlayerComponent: This is the component that would have controlled the game, I was debating putting it in here as it's not really finished. But its a start, based on Space Warrior game.

I have also included 3 simple examples, that you can pick apart to see how the components are used. Pay attention to collisions, if your bullet collides with your gun, you will have problems. I also really don't use much error checking, because I don't make errors (heh yea) I have also made the back button on the gamepad exit the demo to the menu. I am betting that I am not doing it right and this will cause problems if you do it the same way. Mostly I don't remove the input map but then it gets re assigned anyway, maybe it is alright. I am certain someone will correct me on this... O.o

I'll try to add to this sometime in the future, as well as I wanted to create the demos that will work with the CC version, as it stands right now it won't. However if you start a project from scratch, drag the GameKit folder to your project and you can use it with the CC version of TX.

Torque X 2D Game Kit for 3.1.5

Have fun and I look at the forums almost every day if you want to get in touch.

Quick Edit: I got the version that works with the XNA CC torque included.




About the author

http://twitter.com/theBigDaddio

Recent Blogs

Page «Previous 1 2
#1
01/15/2010 (3:57 pm)
[quote]...if you have not tried objective C its worth it just to feel the smugness come through even in code.[/quoted]

L...O...L! =)

Great resource
#2
01/17/2010 (10:27 am)
Michael, your [/quoted] is supposed to be [/quote] :)
#3
02/20/2010 (3:15 pm)
hey thanks for this stuff it's helping me make my game, have you checked out kalanakis's components on his envygames website? there's alot of overlap between your stuff.

I'm interested in your spawner, specifically giving it the ability to reset its spawn counter, I imagine I can do this pretty easily, do you have plans work on your spawner?

well I added the stuff I needed to make it work, pretty easy too lol.
[TorqueXmlSchemaType(DefaultValue = "5")]
        public float TimeBetweenWaves
        {
            get { return _timeBetweenWaves; }
            set { _timeBetweenWaves = value; }
        }
        [TorqueXmlSchemaType(DefaultValue = "true")]
        public bool KeepSpawning
        {
            get { return _keepSpawning; }
            set { _keepSpawning = value; }
        }

you can set the object to keep spawning multiple waves or not. and in the components process tick method,

_endOfWaveCountDown += dt;
            if (_currentCount >= _spawnCount && 
               _keepSpawning && 
               (_endOfWaveCountDown >= _timeBetweenWaves))
            {
                _currentCount = 0;
                _endOfWaveCountDown = 0;
                
            }

The code just checks if the spawn number has been reached and if the time between waves has been reached as well, if so then the numbers are reset and the spawner spawns again.

add these variables to the end, I sometimes forget to do this lol.

float _timeBetweenWaves = 5.0f;
float _endOfWaveCountDown;
bool _keepSpawning = true;
#4
02/20/2010 (4:53 pm)
Of course I have, I have Johns book. You can do whatever you want, I have used TGB quite a bit and wanted to mimic some of the stuff that was available with TGB when you bought it.

The biggest thing I did differently was the way I handle the damage dealing, if you use Johns weapons component, the collision delegate is inside the component, it's static as well as the variables. So whatever you set the HP of damage top will be used on EVERY object that uses that component.

BTW I found an error in one component, Spawn on remove the _spawnStuff should read:

T2DSceneObject theSpawn;

for (int i = 0; i < _count; i++)
{
    theSpawn = _spawnObject.Clone() as T2DSceneObject;
    int _direction = miscDelegates.statRand.Next(360);
    theSpawn.Position = _sceneObject.Position + (T2DVectorUtil.VectorFromAngle((float)_direction) * (_offset * (float)miscDelegates.statRand.NextDouble()));
     TorqueObjectDatabase.Instance.Register(theSpawn);
}

I don't know what I was thinking with the code I put in there?



#5
02/21/2010 (12:05 am)
hi, I was trying out your deals and takes damage components, I think they have performance problems. When I put the takes damage component on an enemy I can use your spawner to spawn around 70 of them before I see framerate slowdown, but if I take it off I can spawn hundreds with no problems. I will look into your component some more since I would like to be able to set how many hit points my enemies have and stuff.
#6
02/22/2010 (6:41 am)
hmm I don't know what it could be they don't even tick. The only time they execute any code is when there is a hit, then they do quite a bit. I haven't found any issues on the Xbox or the PC. But then my PC is an i7.
#7
03/07/2010 (12:30 pm)
I tried running it in Visual Studio but it comes up with the error can't find namespace for GarageGames. Is there something I need to add to Visual Studio in order to run it?
#8
03/07/2010 (12:51 pm)
You need to add the Garage Games folders to the project, if you are using the source version, if you are not using the source version then you need to update the Refences to point to your GG binaries. Usually in C:\Program Files\Common Files\GarageGames\TorqueX if you are running 64bit the folder will be Progam File (x86)

#9
03/07/2010 (1:45 pm)
I went and added a Reference path to the Torque X folder like you said and still getting errors. Here an error I'm getting:

Error 1 The type or namespace name 'GarageGames' could not be found (are you missing a using directive or an assembly reference?) C:UsersDavidDesktopGameKitTestGameKit_CCGameKit_CCGameGameKitaiai_RandomVelocity.cs 27 7 Game
#10
03/07/2010 (2:14 pm)
Which version are you using GameKit_CC or GameKitTest? If you are using CC are you using CC 3.0 or CC 3.1.4?

If you are using CC 3.1.4 then use the GameKitTest version not the CC version.

Oh yea and point to the actual file in the reference: C:\Program Files (x86)\Common Files\GarageGames\Torque X\v3.1.4.0\References\x86\GarageGames.TorqueX.Framework.dll

AND

C:\Program Files (x86)\Common Files\GarageGames\Torque X\v3.1.4.0\References\x86\GarageGames.TorqueX.Framework2D.dll

#11
03/07/2010 (3:47 pm)
I'm using 3.1.4 and was using GameKit_CC so gues thats what the problem is. I tested it and it worked. Only question is that in the Asteroid game Planetoid game is your character suppose to keep moving or stop when you stop pressing the button for the direction you want as mine continues to move when I'm not pressing anything. Besides that really good work and thanks for your help. :)
#12
03/09/2010 (7:01 pm)
Hey Henry...I just saw you reference this kit on the CC forums.

I don't own TGB or TGBi...so I'm not sure what a "behavior" is? Is it something like a TX component?

I've got major game developer's block going on. I want to start a new project...but I don't know which of the 300 ideas I have running around my skull that I want to take a stab at.

So I'm trying to look at different tools and kits...and see if any new feature compels me toward one direction or another.

Thanks...
--RB
(Chapel on CC forums)
#13
03/09/2010 (7:17 pm)
Yes basically behaviors can be thought of as TorqueComponents, however it was an older deal with scripting. Check out the asteroids demo on TDN, thats what got me started with this process.

The kit is a bunch of components you can can use out of the box to start building a game, they provide basic game functionality that I saw as missing.

#14
03/10/2010 (5:35 am)
Henry...I have a question that you might be able to answer. I think you've been involved with Torque X for a while, and I know you've released a couple of XBLIG titles.

How does Torque X fair in terms of overhead? What's the size of the typical .ccgame binary? Were your titles over the 50MB limit for the "lowest price point" option?

I guess I'm assuming you're XBLIG titles were done using Torque X...is this a correct assumption?

Thanks
--RB
#15
03/10/2010 (10:18 am)
The overhead is negligible, really, the binaries once compiled are less than 1M. My last game was around 10M, then I added 30M of music. very easy to keep under the 50M limit. My current game is 5x as complex has 10x as many assets and is still under 20M.

#16
03/10/2010 (1:00 pm)
Thanks for the info...10MB plus 30MB of music sounds like my first XNA game. :)

So I understand you're on the beta test team for TX products, is that correct? What's your feeling on the direction of the TX offerings?

I know John K is hard at work trying to get things unified between the Torque arena and the Torque X arena...but it seems like he's got a really long road ahead of him.

It also looks like the ancillary product offerings aren't really "there" yet. There's only 1 genre starter kit and it's 2D only...there are no lighting tools...it just seems like TX products are the redheaded stepchild of GG.

Am I wrong here? Is there a real commitment to improving the offering and extending the capabilities?

The road map that John blogged about seemed promising to start...but he's already late on the 3.2.1 release and mentioned something about an interim release that doesn't seem likely either.

I feel for the guy...I do this for a living...and I know the pitfalls of trying to please everyone (no good deed goes unpunished). You just end up setting artificially high expectations and failing to hit the mark.

What are your thoughts on this?

Thanks
--RB
#17
03/10/2010 (2:18 pm)
I really don't know much more than you do, being a beta tester doesn't mean they communicate with me any more unless there is a beta. I have not seen anything yet, no blog post either. This is a bad week for GG communications they are all mostly at GDC.

Supposedly TX is supposed to become the entry level torque engine. I believe GG has a commitment to it.
#18
04/04/2010 (1:27 pm)
thanks
#19
07/27/2010 (2:58 am)
Updated for 3.1.5 added UI and Sound
#20
08/06/2010 (3:53 am)
Thanks for this Henry. Just dropped in the splash screen and main menu; going to add the rest one piece at a time.

Sweet!

EDIT: I get the following error when I run the gamekit using 3.1.5:

{"The current profile does not have an XNA Creators Club membership, which is required to sign in to the Live service. To continue, purchase a membership from Xbox Live Marketplace, or switch to a local gamer profile."}

I can't seem to find anywhere to set the profile or switch to a local profile. Any idea?
Page «Previous 1 2