Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / (DBP) CAR MOVEMENT

Author
Message
CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 20th Jul 2004 21:40
hi,

can someone explain basics of;
velocity, speed to time relation, acceleration to time relation
briefly basic knowledge to make a car movement simulation...

Thank you
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 21st Jul 2004 01:33
--Basic Physics--
Velocity = distance traveled over a given time frame.
1 KPH = 1 kilometer per hour for example.
(This should answer the speed/time relation.)

Acceration = change in velocity over time.
1g = 32 feet per second times number of seconds squared.
V = A * T^2

Total velocity = 1/2 the acceleration times # of seconds applied.
V = 1/2 * A * T^2

For gaming purposes, the maximum velocity is usually a fixed value, say 50 units for every pass through the game loop. Based upon the scale used by the world, this can simulate anything from 50 inches or microns per second to 50 light years per second, but is usually the number of screen pixels the character or object moves per loop.

Acceleration in the gaming sense is the amount of the change of speed for the character, say a car that starts off as stopped and gains 1 unit of speed for every pass in the loop until it reaches the 50 stated above. It then continues at that speed until you hit the brakes, which slow it down at say, 2 units per loop until it stops again.

More complex formulas actually use the above physical formulas, not the simple examples I've given. Look in the 2D forums for the tutorial on gaming physics, or get a physics textbook.

Hope this helps.
S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 21st Jul 2004 07:13
Oh by the way, I was wrong about the second formula... it's actually the distance traveled, not speed;

D = 1/2 * A * T^2

Used primarily for falling objects or those under a constant acceleration if I remember correctly.
S.

Any truly great code should be indisguishable from magic.
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 21st Jul 2004 07:35
Hi,

ah - physics questions - I may be able to help here

It's as Sandra has said, but here's another way of looking at it which doesn't involve any complex equations or physics text books!

Let's say your car is able to move in just one direction first of all (to keep things simple). Its position is given by its x-coordinate, so we'll call it 'x#'

Velocity is the change in this position per unit of time. As you will have a loop in your program, this loop is really the 'time', so velocity just becomes the change in position. We'll call this change in position 'v#' for velocity. Your object's new position will be given, then, by 'x#=x#+v#'

Acceleration is the change in velocity. Let's call it 'a#'. When you accelerate, the velocity is then given by 'v#=v#+a#'

So, your game loop should look something like this:

DO

check input (maybe the arrow keys) for increase or decrease in v#

x#=x#+v#
v#=v#+a#

Show object at position x#

LOOP

That's the basics in one dimension. It's quite easy then to extend into 2 or 3 dimensions by adding y and z coordinates. Let me know if you get stuck.

Richard
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 21st Jul 2004 13:30
Thanks Ric!
Maybe between the two of us it'll make sense for him...


Any truly great code should be indisguishable from magic.
CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 21st Jul 2004 17:49 Edited at: 21st Jul 2004 17:55
Well, i have managed the x# y# z# positions with friction#, smooth acceleration..
however, ive stucked on turns, here is my well designed but poor explained code hope someone can also learn from this..

Can Anyone implement turning with skiddings to this code?

Im sorry i cant include the 3d model because its a huge file and i spent lots of time creating it..however, any 4 wheels with 3 limbs as follows will do fine:
1st - backwheels
2nd - Front Left Wheel
3rd - Front Right Wheel

CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 21st Jul 2004 17:59
Also i need some sort of vectors implementing to find the mass position of the car and calculating different forces,
Thanks Very much..
CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 22nd Jul 2004 01:00
well, unfortunately ive found out theres nothin to learn from this code..
so nevermind ppl

Login to post a reply

Server time is: 2024-11-27 01:43:46
Your offset time is: 2024-11-27 01:43:46