Monkey Coder – Draw Geometry

Notice:

You can draw geometric figures.

The code is:

‘ DrawPlayField START *********
Method DrawPlayField:Int()

DrawCircle (100,200,20) ‘ x,y,r
DrawEllipse (100,300,20,40) ‘ x,y,r1,r2
DrawOval (400,200,100,200) ‘ x,y,r1,r2
DrawPoint(5,5) ‘ x,y
DrawLine (300,300,400,400) ‘ x,y,x,y
DrawRect (10,10,200,100) ‘ x,y,x,y

Return True
End
‘ DrawPlayField END ***********

' STEP 1 All games open with this first command
Strict

#rem
Script: 
Description: 
Author: Andrea Tonin
#End

' STEP 2 Import framework mojo - it is a 2D framamework to support graphics, sound, input, device events
Import mojo

' STEP 3 Creation of Class - yourgame - (we can use the name of the game)

' Class yourgame START *****************************************
Class yourgame Extends App

' STEP 4 Creation of Method OnCreate - OnUpdate - OnRender

	' OnCreate START *******
	Method OnCreate:Int()
	SetUpdateRate(60)
	Return True
	End
	' OnCreate END *********

	' OnUpdate START *******
	Method OnUpdate:Int()
	Return True
	End
	' OnUpdate END *********
	
	' DrawPlayField START *********
	Method DrawPlayField:Int()
	
	DrawCircle (100,200,20)     ' x,y,r
	DrawEllipse (100,300,20,40) ' x,y,r1,r2
	DrawOval (400,200,100,200)  ' x,y,r1,r2
	DrawPoint(5,5)              ' x,y
	DrawLine (300,300,400,400)  ' x,y,x,y
	DrawRect (10,10,200,100)    ' x,y,x,y
	
	Return True
	End
    ' DrawPlayField END ***********

	' OnRender START *******
	Method OnRender:Int()
	
	Cls 'Clear the canvas each frame, the canvas will be black!
    DrawPlayField() 'this call draws the background
	
	Return True
	End
	' OnRender END *********

End
' Class yourgame END ********************************************

' Step 5 Creation of Main function

Function Main:Int()
	' Create a running istance from our class - the class - yourgame - has been created at STEP 3 
	New yourgame
	Return True
End