car speed/mouse

Game Editor comments and discussion.

car speed/mouse

Postby Oman » Thu Jun 07, 2007 2:02 am

hello,
I was wondering if there was a code to make my car (player actor) move faster depending on how far away it is from the crosshair. Like if my crosshair was 30 pixels away from the car the car would be moving somewhere around 3 velocity, but if the crosshair was 120 pixels away from the car then the car would be moving somewhere around 7 velocity.

I am using this code now, but it doesn't do exactly what i want.

angle = direction(x, y, crosshair.x, crosshair.y);
directional_velocity = 8;

By the way the crosshair follows the mouse...

any help is appreciated :D
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Re: car speed/mouse

Postby Sgt. Sparky » Thu Jun 07, 2007 2:28 am

Oman wrote:hello,
I was wondering if there was a code to make my car (player actor) move faster depending on how far away it is from the crosshair. Like if my crosshair was 30 pixels away from the car the car would be moving somewhere around 3 velocity, but if the crosshair was 120 pixels away from the car then the car would be moving somewhere around 7 velocity.

I am using this code now, but it doesn't do exactly what i want.

angle = direction(x, y, crosshair.x, crosshair.y);
directional_velocity = 8;

By the way the crosshair follows the mouse...

any help is appreciated :D

you need to use,
Code: Select all
angle = direction(x, y, crosshair.x, crosshair.y);
directional_velocity = distance(x, y, crosshair.x, crosshair.y) / 12;
:D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby Oman » Thu Jun 07, 2007 2:51 am

I knew it was simple like that...

Thanks a ton sparky :D
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

Postby Sgt. Sparky » Thu Jun 07, 2007 2:54 am

you are Welcome, any time! :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron