XMMO is on pause for this weekend. I won’t be here.
————
On other notes about XMMO though, I figured out how to tween an object with my minimal (at best) geometry skills.
I share with you my hacky tweening test code. I want you to keep in mind that it’s using my unreleased BlitzMax Monkey-mojo mod. So you’ll have to conform the code to your own system. Or, optionally to run in Monkey, replace keyword “Type” with “Class” and “TImage” with “Image”, remove SetAppTitle, SetWidth, SetHeight, gameFps, and the KeyDown escape check code. Then alter Cls() to Cls(0,0,0), get rid of the globally executing “Main()” and then finally, alter the Function Main() to just have “New TGameApp”.
On a last note, you’ll need a picture. Doesn’t matter what picture, just a picture to see the tweening. Well, now I’m off. I feel good about my math for now. I still need to go back to school and learn this stuff. Seeing as how I really only went up to the Algebraic level of math. I’m just so damn sharp that I can latch onto figuring out things with a little thinking. I also think I used sine and cosine by accident while I was working. Hmm…
Code can be viewed by clicking “(more…)”
SuperStrict Import monkey.app Type TGameApp Extends App Field gameFps:Fps Field twnObject:Tween Method OnCreate() SetAppTitle( "Test2" ) SetUpdateRate( 30 ) SetWidth( 800 ) SetHeight( 600 ) gameFps = New Fps twnObject:Tween = Tween.Create( "data/picture.png" ) End Method Method OnSuspend() End Method Method OnUpdate() twnObject.Update() If ( KeyDown( KEY_ESCAPE ) ) Then EndGame() If ( MouseHit ( 1 ) ) Then twnObject.MoveVelocity( 30, MouseX(), MouseY() ) End Method Method Render() twnObject.Draw() End Method Method OnRender() Cls() gameFps.Update() Render() gameFps.Render() End Method EndType Type Tween Const ACT_MOVE_FIXED% = 2 Field _image:TImage Field _ax# = 0, _ay# = 0 Field _bx# = 0, _by# = 0 Field act% = 0 Field timeStamp% = 0 Field toTimeStamp% = 0 Field ri#, ru# Function Create:Tween( image:String ) Local twn:Tween = New Tween twn.SetImage( LoadImage( image ) ) Return twn End Function Method SetImage( image:TImage ) _image = image End Method Method MoveFixedSeconds( msecs%, bx#, by# ) timeStamp = MilliSecs() ru = bx - _ax ri = by - _ay _bx = bx _by = by ru = ru / msecs ri = ri / msecs toTimeStamp = MilliSecs() + msecs SetAction( ACT_MOVE_FIXED ) End Method Method MoveVelocity( velocity#, bx#, by# ) timeStamp = MilliSecs() velocity = velocity / 100 ru = bx - _ax ri = by - _ay _bx = bx _by = by Local hyp# = Sqr( ru^2 + ri^2 ) ru = ( ru / hyp ) * velocity ri = ( ri / hyp ) * velocity toTimeStamp = MilliSecs() + Int( hyp / velocity ) SetAction( ACT_MOVE_FIXED ) End Method Method Update() Select ( act ) Case ACT_MOVE_FIXED If ( MilliSecs() >= toTimeStamp ) If ( _ax <> _bx Or _ay <> _by ) _ax = _bx _ay = _by End If StopAction() Else Local msecsPassed% = MilliSecs() - timeStamp Local mru# = msecsPassed * ru Local mri# = msecsPassed * ri _ax :+ mru _ay :+ mri timeStamp = MilliSecs() End If End Select End Method Method Draw() DrawImage( _image, _ax, _ay ) End Method Method StopAction() act = 0 End Method Method SetAction( uact% ) act = uact End Method End Type Function Main() Local gameApp:TGameApp = New TGameApp gameApp.Start() End Function Main()






