Game Development Community

Asteroids game

by Vladaboy Mx · in Torque Game Builder · 09/24/2007 (10:59 am) · 25 replies

Im tring to make something similar to this, firs of all i would like to import my image with no background.... i already made my image ( the plane)with the color background pink : ) and it doesent work??? i need help with this problem.

About the author

Page «Previous 1 2
#1
09/24/2007 (11:09 am)
What doesn't work? If you still have the background, use a .PNG file instead since it supports transparency.
#2
09/24/2007 (11:11 am)
I know

But it still doesent work!!!!!!!!!
#3
09/24/2007 (11:17 am)
OK, you're going to have to be more specific. "It doesn't work," is not helpful. What are you doing and what isn't working?
#4
09/24/2007 (11:26 am)
Well lets putt it this way i tried anithing from convering it to PNG to JPEG/JPG and i even did the holle backroung again so taht it;s the same color (pink) and it still doesent work!
#5
09/24/2007 (11:39 am)
OK, I'm going to try this just one more time.

What doesn't work? Are you able to get it into the editor, but not into a map? Are unable to get it into the editor at all?

What steps are you taking? You didn't ever tell us what you are doing. Step by step, tell us how you are trying to get a new .PNG file into your project.
#6
09/24/2007 (11:50 am)
I'm sorry if you didnt understand...

but the problem is that i can load the image with no prob, but the pink background still can be seen.
But what i also dont understand is how are the "TGB images" that come with the engine all trransparent and mine are not?
#7
09/24/2007 (12:00 pm)
OK, that's a better explanation. Now I understand the problem. You believed, and understandably so, that pink would be transparent. Many games used to be that way. PNG actually has a transparent value. Use an editor that supports PNG files and transparency and you'll be set. If you are unsure of one, I use Paint.NET from http://www.getpaint.net. The specific attribute is tRNS. TGB handles it quite nicely.
#8
09/24/2007 (12:42 pm)
Wow. How did you find out about Paint.NET? It looks like a nice piece of software.
#9
09/24/2007 (5:14 pm)
Well, I needed something to edit sprites and clean them a little bit and tried a ton of things, that was the best one. There are a few nicer ones out there, but they weren't free.

Let me know if that fixed your problem.
#10
09/25/2007 (11:35 am)
Yea i did it! thanks a lot!

i wILL keep developing my game utill i reach anoter problem !!!!
#11
09/27/2007 (4:07 am)
Yup i reached another dead end :(

I need help with the 360 movement code.

I made it work but the problem is that the moving function doesent repet itself, and it should cause it must update the $tenk.getRotation() variable, what it does in my code is it just takes the $tenk.getRotation() ONCE and when i press the letter "w" or "s" it just takes it ONCE and it doesent work properly :(

here is my code:

dont bother about the names of functions and thet stuff i'm a forener :) i dont make eanglish names of variables and functions :)

function tank::onLevelLoaded(%this)
{

namestiKomande();
$tenk=%this;
$t_ugao=$tenk.getRotation();
$tenk.brzina = 10;
$tenk.rotacija = 100;
}


function namestiKomande(){
moveMap.bindCmd(keyboard, "w", "kretanje($tenk.brzina,$t_ugao);", "kretanje(0);");
moveMap.bindCmd(keyboard, "s", "kretanje(-$tenk.brzina,$t_ugao);", "kretanje(0);");
moveMap.bindCmd(keyboard, "a", "Rotiranje(-$tenk.rotacija);", "Rotiranje(0);");
moveMap.bindCmd(keyboard, "d", "Rotiranje($tenk.rotacija);", "Rotiranje(0);");
}


function kretanje(%brzinaKretanja,%ugao)
{

%ugao=$t_ugao;
$tenk.setLinearVelocityPolar( $t_ugao, %brzinaKretanja );
}


function Rotiranje(%brzinaRotacije)
{
$t_ugao=$tenk.getRotation();
$tenk.setAngularVelocity( %brzinaRotacije );
}
#12
09/27/2007 (4:40 am)
Vladaboy, I'll try that out on Friday and find the problem (I'm quite busy until then). Honestly, the Serbian names are a bit distracting. I haven't yet made a rotational-movement system before, but I've seen it done and could probably get it to work.
#13
09/27/2007 (5:12 am)
Thank you i apreciate the time, i'l change the names no prob :) sorry about that.

here is the new English version of the code.

function tank::onLevelLoaded(%this)
{

comands();
$tenk=%this;
$tenk.speed = 10;
$tenk.rotation = 100;
}


function comands(){
moveMap.bindCmd(keyboard, "w", "movement($tenk.speed);", "movement(0);");
moveMap.bindCmd(keyboard, "s", "movement(-$tenk.speed);", "movement(0);");
moveMap.bindCmd(keyboard, "a", "rotation(-$tenk.rotation);", "rotation(0);");
moveMap.bindCmd(keyboard, "d", "rotation($tenk.rotation);", "rotation(0);");
}


function movement(%speedofmovement)
{


$tenk.setLinearVelocityPolar( $tenk.getRotation(), %speedofmovement );
}


function rotation(%speedofrotation)
{

$tenk.setAngularVelocity( %speedofrotation );
}


The problem still remains the same:


I need to update the movement function in every milisecond, das giving it the updated $tenk.GetRotation()
variable.

the core of the problem is that when presed w or s the tank moves in one direction (depending on the angle) and if in the proces of moving the tank in one direction, i press the a or d letter it just rotates and dosent change DIRECTION!!!
#14
09/27/2007 (12:06 pm)
Right, that would make sense, because your using "setLinearVelocityPolar(...); but when you rotate, you are not setting the new linear velocity. A behavior which checks the forward velocity and adjusts the LinearVelocityPolar would solve this issue. The point really comes down to that setting the PolarVelocity value just sets it, it doesn't continually update it. Your code sets it once, then doesn't adjust it again.
#15
09/27/2007 (12:15 pm)
Yea i know but i dont know how to fix it???
#16
09/27/2007 (2:36 pm)
Well, you could use onTimer or schedule or something. Maybe have 'w' set the tank.forward = yes on press and tank.forward = no on release. Then every tick or few, check to see if it should be moving forward. If the tank should be moving forward, use setPolarVelocity again. That's probably the easiest way I could think of implementing it with the resources you currently have available. Actual behaviors would produce somewhat more efficient results.
#17
09/28/2007 (11:36 am)
I did it with the schedule fuction :)

but i need to know how to use something of a timer so that i could like, increase the tanks speed every 2 secinds whe a sertain key is pressed? i need help with using the timer function!!! thank's for all the previous HELP!!!!!!
#18
09/28/2007 (11:51 am)
Oh, if you want it to accelerate, then in that space where you address the forward movement add something that will increase the current speed of the tank (up to a limit). Then when the button is released, you could have it reset the speed to zero.

Keep in mind, this is very crude, so don't expect to keep it this way forever. When you call your function that updates the LinearPolarVelocity, have it update the speed as well. Set an accleration rate, which would cause it to be linear (unrealistic, but good enough) so that each time it cycles through up add that rate to the speed of the tank and be absolutely sure that it has a maximum speed. If you want to be really high tech, you could also make it slow down quickly when tank.forward is set to 'no' instead of stopping abruptly. For that, a deceleration rate would be desired since it would be strange for the tank to accelerate and decelerate at the exact same speed. Lastly, it could *not* be allowed to decelerate below 0.
#19
09/29/2007 (3:14 pm)
I have a BIG problem that i didnt notice before, the thing is that my code for the tank movement (i gave up on the asteroids, tank's are more original) but the tanks moves good until the a and s keys are presed at the same time or very quickly then the tank just doesent want to turn in other words my 360 movement aint that fancy it doesent ride like it should, it stops turning at some point. this is a major problem for me cause the movement should be flawless!!!!!

here is the code:



tenk.brzina = 20;
tenk.rotacija = 150;
}


function namestiKomande(){

moveMap.bindCmd(keyboard, "w", "kretanje(tenk.brzina);", "kretanje(0);");
moveMap.bindCmd(keyboard, "s", "kretanje(-tenk.brzina);", "kretanje(0);");
moveMap.bindCmd(keyboard, "a", "Rotiranje(-tenk.rotacija);", "Rotiranje(0);");
moveMap.bindCmd(keyboard, "d", "Rotiranje(tenk.rotacija);", "Rotiranje(0);");
}


function kretanje(%brzinaKretanja)
{

$brzina = %brzinaKretanja;


}


function Rotiranje(%brzinaRotacije)
{
tenk.setAngularVelocity(%brzinaRotacije );
}

function Rotiranje(%brzinaRotacije)
{
tenk.setAngularVelocity(%brzinaRotacije );
}



function kretanjeTenka()
{

%ugao = tenk.getRotation();
tenk.setLinearVelocityPolar( %ugao, $brzina );





schedule( 50, 0, "kretanjeTenka" );
}
#20
09/29/2007 (8:30 pm)
Rather than use the "a" and "d" keys to directly set your rotation, try this:

{
...
moveMap.bindCmd(keyboard, "a", "turnLeft", "turnLeftStop);
moveMap.bindCmd(keyboard, "d", "turnRight", "turnRightStop");
%this.left = 0;
%this.right = 0;
...
}

(Make sure that you set those variables to zero right after the bind commands.

The function "turnLeft" is a simple one-line function that sets the variable %this.left to 1.
The function "turnRight is a simple one-line function that sets the variable %this.right to 1.
For example:

function t2dObject::turnLeft( %this )
{
%this.left = 1;
}

function t2dObject::turnLeftStop( %this )
{
%this.left = 0;
}

function t2dObject::turnRight( %this )
{
%this.right = 1;
}

function t2dObject::turnRightStop( %this )
{
%this.right = 0;
}

Then your Rotiranje function becomes:

function Rotiranje(%brzinaRotacije)
{
tenk.setAngularVelocity( %brzinaRotacije*(%this.right-%this.left) );
}

Every time Rotiranje is called, it calculates a new angular rotation based on the values of %this.right and %this.left. They will be either 1 or 0, so the subtraction will give you a 1, 0, or -1. Multiply that by your %brzinaRotacije, and you have just the angular velocity you wanted.

I wish I could say I thought of it myself, but I stole it from TDN. On the TGB pages of TDN you will find a couple of tutorials and two behaviors called "platformerControls" and "Asteroids". You can learn more by reading the tutorials, and by examining the behavior scripts. (Or you can just steal the behaviors. That's why they're there.)

Good luck to you.
Page «Previous 1 2