I don't know much about you kids' tweening & such, but the math for parabolic projectile motion is not too hard. Recall in high school physics we learned that forward speed is constant & upward speed is decelerated by gravity until it becomes downward speed. So in code we simply fire off initial forward & vertical velocity & then each frame add the velocity to the positon to get the new position. We also add the accelerations to the velocities to get the new velocities. The following code illustrates all this. Sprite image attached. Space bar to jump & double-jump. Enjoy.
// Project: UncleM_ProjectileMotion
// Created: 2015-08-01
// Demonstrates simple projectile motion using basic physics calculations
// by: Uncle Martin
// set window properties
SetWindowTitle( "UncleM_ProjectileMotion" )
SetWindowSize( 1024, 768, 0 )
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
// Create an object for projectile
Image = LoadImage("Ball1.png")
Sprite = CreateSprite(Image)
// Set constants
#constant GroundY# = 400
#constant StartX# = 20
#constant VelUp# = 20.0
#constant VelFwd# = 3.0
#constant GravityY# = 1.0
// Position
y# = GroundY#
x# = StartX#
// Velocity
yVel# = 0.0
xVel# = 0.0
// Acceleration
yAcc# = -GravityY#
xAcc# = 0.0
repeat
// Draw ground line
DrawLine(0, GroundY#+70, 1023, GroundY#+70, 0,255,0)
// Apply impulse to object when triggered
if (GetRawKeyPressed(32)) // Space Bar pressed
yVel# = VelUp#
xVel# = VelFwd#
endif
// Integrate object position based on velocities
y# = y# - yVel#
x# = x# + xVel#
// Position the object
SetSpriteX(Sprite, x#)
SetSpriteY(Sprite, y#)
// Integrate velocity based on accelerations
xVel# = xVel# + xAcc#
yVel# = yVel# + yAcc#
// Freeze the object when it hits the ground
If y# > GroundY#
y# = GroundY#+20
yVel# = 0.0
xVel# = 0.0
endif
Print( ScreenFPS() )
Sync()
until GetRawKeyState(27) // Esc
Code every line like it might be your last...
Someday it will be.