From 538fea556dbf43b587a9a8344e3ad7ea0e7186d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simo-Pekka=20Kerkel=C3=A4?= Date: Thu, 7 Feb 2019 23:56:49 +0200 Subject: [PATCH] initial commit --- .vscode/settings.json | 3 +++ conf.lua | 5 +++++ main.lua | 12 +++++++++-- readme.md | 3 +++ scenes.lua | 49 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 conf.lua create mode 100644 readme.md create mode 100644 scenes.lua diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..cac0e10 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "editor.formatOnSave": true +} \ No newline at end of file diff --git a/conf.lua b/conf.lua new file mode 100644 index 0000000..b5f34b5 --- /dev/null +++ b/conf.lua @@ -0,0 +1,5 @@ +function love.conf(t) + t.window.width = 640 + t.window.height = 480 + t.window.title = "Datix" +end \ No newline at end of file diff --git a/main.lua b/main.lua index cbe23ab..c243efc 100644 --- a/main.lua +++ b/main.lua @@ -1,3 +1,11 @@ -function love.draw() - love.graphics.print("Hello World", 400, 300) +require "scenes" +function love.load() +end + +function love.update(dt) + scenes[#scenes].update(dt) +end + +function love.draw() + scenes[#scenes].draw() end diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..fbfd987 --- /dev/null +++ b/readme.md @@ -0,0 +1,3 @@ +# Game + +Let's see where this goes. \ No newline at end of file diff --git a/scenes.lua b/scenes.lua new file mode 100644 index 0000000..287e5da --- /dev/null +++ b/scenes.lua @@ -0,0 +1,49 @@ +scenes = {} + +time_since_start = 0 +loops = 0 +main_scene = {} +looping_scene = {} +looping_scene.draw = function() + love.graphics.print("Loopdy loo", 110, 120) +end +looping_scene.update = function(dt) + time_since_start = time_since_start + dt + if time_since_start > 2 then + looping_scene.draw = function() + love.graphics.print("Looping continues", 200, 150) + end + end + if time_since_start > 8 then + time_since_start = 0 + table.remove(scenes) + loops = loops + 1 + end +end + +main_scene.update = function(dt) + time_since_start = time_since_start + dt + if time_since_start > 2 then + main_scene.draw = function() + love.graphics.print("Main Scene extended", 400, 300) + end + end + if time_since_start > 6 then + time_since_start = 0 + if loops < 4 then + table.insert(scenes, looping_scene) + else + main_scene.draw = function() + love.graphics.print("Damn, enough with the looping..", 100, 100) + end + end + end +end + +main_scene.draw = function() + love.graphics.print("Main Scene", 400, 300) +end + +table.insert(scenes, main_scene) + +return scenes