Last active 1 hour ago

simple-object.lua Raw Playground
1return function(animation, x, y)
2 local object = {
3 x = x
4 , y = y
5 , frame = 0
6 , animation = animation
7 , grabbed = false
8 }
9 function object:draw()
10 if mouseIsPressed and not taken and self:contains(mouseX, mouseY) and not self.grabbed then
11 self.grabbed = true
12 taken = true
13 elseif not mouseIsPressed then
14 self.grabbed = false
15 taken = false
16 print(animation, self.x, self.y)
17 end
18 self:animate()
19 if self.grabbed then
20 self.x = mouseX
21 self.y = mouseY
22 end
23 end
24 require "is.animated" (object)
25 require "is.sized" (object)
26 return object
27end