Rich, I did a quick mock up for you, the berp function might need playing with to get the exact result you want as it's not very pronounced:
rem
rem AGK Application
rem
rem Landscape App
SetDisplayAspect( 4.0/3.0 )
#constant PI 3.14159265358979
MODE = 1
spr = createSprite(0)
setSpriteSize(spr,10,-1)
setSpritePositionbyOffset(spr,50,0)
startTime# = timer()
totaltime# = 1.0
rem A Wizard Did It!
do
time# = timer()
select MODE
case 1
rem move in from top of screen
elapsed# = (time#-startTime#)/totaltime#
Print("Elapsed time: "+str(elapsed#))
setSpritePositionByOffset(spr,50,Berp(0,50,elapsed#,1.0))
if elapsed#>totaltime#*1.5
startTime# = time#
MODE = 2
setSpritePositionByOffset(spr,50,50)
endif
endcase
case 2
rem start small and get big
elapsed# = (time#-startTime#)/totaltime#
Print("Elapsed time: "+str(elapsed#))
setSpriteSize(spr,Berp(1,10,elapsed#,1.0),-1)
if elapsed#>totaltime#*1.5
startTime# = time#
MODE = 1
setSpritePositionByOffset(spr,50,0)
endif
endcase
endselect
Sync()
loop
`######################################## LERP FUNCTIONS
function Berp( startValue as float, endValue as float , value as float, amount as float )
value = Clamp(0, 1, value)
value = (sin(value * PI * (amount + 2.5 * value * value * value)) * Pow(1.0 - value, 2+amount) + value) * (1.0 + ((1+amount) * (1.0 - value)))
result# = startValue + (endValue - startValue) * value
endfunction result#
function Hermite( startValue as float, endValue as float, value as float)
result# = Lerp(startValue, endValue, value * value * (3.0 - 2.0 * value))
endfunction result#
function Sinerp( startValue as float, endValue as float, value as float)
result# = Lerp( startValue, endValue, sin(value * PI * 0.5))
endfunction result#
function Coserp( startValue as float, endValue as float, value as float)
result# = Lerp(startValue, endValue, 1.0 - cos(value * PI * 0.5))
endfunction result#
function Bounce(x as float)
result# = abs(sin(6.28*(x+1)*(x+1)) * (1-x))
endFunction result#
function Lerp( startValue as float, endValue as float , value as float )
result# = ((1.0 - value) * startValue) + (value * endValue)
endfunction result#
function SmoothStep( x as float, min as float, max as float)
x = Clamp (x, min, max)
v1# = (x-min)/(max-min)
v2# = (x-min)/(max-min)
result# = -2*v1 * v1 *v1 + 3*v2 * v2
endfunction result#
function Approx( value as float, target as float, range as float)
result = (( abs(value - target) < range) )
endfunction result
function Clerp( startValue as float, endValue as float, value as float )
min# = 0.0
max# = 360.0
half# = abs((max# - min#)/2.0)
retval# = 0.0
diff# = 0.0
if (endValue - startValue) < -half#
diff = ((max - startValue) + endValue) * value
retval# = startValue + diff#
elseif (endValue - startValue) > half#
diff# = -((max# - endValue) + startValue) * value
retval# = startValue + diff#
else
retval# = startValue + (endValue - startValue) * value
endif
endfunction retval#
function Pow( base as float, exp as float )
result# = base ^ exp
endfunction result#
function Clamp( min as float, max as float, value as float)
if value < min then exitfunction min
if value > max then exitfunction max
endfunction value
EDIT: I added an "amount" variable to the berp function which allows you to make it more pronounced...