Is this code right? (velocity)
Hi, i''m a flash programmer and i''m trying to come up w/ some simple game physics. This is what i''ve come up w/ for velocity, and was wondering if you could tell me if i''m right or not:
each "frame" this is run:
velocity = velocity + accel;
velocity = velocity * drag;
Then the velocity is added to the current position.
Drag in this case is below 1 (like .7 or something)
Accel is changed when a "force" is applied. When it''s not applied accel becomes zero.
This also gives me a terminal velocity which is nice, and here is a graph of the curve (i hope you can put html in here):
I was expecting to get more of a bell curve, but after checking stuff out on the net this looks almost right...
So does it make sense?
Ya that should work. Also, you probably should make:
velocity = velocity +accel;
to
velocity += accel;
and
velocity = velocity * drag;
to
velocity *= drag;
Good stuff you have there, good luck!
velocity = velocity +accel;
to
velocity += accel;
and
velocity = velocity * drag;
to
velocity *= drag;
Good stuff you have there, good luck!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement