summaryrefslogtreecommitdiff
path: root/game.lua
blob: 16b1e060ad8b433c684acf0dde14da8eb9c09044 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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