Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. poke(0x5f2d,1)
  2.  
  3. move=false
  4. b={x=20,y=20,w=20,h=30}
  5. m={x,y,clicked}
  6. c=0
  7. cx=-1
  8. cy=-1
  9.  
  10. function mousedraw()
  11. spr(0,m.x,m.y)
  12. end
  13.  
  14. function mouse()
  15.  
  16. m={
  17. x=stat(32),
  18. y=stat(33),
  19. clicked=false
  20. }
  21.  
  22. if m.x<0 then m.x=0
  23. elseif m.x>127 then m.x=127
  24. elseif m.y<0 then m.y=0
  25. elseif m.y>127 then m.y=127
  26. elseif stat(34)==1 then
  27. m.clicked=true
  28. end
  29.  
  30. mousedraw()
  31. end
  32.  
  33. function boxmove()
  34. if move==true then
  35. b.x+=stat(32)-m.x
  36. b.y+=stat(33)-m.y
  37. cx+=stat(32)-m.x
  38. cy+=stat(33)-m.y
  39. if cx<0 then cx=0
  40. elseif cx>127 then cx=127
  41. elseif cy<0 then cy=0
  42. elseif cy>127 then cy=127
  43. end
  44. end
  45.  
  46. if m.clicked and c==0 then
  47. cx=m.x
  48. cy=m.y
  49. c=1
  50. elseif m.clicked==false then
  51. c=0
  52. end
  53.  
  54. if m.clicked and
  55. cx>=b.x and cx<=b.x+b.w and
  56. cy>=b.y and cy<=b.y+b.h then
  57. move=true else move=false
  58. end
  59. end
  60.  
  61. function boxdraw()
  62. rectfill(b.x,b.y,b.x+b.w,b.y+b.h,1)
  63. end
  64.  
  65. function box()
  66.  
  67. b={
  68. x=b.x,
  69. y=b.y,
  70. w=30,
  71. h=20
  72. }
  73.  
  74. boxmove()
  75.  
  76. if b.x<0 then b.x=0
  77. elseif b.x+b.w>127 then b.x=127-b.w
  78. end
  79.  
  80. if b.y<0 then b.y=0
  81. elseif b.y+b.h>127 then b.y=127-b.h
  82. end
  83.  
  84. boxdraw()
  85.  
  86. end
  87.  
  88. function _update()
  89. cls()
  90. box()
  91. mouse()
  92. end
  93.  
  94. function _draw()
  95. print(m.clicked,20,20,7)
  96. print(move,20,30,7)
  97. print(cx,20,40,7)
  98. print(cy,20,50,7)
  99. print(b.x,30,40,7)
  100. print(b.y,30,50,7)
  101. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement