Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Strict
- Import mojo
- Function Main:Int()
- New MyApp()
- Return 0
- End
- Class MyApp Extends App
- Field i:Bool
- Field m:Image
- Field p:Int[]
- Field x:Int, y:Int
- Method OnCreate:Int()
- m = LoadImage("m.png")
- p = New Int[169]
- SetUpdateRate(60)
- Return 0
- End
- Method OnUpdate:Int()
- Local px:Int = x
- Local py:Int = y
- If KeyHit(KEY_UP) Then y = Max(0, y - 1)
- If KeyHit(KEY_RIGHT) Then x = Min(12, x + 1)
- If KeyHit(KEY_DOWN) Then y = Min(12, y + 1)
- If KeyHit(KEY_LEFT) Then x = Max(0, x - 1)
- If p[x + y * 13] = -16777216
- x = px
- y = py
- End
- Return 0
- End
- Method OnRender:Int()
- If Not i
- DrawImage m, 0, 0
- ReadPixels(p, 0, 0, 13, 13)
- For Local n:Int = 0 Until p.Length
- If p[n] = -65281
- x = n Mod 13
- y = (n - x) / 13
- EndIf
- Next
- Cls
- i = True
- Else
- Local rgb:Int = p[x + y * 13]
- Local r: Int = (rgb Shr 16) & $ff
- Local g: Int = (rgb Shr 8) & $ff
- Local b: Int = rgb & $ff
- Cls r, g, b
- EndIf
- Return 0
- End
- End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement