Pastor = {} function Pastor:new(x, y) self.sprite = love.graphics.newImage("img/pastor.png") self.width = self.sprite:getWidth() self.height = self.sprite:getHeight() self.x = x-self.width/2 self.y = y-self.height/2 self.speed = 2 return self end function Pastor:update(dt) local width, height, flags = love.window.getMode(); width = width - self.width height = height - self.height if love.keyboard.isDown("up") and self.y > 0 then self.y = self.y - self.speed end if love.keyboard.isDown("down") and self.y < height then self.y = self.y + self.speed end if love.keyboard.isDown("left") and self.x > 0 then self.x = self.x - self.speed end if love.keyboard.isDown("right") and self.x < width then self.x = self.x + self.speed end end function Pastor:draw() love.graphics.draw(self.sprite, self.x, self.y) end