That was the best way to learn, and can be applied to many other things in AGK. But now I'll show you the easy way (if you have AppGameKit V2)
I used to calculate all my own transitions - movement, fades, resizes, rotates etc. I have a library of linear transitions, ease in and out, berps, ping-pongs, etc etc It's 1,600 lines of code to manage all of these things seamlessly, for as many sprites as needed.
Then Paul made Tweens, and 80% of my code was replaced overnight. I could be bitter, but I'm actually very grateful, it's so much neater.
Here is how you can do the same thing with Tweens. I've used a smooth tween to show how easy it is to improve the look. I've documented the code.
// Project: TweenShuttle
// Created: 2015-02-05
// set window properties
SetWindowTitle( "TweenShuttle" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
shuttle = createSprite(0)
setSpriteSize(shuttle, 150,150)
setSpritePosition(shuttle, 100,300)
//A chain allows you to create a sequenece of tweens
chain = createTweenChain()
//We need a left->right and a right->left tween
LeftToRight = CreateTweenSprite(5)
RightToLeft = CreateTweenSprite(5)
//set the actions of our 2 new tweens
SetTweenSpriteX(LeftToRight,100, getVirtualWidth() - 200,1)
SetTweenSpriteX(RightToLeft,getVirtualWidth() - 200,100,1)
//Add the tweens to the chain in pairs, 10 times over
for n = 1 to 10
AddTweenChainSprite(chain,LeftToRight,shuttle,0)
AddTweenChainSprite(chain,RightToLeft,shuttle,0)
next n
//Start the tween chain
PlayTweenChain(chain)
do
//just call UpdateAllTweens() and the sprite will take care of itself!
UpdateAllTweens(GetFrameTime())
Print( ScreenFPS() )
Sync()
loop
Quidquid latine dictum sit, altum sonatur