The X and Y vectors of motion are independent. moving left or right is independent of the up-down acceleration due to jumping/gravity.

Not Sin/Cos, but Physics 101.

roymeo

At 02:29 AM 12/2/2002 +0000, you wrote:
----- Original Message -----
From: "mike m" <[EMAIL PROTECTED]>
>
> I am trying to make my charactor jump forward, obviously (i think) the sin
> and cosine command would be used, but i have no idea how this works or how
> to write it, i cant really find any really useful sites that explain it in
> such a way either.

I wouldn't use sin or cosine. What I would do is to have the left and right
speed controlled by the left and right keys. Then I'd have a button that
makes the character jump: this only needs to concern itself with the upward
movement. This is not realistic physics, but is traditional in games and
keeps the controls intuitive.

So, to do this jump action, I would start with an initial velocity, say 2
pixels per frame. Then I would apply "gravity" to this velocity every frame
(do this in the exitFrame or enterFrame handler). This will cause the upward
velocity to decrease each frame, say by 0.5 pixels per frame per frame (no,
that is not a typo) until -terminalVelocity is reached. terminalVelocity
determines how fast the character will fall back to the ground under the
force of gravity. This should be about 120mph, but it's probably better to
go for about 5 pixels/frame or something.

Also, every frame, I would subtract the upward velocity from the character's
locV, so it moves up (or down if it is falling). If it's falling, I would
want to test for collisions with the tops of platforms/objects every frame.
If the character hits one, I'd want to reset the velocity property to zero,
so it stops moving, and set the locV correctly, so the character is standing
on top of the object. To be really smart, perhaps add a little landing
animation and/or bounce effect at that point.

- Robert

[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi  To post messages to the list, email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo.  Thanks!]


Reply via email to