Advertisement
Guest User

m source

a guest
Apr 28th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. Strict
  2.  
  3. Import mojo
  4.  
  5. Function Main:Int()
  6. New MyApp()
  7. Return 0
  8. End
  9.  
  10. Class MyApp Extends App
  11. Field i:Bool
  12. Field m:Image
  13. Field p:Int[]
  14. Field x:Int, y:Int
  15.  
  16. Method OnCreate:Int()
  17. m = LoadImage("m.png")
  18. p = New Int[169]
  19. SetUpdateRate(60)
  20.  
  21. Return 0
  22. End
  23.  
  24. Method OnUpdate:Int()
  25. Local px:Int = x
  26. Local py:Int = y
  27.  
  28. If KeyHit(KEY_UP) Then y = Max(0, y - 1)
  29. If KeyHit(KEY_RIGHT) Then x = Min(12, x + 1)
  30. If KeyHit(KEY_DOWN) Then y = Min(12, y + 1)
  31. If KeyHit(KEY_LEFT) Then x = Max(0, x - 1)
  32.  
  33. If p[x + y * 13] = -16777216
  34. x = px
  35. y = py
  36. End
  37.  
  38. Return 0
  39. End
  40.  
  41. Method OnRender:Int()
  42. If Not i
  43. DrawImage m, 0, 0
  44. ReadPixels(p, 0, 0, 13, 13)
  45. For Local n:Int = 0 Until p.Length
  46. If p[n] = -65281
  47. x = n Mod 13
  48. y = (n - x) / 13
  49. EndIf
  50. Next
  51. Cls
  52. i = True
  53. Else
  54. Local rgb:Int = p[x + y * 13]
  55. Local r: Int = (rgb Shr 16) & $ff
  56. Local g: Int = (rgb Shr 8) & $ff
  57. Local b: Int = rgb & $ff
  58. Cls r, g, b
  59. EndIf
  60.  
  61. Return 0
  62. End
  63. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement