The code below shows you how to draw a rectangle to the screen. The rectangle moves up and down.
Code below : (paste it into the monkey editor and run it)
Import mojo
Global x:Int = 320
Global y:Int = 100
Global inc:Int = 1
Class MyGame Extends App
Method OnCreate()
SetUpdateRate(60)
End
Method OnUpdate()
y+=inc
If y>200 Then inc=-1
If y<100 Then inc=1
End
Method OnRender()
Cls(0,0,0)
SetColor(255,0,0)
DrawRect(x,y,16,16)
End
End
Function Main()
New MyGame()
End
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.