From 93de2ebdd79454087f8299603959f22bdb48bb89 Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 26 Sep 2013 00:32:09 +0200 Subject: [PATCH] added demo files --- main.lua | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 main.lua diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..8e7fb7e --- /dev/null +++ b/main.lua @@ -0,0 +1,48 @@ +local cron = require 'cron' + +local counter = 10 +local exploded = false +local defused = false + +local bombClock +local exitClock + +function ticktack() + if exploded or defused then return end + counter = counter - 1 + if counter <= 0 then + exploded = true + exitClock = cron.after(2, love.event.quit) + end +end + +function love.keypressed(key, unicode) + if exploded or defused then return end + if key == ' ' then + defused = true + exitClock = cron.after(2, love.event.quit) + end +end + +function love.load() + bombClock = cron.every(1, ticktack) -- execute the ticktack function every second +end + +function love.update(dt) + bombClock:update(dt) + if exitClock then exitClock:update(dt) end +end + +function love.draw() + local msg + if exploded then + msg = 'BOOM! Game over. Bye!' + elseif defused then + msg = "Good job! You saved the day! Bye!" + else + msg = 'You have ' .. tostring(counter) .. ' seconds left to defuse the bomb - press space to defuse it!' + end + love.graphics.print(msg, 100, 200 ) +end + +