Saturday, February 7, 2015

Monkey-X beginners - Line Seperation example code.

Here a short example of how to use more lines for a single line in Monkey-X. This is useful for not getting to long lines. Also for posting online on blogs you can shorten the lines so that the code will fit on the page.

Mathmatical characters should be the last character, also comma's seem to work.

Thanks to Samah from the Monkey Forum for learning me this. I will be using this from now on.

Code below :

Import mojo

Class MyGame Extends App

    Method OnCreate()
    End Method
    Method OnUpdate()        
    End Method
    Method OnRender()
        Cls 0,0,0 
        SetColor 255,255,255
        DrawText "Line seperation (Less wide code / blog posts) example code",0,0
        Local val:Int=addinteger(10,20)
        ' Here you can see that one line has become more lines resulting
        ' in less longs lines.
        DrawText "10+20 = " +
    End Method
End Class

' Function example on multiple lines
Function addinteger:Int(val1:Int,
    Return val1+val2
End Function

Function Main()
    New MyGame()
End Function

No comments:

Post a Comment