summaryrefslogtreecommitdiff
path: root/Camera.lua
diff options
context:
space:
mode:
authorthe lemons <citrons@mondecitronne.com>2022-08-21 20:37:53 -0500
committerthe lemons <citrons@mondecitronne.com>2022-08-21 20:37:53 -0500
commit4fbbf73aeb39566f73d54e3d42670c7c258e2466 (patch)
tree41bef03c3547c69b8e703b068da4d84c8df1ce31 /Camera.lua
everything so far
basic mechanics and player control have been implemented, but they work very poorly at present.
Diffstat (limited to 'Camera.lua')
-rw-r--r--Camera.lua24
1 files changed, 24 insertions, 0 deletions
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