Asteroids Type Starter
by Mitchell Vincent · in Torque Game Builder · 09/24/2005 (11:21 am) · 7 replies
Hello gang, I just got my hands on Torque 2D and wanted to start porting some of my old hobby games that I developed in BlitzBasic and PureBasic over to Torque to get my feet wet.
Honestly, Torque seems too easy! I need a bit of a nudge to help me wrap my head around using the Torque engine instead of doing the raw sprite manipulation.
For example, in my little space shooter (everyone has to make one of those!) my ship tries to act as if it is really in space when the thrust is fired in that it keeps going until an equal amount of thrust is applied in the opposite direction. I would like some hints on how to do that in Torque - I can share the Blitz code if it would help anyone out.
Also, with Blitz you would take a ship sprite and rotate the image to all degrees you wanted it to be able to turn and save it in an array, then based on which way the player was moving you'd display one of the images in the array. I assume this is much easier in Torque, I've just not seen anything but side-scrolling shooters as 2D examples.
It was back in 2002/2003 when I did DootSpace and I've lost all the original source to the finished game. I did manage to find a very, very early version and I posted it at http://www.ksoftware.net/DootSpace.zip if anyone is interested in taking a look to see what I was talking about with the physics of the ship.
Thanks all, I look forward to developing with Torque!
Honestly, Torque seems too easy! I need a bit of a nudge to help me wrap my head around using the Torque engine instead of doing the raw sprite manipulation.
For example, in my little space shooter (everyone has to make one of those!) my ship tries to act as if it is really in space when the thrust is fired in that it keeps going until an equal amount of thrust is applied in the opposite direction. I would like some hints on how to do that in Torque - I can share the Blitz code if it would help anyone out.
Also, with Blitz you would take a ship sprite and rotate the image to all degrees you wanted it to be able to turn and save it in an array, then based on which way the player was moving you'd display one of the images in the array. I assume this is much easier in Torque, I've just not seen anything but side-scrolling shooters as 2D examples.
It was back in 2002/2003 when I did DootSpace and I've lost all the original source to the finished game. I did manage to find a very, very early version and I posted it at http://www.ksoftware.net/DootSpace.zip if anyone is interested in taking a look to see what I was talking about with the physics of the ship.
Thanks all, I look forward to developing with Torque!
About the author
#2
Thanks Stephen!
09/24/2005 (11:52 am)
Yes, the beginner tutorial is great (other than the map not working!). I've gone through it already and it does show use of the SetLinearX/Y function but I didn't realize there was a SetLinearVelocity(). I'll have to dig in and start reading the reference PDF as well!Thanks Stephen!
#3
09/24/2005 (12:27 pm)
Actually, if you wanted space-like behavior, so to speak, you could turn off the ship object's damping, and use setConstantForcePolar() to apply thrust.
#4
Not sure how to do this exactly, but since I'm spending the weekend doing a personal GID and need this type of movement in some circumstances I'll probably wind up figuring it out!
09/24/2005 (12:31 pm)
Yah he's right, because setLinearVelocity is relative to coordinate system, not ship facing. Polar based around the ship's current facing is the way to go for this, although if you want momentum as well, you'll need to do a combination of the two: have the movement input control a velocity vector add to the current ship's velocity vector.Not sure how to do this exactly, but since I'm spending the weekend doing a personal GID and need this type of movement in some circumstances I'll probably wind up figuring it out!
#5
09/24/2005 (12:37 pm)
Psst. Stephen. Reread my post. :)
#6
09/24/2005 (12:47 pm)
@Teck: Hehe..have to remember I've not used T2D much yet, so I'm not sure of the implications of "turn off the ship object's damping"...I'm assuming based on your second response that it does what I described, so...will experiment!
#7
09/24/2005 (12:52 pm)
Oh, sorry. :) I was actually referring to the setConstantForcePolar. That'll do your auto increment of speed for you. Turning off the damping simply allows your object to keep moving after you stop applying directional force.$ship.setDamping(0);
function left()
{
$left = true;
leftSched();
}
function leftStop()
{
$left = false;
}
function leftSched()
{
if($left)
{
$ship.setConstantForcePolar(-100);
schedule(50, 0, "leftSched");
}
}Then just bind your "left" key to the appropriate functions. Modify the values as appropriate. :)
Torque 3D Owner Stephen Zepp
You may want to check out the .pdf files included in your /docs directory (post install), as well as the wealth of tutorials here. I myself am actually spending the weekend learning actual implementation in T2D (as opposed to supporting T2D, which is a bit different!), and my plan is to step through each and every tutorial available--even if it doesn't directly apply to what I want to do-- because I will see tricks and techniques that may be of use to me!
Folks have given demo code in both tutorials and their own "learning" projects for probably dozens of different game styles...look in the "Show Off" forum for some really nice links.