blob: 8a12fa86f32a2e089976d20c6590294d4d2aab7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
local game = require 'game'
local Camera = game.Object:extend()
function Camera:use()
local x, y = unpack(self.pos)
local scale = 1 / self.scale
local transform = love.math.newTransform(
-x + 1920 / 2, -y + 1080 / 2, -self.rot, scale, scale)
love.graphics.applyTransform(transform)
end
function Camera:follow(obj)
self.following = obj
end
function Camera:update(dt)
if self.following then
self.pos[1] = self.following.pos[1]
self.pos[2] = self.following.pos[2]
end
end
return Camera
|