Simple retro sinus scroller

Jimmy

Active Member
Tutorial Author
Joined
Jan 2, 2020
A little example showing off some retro coding using strings and mojo2.

IDE.png



Simple sinus scroller:
Import mojo2

Function Main()
    New MyApp
End

Class MyApp Extends App

    Field canvas:Canvas
    Field A:String = "Sine waves ARE AMAZING AM I RIGHT?!"
    Field B:Float
   
    Method OnCreate()
        canvas=New Canvas
             SetSwapInterval 1
             SetUpdateRate 0
    End
   
    Method OnUpdate()
        A = A + " OH YES, THEY ARE, INDEED, AMAZING!"
    End
       
    Method OnRender()
        canvas.Clear
       
        For Local x := 1 To 39
            For Local Y := 1 To 39
                canvas.DrawText Mid(A,x,1),x*1280/64.0,300*Sinr(x/6.0+B)+472
                canvas.DrawText Mid(A,x,1),300*Cosr(x/6.0/Y+B)+472 ,300*Sinr(x/6.0+B)+472
            Next
        Next
       
        B=B+0.02
       
        canvas.Flush
    End

    Method Mid:String(s:String,p:Int,n:Int)
        p=p-1
        Return s[(p)..(p+n)]
    End

End
 
Top Bottom