Friday, February 3, 2017

Monkey-X - Getting Started - Default Parameters - code example

Import mojo

Class MyGame Extends App
    Method OnCreate()
        SetUpdateRate(60)
    End Method
    Method OnUpdate()   
    End Method
    Method OnRender()
        Cls 0,0,0 
        SetColor 255,255,255
        Scale 2,2
        defaultparameter(0,0)
        defaultparameter(0,20,100,200,"Not Default")
    End Method
End Class

' Like with variable declaration you can set a value to 
' a variable in a function or method.
Function defaultparameter(x:Int,y:Int,a:Int=10,b:Int=20,c:String="default")
    DrawText "a="+a+" b="+b+" c="+c,x,y
End Function

Function Main()
    New MyGame()
End Function

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.