Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object = {}
- function Object:New(x, y)
- local obj = {}
- obj.x = x or 0
- obj.y = y or 0
- obj.xSpeed = 0
- obj.ySpeed = 0
- obj.rSpeed = 0
- obj.direction = 0
- obj.sprite = nil
- function obj:setSprite(type, color, width_radius, height)
- self.sprite = Sprite:New(type, color, width_radius, height)
- end
- function obj:moveTo(x, y) -- Move object to specified destination
- self.x = x
- self.y = y
- end
- function obj:moveBy(x, y) -- Move object by amounts x and y
- self.x = self.x + x
- self.y = self.y + y
- end
- function obj:setSpeed( x, y )
- self.xSpeed = x
- self.ySpeed = y
- self.rSpeed, self.direction = resultant(self.xSpeed, self.ySpeed)
- end
- function obj:addSpeed( x, y )
- self.xSpeed = self.xSpeed + x
- self.ySpeed = self.ySpeed + y
- self.rSpeed, self.direction = resultant(self.xSpeed, self.ySpeed)
- end
- function obj:update(dt)
- end
- function obj:draw()
- self.sprite:draw(self.x, self.y)
- end
- return obj
- end
Add Comment
Please, Sign In to add comment