Directional_velocity and such

Talk about making games.

Directional_velocity and such

Postby ALK3_Steph » Mon Oct 17, 2005 3:36 am

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?
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby Joshua Worth » Mon Oct 17, 2005 3:51 am

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.
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby ALK3_Steph » Mon Oct 17, 2005 3:55 am

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
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby Joshua Worth » Mon Oct 17, 2005 5:38 am

what do you mean by "what code would I use for the angle?"?
Stay sweet
User avatar
Joshua Worth
 
Posts: 515
Joined: Tue Jul 19, 2005 12:00 am
Location: Stralia
Score: 5 Give a positive score

Postby ALK3_Steph » Mon Oct 17, 2005 4:03 pm

Like, I meant how would I set it up? If hes going left, would I say angle=90 and then.. what?
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby makslane » Mon Oct 17, 2005 4:20 pm

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
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby ALK3_Steph » Tue Oct 18, 2005 1:06 pm

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.
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby makslane » Tue Oct 18, 2005 2:12 pm

Can you show this codes?
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby ALK3_Steph » Tue Oct 18, 2005 3:13 pm

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
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby makslane » Tue Oct 18, 2005 3:58 pm

Ok, if you don't want diagonal moves, you can make this:

if (pos==0)
{
yvelocity+=1;
xvelocity = 0;
}
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby ALK3_Steph » Tue Oct 18, 2005 4:11 pm

Ahh, thank you kind sir. I appreciate the help! That did the trick and its doin' what I want
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest