-- ************************************ Clock ************************************ --
Clock = deriveLuaClass("Clock", "SpriteExt")

function Clock:init(desc)
	self.initHands = true
end

function Clock:onTick(time)
	self:tick(time)
	if (self.initHands) then
		self.big_hand = level:getSpriteExt("clock_big_hand")
		if (self.big_hand) then
			self.small_hand = level:getSpriteExt("clock_small_hand")
			self.big_hand.anchor = {3.5, 12.5}
			self.small_hand.anchor = {3.5, 12.5}
		end
		self.initHands = false
	end
	if (self.big_hand) then
		local date = os.date("*t")
		if (self.minute ~= date.min) then
			local minutes = (date.min / 60) * 360
			self.big_hand.rotation = ((date.hour % 12) / 12) * 360 + minutes/12
			self.small_hand.rotation = minutes
			self.minute = date.min
		end
	end
end
