-
Notifications
You must be signed in to change notification settings - Fork 8
/
Beginners - Array of Arrays Tilemap.monkey2
52 lines (46 loc) · 1.45 KB
/
Beginners - Array of Arrays Tilemap.monkey2
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#Import "<std>"
#Import "<mojo>"
Using std..
Using mojo..
Class MyWindow Extends Window
Field map := New Int[][] (
New Int[]( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ),
New Int[]( 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ),
New Int[]( 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ),
New Int[]( 1, 0, 0, 0, 0, 0, 1, 1, 1, 1 ),
New Int[]( 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ),
New Int[]( 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ),
New Int[]( 1, 1, 1, 1, 1, 0, 0, 0, 0, 1 ),
New Int[]( 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ),
New Int[]( 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ),
New Int[]( 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 ),
New Int[]( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ) )
Field tilewidth:Int
Field tileheight:Int
Method New()
' Set The title of the window...
Title="Tilemap example Array of Arrays....."
tilewidth = Width/map[0].Length
tileheight = Height/map.Length
End Method
Method OnRender( canvas:Canvas ) Override
App.RequestRender() ' Activate this method
' Clear with black color
canvas.Clear(Color.Black)
canvas.Color = Color.White
For Local y:Int=0 Until map.Length
For Local x:Int=0 Until map[0].Length
If map[y][x] = 1
canvas.DrawRect(x*tilewidth,y*tileheight,tilewidth,tileheight)
End If
Next
Next
' if key escape then quit
If Keyboard.KeyReleased(Key.Escape) Then App.Terminate()
End Method
End Class
Function Main()
New AppInstance
New MyWindow
App.Run()
End Function