I coded up a TicTacToe game also - took about 4 hours in Codea. I put the code up as a Gist: https://gist.github.com/4272076
Aren’t you missing the timer class?
You can grab the class from my utils gist or, to make it faster, here’s a copy of that class:
----
Timer = class()
function Timer:init(secs, callback)
-- you can accept and set parameters here
self.ticks=0
self.callback = callback or nil
self.secs=secs
end
function Timer:start()
self.ticks=ElapsedTime
end
function Timer:running()
return self.ticks > 0
end
--ac: timer is queries, we have to ask if we are elapsed.
--returns true when timer has elapsed
function Timer:check()
if self.ticks > 0 then
if ElapsedTime - self.ticks>=self.secs then
self.timer=0
-- if the timer fires, "magically" call the callback...untested!!
if self.callback ~= nil then self.callback() end
return true -- old school checking.
end
end
return false
end
My grid / box hit tests are very poor, btw.