Game Development Community

Helpful hints for learning

by Anthony Farmer · in Torque X 2D · 05/20/2008 (10:13 am) · 5 replies

Hello.

I'm creating a sample application to compare & constrast straight XNA 2.0 programming with TorqueX 2.0 programming and could really use some pointers because it's not at all obvious to me what I need to do to get this up & running using TorqueX. I got it up & running in about 20 hours with straight XNA and SpriteBatch.Draw().

My test project is essentially "Wheel of Fortune" with four players around the wheel (top, left, bottom, and right edges of screen). I want to click & drag the mouse to spin the wheel and have it accelerate & decelerate "realistically". When it stops, the value on the wheel for each player is printed next to their names. All the text is rotated appropriately for someone looking forward at that particular edge of the screen, so (for example) the text at the top of the screen is "upside down".

Implementing this with straight XNA was pretty simple. I loaded a background bitmap and the foreground wheel bitmap is a .png file with alpha built-in. For whatever reason I couldn't get a 32-bit .BMP to export properly out of Photoshop, but the .png works great. I then track the mouse as it's pressed and when they let go of the button I spin the wheel. When it stops, I print whatever text is appropriate next to each player.

How do I go about doing this in TorqueX? It's completely 2D (I've no desire to get into 3D at this time), but even the first steps aren't obvious. How do I get the bitmaps into my TorqueX project? Through Visual Studio or through Game Builder? Once they're in, how should I load them, draw them, and manipulate them? How can I use the built-in Physics support to model/simulate the wheel spin?

In theory, it should be much easier to do this with TorqueX than straight XNA, so I think I just don't "get" the TorqueX paradigm or something. None of the sample apps seem to do anything like what I'm trying to do and the apps that I've opened have hardly any C# code at all so I'm not sure how they even function.

Anyhow, I'd appreciate general pointers for what parts of what documents to read so that I "get it" with TorqueX but I'd like to get some references to specific classes or sections of sample code as well. For example, what TorqueX classes should I use to load & draw the sprites? The text?

Thanks much,
ALF

#1
05/20/2008 (2:23 pm)
Just a quick follow-up to clarify a few things, as it's not like I've made NO progress -- just that I'm still trying to understand the paradigm.

Once I created a blank project, I opened the project file in TGB and added my two bitmaps. I saved the project file and the default level file, rebuilt, and was able to see my background image. I'm just not sure what to do after that.

Also, my application needs to run in Windowed mode on a very specific video card at 1024x768x32. The default camera is set up at (x=-0.943, y=-1.958) and width=100.00, heigh=75.00. While that aspect ratio is correct, I need BORDERLESS window that's exactly 1024x768 and my background image is 1024x768 so it needs to be at (0,0) within the camera's view. How do I make that happen?

None of the parameters I see within TGB seem to let me touch window width & height, and I don't know the relationship between world units and screen pixels so I'm not sure how big 100x75 really is. It does appear to be smaller than my bitmaps, however, and I don't wish to scale my bitmaps at all because they're set up at very specific sizes for layout reasons.

Once again, your help is appreciated...
#2
05/20/2008 (3:21 pm)
When you drug your bitmap/material into your scene, it created a T2DStaticSprite. T2DStaticSprites have properties for size and position. Edit these properties by clicking the Edit tab, above the materials pane.

The size of your game window is determined in torquesettings.xml. Edit the backbuffer settings in that file.

For camera position: click anywhere in your scene so you aren't selecting any objects. Go to the Edit tab.

To make your wheel spin: Does your wheel's T2DStaticSprite have a T2DPhysics component? Edit the AngularVelocity property of the physics component.

Almost everything TXB can create/edit is saved to the .txscene file. This is an XML file. You can open it and edit any property for any object in the scene. For example, you could open it and find to change the camera's position to 0,0.

To give your wheel custom behavior you need to create a new component in Visual Studio. This component would modify the AngularVelocity during a tick callback or in response to player input. Open the TankBuster sample in the Demos folder to see how this kind of stuff works. Once you've written a component and rebuilt the project, the component will appear in the dropdown in TXB on the Edit tab, you can add the component to your wheel this way.
#3
05/21/2008 (2:41 pm)
I don't see T2DStaticSprites anywhere in Visual Studio, the Scene file, or TGB. Is there more than one way to drag a bitmap into a scene? Because all it created was a Material for each bitmap.

Cheers,
ALF
#4
05/22/2008 (12:07 pm)
Well forget about what they're called for now. Just drag something from your list of materials into the scene, then click the Edit tab.
#5
05/23/2008 (10:08 am)
Thanks! Got the static sprites.

I'm still looking into the physics piece and don't yet follow what's going on with TankBuster. It's got a ton of stuff I don't need for what I'm doing so I need to narrow the scope a bit. In addition to a T2DPhysics component, do I need a T2DForce component?

Also, in TGB I tried assigning an angular velocity to the wheel with the assumption it'd just be spinning at that rate when the application starts. But instead, I see the wheel for a fraction of a second and then it goes blank (or goes away, not sure which). What's up with that?

Thx,
ALF