Sunday, September 20, 2015

Monkey-X - Beginners - Center text on screen (DrawText/DeviceWidth/DeviceHeight) - example


The screen of your game/application is like a piece of paper where the more right you go the more the x value gets. Same with the y value and the height of the screen. DeviceWidth has the total width. To draw something in the middle you can / (devide) by 2 and then draw the text using the .5, .5 settings (.5 = 1/2(center))

Import mojo

Class MyGame Extends App
    Method OnRender()
        Cls 0,0,0 
        SetColor 255,255,255        
        DrawText "Monkey-X Beginner Example",10,10
        DrawText "Center text on the screen.",10,30
        DrawText "Center of Screen.",DeviceWidth()/2,DeviceHeight()/2,.5,.5
    End Method
End Class

Function Main()
    New MyGame()
End Function

No comments:

Post a Comment

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