summaryrefslogtreecommitdiff
path: root/game.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 /game.lua
everything so far
basic mechanics and player control have been implemented, but they work very poorly at present.
Diffstat (limited to 'game.lua')
-rw-r--r--game.lua43
1 files changed, 43 insertions, 0 deletions
diff --git a/game.lua b/game.lua
new file mode 100644
index 0000000..16b1e06
--- /dev/null
+++ b/game.lua
@@ -0,0 +1,43 @@
+local Obj = require 'Obj'
+
+local M = {}
+
+M.all_objects = {}
+
+M.Object = Obj:extend()
+M.Object.z = 0
+
+function M.Object:new(pos, rotation, scale)
+ self.pos = pos or {0, 0, 0}
+ self.rot = rotation or 0
+ self.scale = scale or 1
+ self:enable()
+end
+
+function M.Object:enable()
+ M.all_objects[self] = true
+end
+
+function M.Object:disable()
+ M.all_objects[self] = nil
+end
+
+function M.Object:update()
+end
+
+function M.Object:draw()
+ if self.sprite then
+ local x, y = unpack(self.pos)
+ local w, h = self.sprite:getDimensions()
+ ox = (w * self.scale) / 2
+ oy = (h * self.scale) / 2
+ love.graphics.draw(
+ self.sprite, x, y, self.rot, self.scale, self.scale, ox, oy)
+ end
+end
+
+function M.Object:visible()
+ return not self.hidden
+end
+
+return M