From 4fbbf73aeb39566f73d54e3d42670c7c258e2466 Mon Sep 17 00:00:00 2001 From: the lemons Date: Sun, 21 Aug 2022 20:37:53 -0500 Subject: everything so far basic mechanics and player control have been implemented, but they work very poorly at present. --- Camera.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Camera.lua (limited to 'Camera.lua') diff --git a/Camera.lua b/Camera.lua new file mode 100644 index 0000000..8a12fa8 --- /dev/null +++ b/Camera.lua @@ -0,0 +1,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 -- cgit v1.2.3