Function rename

This commit is contained in:
Matthias Richter 2010-09-15 11:28:06 +02:00
parent 1f69ddb249
commit b8dc9b6592

View File

@ -36,18 +36,18 @@ function camera:draw(func)
self:postdraw() self:postdraw()
end end
function camera:toScreenCoords(p) function camera:toCameraCoords(p)
local w,h = love.graphics.getWidth(), love.graphics.getHeight() local w,h = love.graphics.getWidth(), love.graphics.getHeight()
local p = p - self.pos local p = p - self.pos
return vector((p.x+w/2) * self.zoom, (p.y+h/2) / self.zoom):rotate_inplace(self.rot) return vector((p.x+w/2) * self.zoom, (p.y+h/2) / self.zoom):rotate_inplace(self.rot)
end end
function camera:toCameraCoords(p) function camera:toWorldCoords(p)
local w,h = love.graphics.getWidth(), love.graphics.getHeight() local w,h = love.graphics.getWidth(), love.graphics.getHeight()
p = vector((p.x-w/2) / self.zoom, (p.y-h/2) / self.zoom):rotate_inplace(-self.rot) p = vector((p.x-w/2) / self.zoom, (p.y-h/2) / self.zoom):rotate_inplace(-self.rot)
return p + self.pos return p + self.pos
end end
function camera:mousepos() function camera:mousepos()
return self:toCameraCoords(vector(love.mouse.getPosition())) return self:toWorldCoords(vector(love.mouse.getPosition()))
end end