Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- poke(0x5f2d,1)
- move=false
- b={x=20,y=20,w=20,h=30}
- m={x,y,clicked}
- c=0
- cx=-1
- cy=-1
- function mousedraw()
- spr(0,m.x,m.y)
- end
- function mouse()
- m={
- x=stat(32),
- y=stat(33),
- clicked=false
- }
- if m.x<0 then m.x=0
- elseif m.x>127 then m.x=127
- elseif m.y<0 then m.y=0
- elseif m.y>127 then m.y=127
- elseif stat(34)==1 then
- m.clicked=true
- end
- mousedraw()
- end
- function boxmove()
- if move==true then
- b.x+=stat(32)-m.x
- b.y+=stat(33)-m.y
- cx+=stat(32)-m.x
- cy+=stat(33)-m.y
- if cx<0 then cx=0
- elseif cx>127 then cx=127
- elseif cy<0 then cy=0
- elseif cy>127 then cy=127
- end
- end
- if m.clicked and c==0 then
- cx=m.x
- cy=m.y
- c=1
- elseif m.clicked==false then
- c=0
- end
- if m.clicked and
- cx>=b.x and cx<=b.x+b.w and
- cy>=b.y and cy<=b.y+b.h then
- move=true else move=false
- end
- end
- function boxdraw()
- rectfill(b.x,b.y,b.x+b.w,b.y+b.h,1)
- end
- function box()
- b={
- x=b.x,
- y=b.y,
- w=30,
- h=20
- }
- boxmove()
- if b.x<0 then b.x=0
- elseif b.x+b.w>127 then b.x=127-b.w
- end
- if b.y<0 then b.y=0
- elseif b.y+b.h>127 then b.y=127-b.h
- end
- boxdraw()
- end
- function _update()
- cls()
- box()
- mouse()
- end
- function _draw()
- print(m.clicked,20,20,7)
- print(move,20,30,7)
- print(cx,20,40,7)
- print(cy,20,50,7)
- print(b.x,30,40,7)
- print(b.y,30,50,7)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement