Page 1 of 1

Directional_velocity and such

PostPosted: Mon Oct 17, 2005 3:36 am
by ALK3_Steph
In the MechWarrior games, if you have played them, you can hit the + key to increase your running speed, and the - key to decrease it eventually to a stop. Im trying for the same thing with this game. I figured out how to increase speed and decrease speed using a score set up. I made
Code: Select all
Speed.textNumber=Speed.textNumber+1;
for the + and the -1 for the - key. But how do I set the x or y direction? Before I was using " y=y-1;" to test the increase or decrease in speed. But if I added "x=x+1;" for right, it would make it diagonal. So, the question is how do I set the direction for the directional velocity?

PostPosted: Mon Oct 17, 2005 3:51 am
by Joshua Worth
ALK3_Steph wrote:How do I set the direction for the directional velocity?
actor.angle

For the code
Code: Select all
Speed.textNumber=Speed.textNumber+1;

Change that to
Code: Select all
Speed.textNumber+=1;

It does the same thing, exept much less code.

PostPosted: Mon Oct 17, 2005 3:55 am
by ALK3_Steph
Oo thanks for the help, and thanks for the smaller code, haha. But what code would I use for the angle?
Code: Select all
angle=0

PostPosted: Mon Oct 17, 2005 5:38 am
by Joshua Worth
what do you mean by "what code would I use for the angle?"?

PostPosted: Mon Oct 17, 2005 4:03 pm
by ALK3_Steph
Like, I meant how would I set it up? If hes going left, would I say angle=90 and then.. what?

PostPosted: Mon Oct 17, 2005 4:20 pm
by makslane
Using script:

Move to left: you can use x -= 10; or xvelocity = -1;
Move to right: you can use x += 10; or xvelocity = 1;

Move up: you can use y -= 10; or yvelocity = -1;
Move down: you can use y += 10; or yvelocity = 1;

Using Move To action:
Read http://www.game-editor.com/docs/getting ... htm#moveto

PostPosted: Tue Oct 18, 2005 1:06 pm
by ALK3_Steph
Well the moving part Ive got down, I can make it go the direction I want, using key downs such as when I hit left, x=x-5; but using the + to increase velocity, I cant make him go up then stop and go right, he just goes diagonal.

PostPosted: Tue Oct 18, 2005 2:12 pm
by makslane
Can you show this codes?

PostPosted: Tue Oct 18, 2005 3:13 pm
by ALK3_Steph
For up, Ive got Pos=0, right is Pos=1, down is Pos=2, and left is Pos=3

On the '+' key script Ive got
Code: Select all
if (pos==0)
{yvelocity+=1;}


On the - key, I have it backwards (yvelocity-=1) and I have this for all Pos variables.

Code: Select all
if (pos==1)
{xvelocity+=1;}

And so on

PostPosted: Tue Oct 18, 2005 3:58 pm
by makslane
Ok, if you don't want diagonal moves, you can make this:

if (pos==0)
{
yvelocity+=1;
xvelocity = 0;
}

PostPosted: Tue Oct 18, 2005 4:11 pm
by ALK3_Steph
Ahh, thank you kind sir. I appreciate the help! That did the trick and its doin' what I want