forked from Pakz001/MonkeyXExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonkey Getting started - MouseHit - code example.monkey
More file actions
34 lines (32 loc) · 1.19 KB
/
Monkey Getting started - MouseHit - code example.monkey
File metadata and controls
34 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'import mojo needs to be called so that it recognizes the
'mojo commands.
Import mojo
Class MyGame Extends App
Field timedown:Int
Field mytext:String = "Press the mouse."
Method OnCreate() 'This method is only run when the program starts
SetUpdateRate(10) 'how many times should the screen be redrawn per second
End Method
Method OnUpdate() ' Run every frame(put keyinput ect. in here)
timedown-=1
If timedown <= 0 Then
timedown = 0
mytext = "Press the mouse"
End If
If MouseHit(MOUSE_LEFT) Then mytext = "The left mouse was last pressed." ; timedown=10
' Flash does not recognize middle and right mouse buttons....
If MouseHit(MOUSE_RIGHT) Then mytext = "The Right mouse was last pressed."; timedown=10
If MouseHit(MOUSE_MIDDLE) Then mytext = "The Middle mouse was last pressed."; timedown=10
End Method
Method OnRender() 'Drawing commands here.
' Clear the screen with color 0,0,0
Cls 0,0,0
' Set the Color of the next drawing commands
SetColor 255,255,255
' Draw text to the screen. txt,x,y
DrawText mytext,0,0
End Method
End Class
Function Main()
New MyGame()
End Function