diff --git a/android/game.apk b/android/game.apk index 6721d82..f6edeaa 100644 Binary files a/android/game.apk and b/android/game.apk differ diff --git a/android/game.love b/android/game.love index c4b565a..a6081bf 100644 Binary files a/android/game.love and b/android/game.love differ diff --git a/android/icon.png b/android/icon.png index e0567f6..0fe1ae6 100644 Binary files a/android/icon.png and b/android/icon.png differ diff --git a/android/tools/love-android-sdl2/AndroidManifest.xml b/android/tools/love-android-sdl2/AndroidManifest.xml index a8409ae..3e7d9a7 100644 --- a/android/tools/love-android-sdl2/AndroidManifest.xml +++ b/android/tools/love-android-sdl2/AndroidManifest.xml @@ -1,5 +1,5 @@ - @@ -12,13 +12,13 @@ diff --git a/android/tools/love-android-sdl2/assets/game.love b/android/tools/love-android-sdl2/assets/game.love index c4b565a..a6081bf 100644 Binary files a/android/tools/love-android-sdl2/assets/game.love and b/android/tools/love-android-sdl2/assets/game.love differ diff --git a/android/tools/love-android-sdl2/bin/AndroidManifest.xml b/android/tools/love-android-sdl2/bin/AndroidManifest.xml index a8409ae..3e7d9a7 100644 --- a/android/tools/love-android-sdl2/bin/AndroidManifest.xml +++ b/android/tools/love-android-sdl2/bin/AndroidManifest.xml @@ -1,5 +1,5 @@ - @@ -12,13 +12,13 @@ diff --git a/android/tools/love-android-sdl2/bin/build.prop b/android/tools/love-android-sdl2/bin/build.prop index efe666a..d706830 100644 --- a/android/tools/love-android-sdl2/bin/build.prop +++ b/android/tools/love-android-sdl2/bin/build.prop @@ -1,5 +1,5 @@ #Last build type -#Mon, 26 Dec 2016 12:09:05 +0100 +#Tue, 03 Jan 2017 23:46:23 +0100 build.last.target=debug diff --git a/android/tools/love-android-sdl2/bin/classes.dex b/android/tools/love-android-sdl2/bin/classes.dex index 238fffc..fff892f 100644 Binary files a/android/tools/love-android-sdl2/bin/classes.dex and b/android/tools/love-android-sdl2/bin/classes.dex differ diff --git a/android/tools/love-android-sdl2/bin/classes.dex.d b/android/tools/love-android-sdl2/bin/classes.dex.d index 912f3c9..b63cba1 100644 --- a/android/tools/love-android-sdl2/bin/classes.dex.d +++ b/android/tools/love-android-sdl2/bin/classes.dex.d @@ -1,9 +1,9 @@ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes.dex : \ -/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/BuildConfig.class \ -/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/LtaActivity.class \ -/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R$attr.class \ -/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R$drawable.class \ -/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R.class \ +/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/BuildConfig.class \ +/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/LtaActivity.class \ +/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R$attr.class \ +/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R$drawable.class \ +/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R.class \ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/org/libsdl/app/DummyEdit.class \ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/org/libsdl/app/SDLActivity$1.class \ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/classes/org/libsdl/app/SDLActivity$2.class \ diff --git a/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/BuildConfig.class b/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/BuildConfig.class similarity index 74% rename from android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/BuildConfig.class rename to android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/BuildConfig.class index 3a6dc2c..23e9b97 100644 Binary files a/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/BuildConfig.class and b/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/BuildConfig.class differ diff --git a/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/LtaActivity.class b/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/LtaActivity.class similarity index 62% rename from android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/LtaActivity.class rename to android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/LtaActivity.class index 14f349b..30bca49 100644 Binary files a/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/LtaActivity.class and b/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/LtaActivity.class differ diff --git a/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R$attr.class b/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R$attr.class new file mode 100644 index 0000000..76a621e Binary files /dev/null and b/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R$attr.class differ diff --git a/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R$drawable.class b/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R$drawable.class similarity index 56% rename from android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R$drawable.class rename to android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R$drawable.class index 577d896..f91ae39 100644 Binary files a/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R$drawable.class and b/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R$drawable.class differ diff --git a/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R.class b/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R.class similarity index 63% rename from android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R.class rename to android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R.class index c84a62c..2e15eb4 100644 Binary files a/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R.class and b/android/tools/love-android-sdl2/bin/classes/love/to/android0103234617/R.class differ diff --git a/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R$attr.class b/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R$attr.class deleted file mode 100644 index 07d501a..0000000 Binary files a/android/tools/love-android-sdl2/bin/classes/love/to/android1226120858/R$attr.class and /dev/null differ diff --git a/android/tools/love-android-sdl2/bin/love_android_sdl2-debug-unaligned.apk b/android/tools/love-android-sdl2/bin/love_android_sdl2-debug-unaligned.apk index ac2a933..e11a4e7 100644 Binary files a/android/tools/love-android-sdl2/bin/love_android_sdl2-debug-unaligned.apk and b/android/tools/love-android-sdl2/bin/love_android_sdl2-debug-unaligned.apk differ diff --git a/android/tools/love-android-sdl2/bin/love_android_sdl2-debug.apk b/android/tools/love-android-sdl2/bin/love_android_sdl2-debug.apk index 6721d82..f6edeaa 100644 Binary files a/android/tools/love-android-sdl2/bin/love_android_sdl2-debug.apk and b/android/tools/love-android-sdl2/bin/love_android_sdl2-debug.apk differ diff --git a/android/tools/love-android-sdl2/bin/love_android_sdl2.ap_ b/android/tools/love-android-sdl2/bin/love_android_sdl2.ap_ index fa55576..41b135a 100644 Binary files a/android/tools/love-android-sdl2/bin/love_android_sdl2.ap_ and b/android/tools/love-android-sdl2/bin/love_android_sdl2.ap_ differ diff --git a/android/tools/love-android-sdl2/bin/proguard.txt b/android/tools/love-android-sdl2/bin/proguard.txt index bb99f3e..415524b 100644 --- a/android/tools/love-android-sdl2/bin/proguard.txt +++ b/android/tools/love-android-sdl2/bin/proguard.txt @@ -1,9 +1,9 @@ # view AndroidManifest.xml #generated:45 --keep class love.to.android1226120858.DownloadActivity { (...); } +-keep class love.to.android0103234617.DownloadActivity { (...); } # view AndroidManifest.xml #generated:17 --keep class love.to.android1226120858.DownloadService { (...); } +-keep class love.to.android0103234617.DownloadService { (...); } # view AndroidManifest.xml #generated:18 --keep class love.to.android1226120858.LtaActivity { (...); } +-keep class love.to.android0103234617.LtaActivity { (...); } diff --git a/android/tools/love-android-sdl2/bin/res/drawable-xxhdpi/ic_launcher.png b/android/tools/love-android-sdl2/bin/res/drawable-xxhdpi/ic_launcher.png index e7559c2..01b1eae 100644 Binary files a/android/tools/love-android-sdl2/bin/res/drawable-xxhdpi/ic_launcher.png and b/android/tools/love-android-sdl2/bin/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/android/tools/love-android-sdl2/gen/R.java.d b/android/tools/love-android-sdl2/gen/R.java.d index 5889185..a6a51d0 100644 --- a/android/tools/love-android-sdl2/gen/R.java.d +++ b/android/tools/love-android-sdl2/gen/R.java.d @@ -1,3 +1,3 @@ -/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/gen/love/to/android1226120858/R.java \ +/Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/gen/love/to/android0103234617/R.java \ : /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/res/drawable-xxhdpi/ic_launcher.png \ /Users/androsfenollosa/www/alunizaje/android/tools/love-android-sdl2/bin/AndroidManifest.xml \ diff --git a/android/tools/love-android-sdl2/gen/love/to/android1226120858/BuildConfig.java b/android/tools/love-android-sdl2/gen/love/to/android0103234617/BuildConfig.java similarity index 79% rename from android/tools/love-android-sdl2/gen/love/to/android1226120858/BuildConfig.java rename to android/tools/love-android-sdl2/gen/love/to/android0103234617/BuildConfig.java index 2c4d462..13cc3d8 100644 --- a/android/tools/love-android-sdl2/gen/love/to/android1226120858/BuildConfig.java +++ b/android/tools/love-android-sdl2/gen/love/to/android0103234617/BuildConfig.java @@ -1,5 +1,5 @@ /** Automatically generated file. DO NOT MODIFY */ -package love.to.android1226120858; +package love.to.android0103234617; public final class BuildConfig { public final static boolean DEBUG = true; diff --git a/android/tools/love-android-sdl2/gen/love/to/android1226120858/R.java b/android/tools/love-android-sdl2/gen/love/to/android0103234617/R.java similarity index 91% rename from android/tools/love-android-sdl2/gen/love/to/android1226120858/R.java rename to android/tools/love-android-sdl2/gen/love/to/android0103234617/R.java index 0eb0cf0..36da636 100644 --- a/android/tools/love-android-sdl2/gen/love/to/android1226120858/R.java +++ b/android/tools/love-android-sdl2/gen/love/to/android0103234617/R.java @@ -5,7 +5,7 @@ * should not be modified by hand. */ -package love.to.android1226120858; +package love.to.android0103234617; public final class R { public static final class attr { diff --git a/android/tools/love-android-sdl2/res/drawable-xxhdpi/ic_launcher.png b/android/tools/love-android-sdl2/res/drawable-xxhdpi/ic_launcher.png index e0567f6..0fe1ae6 100644 Binary files a/android/tools/love-android-sdl2/res/drawable-xxhdpi/ic_launcher.png and b/android/tools/love-android-sdl2/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/android/tools/love-android-sdl2/src/love/to/android1226120858/LtaActivity.java b/android/tools/love-android-sdl2/src/love/to/android0103234617/LtaActivity.java similarity index 69% rename from android/tools/love-android-sdl2/src/love/to/android1226120858/LtaActivity.java rename to android/tools/love-android-sdl2/src/love/to/android0103234617/LtaActivity.java index 8236598..ab903bd 100644 --- a/android/tools/love-android-sdl2/src/love/to/android1226120858/LtaActivity.java +++ b/android/tools/love-android-sdl2/src/love/to/android0103234617/LtaActivity.java @@ -1,4 +1,4 @@ -package love.to.android1226120858; +package love.to.android0103234617; import org.love2d.android.GameActivity; public class LtaActivity extends GameActivity {} diff --git a/assets/scripts/controls.lua b/assets/scripts/controls.lua index 3a78bca..44e962e 100644 --- a/assets/scripts/controls.lua +++ b/assets/scripts/controls.lua @@ -1,33 +1,35 @@ +local anim8 = require 'assets/scripts/vendor/anim8' local controls = {} -local buttons = {} +local BUTTONS = {} function controls.load(game) - controls.padding = 50 - controls.img_right = love.graphics.newImage('assets/sprites/hui/button.png') - controls.right_x = game.window.width - controls.img_right:getWidth() - controls.padding - controls.right_y = game.window.height - controls.img_right:getHeight() - controls.padding + local padding = 50 + -- Button left + local img_button_left = love.graphics.newImage('assets/sprites/hui/button_left.png') + local left_x = padding + local left_y = (game.window.height / 3 * 2) - img_button_left:getHeight() - padding + controls.new_button('button_left', left_x, left_y, img_button_left) + -- Button right + local img_button_right = love.graphics.newImage('assets/sprites/hui/button_right.png') + local right_x = game.window.width - (img_button_right:getWidth() / 2) - padding + local right_y = (game.window.height / 3 * 2) - img_button_right:getHeight() - padding + controls.new_button('button_right', right_x, right_y, img_button_right) + -- Button up + local img_button_up = love.graphics.newImage('assets/sprites/hui/button_up.png') + local up_x = game.window.width - (img_button_up:getWidth() / 2) - padding + local up_y = (game.window.height / 3) - img_button_up:getHeight() - padding + controls.new_button('button_up', up_x, up_y, img_button_up) end function controls.update(dt) - -- Keyboard - -- Mouse if love.mouse.isDown(1) then - local x, y = love.mouse.getPosition() - -- Up - if x > button_up.x and x < button_up.x + button.img:getWidth() and y > button_up.y + camera.y and y < button_up.y + button.img:getHeight() + camera.y then - control_up = true - end - -- Right - if x > button_right.x and x < button_right.x + button.img:getWidth() and y > button_right.y + camera.y and y < button_right.y + button.img:getHeight() + camera.y then - control_right = true - elseif x > button_left.x and x < button_left.x + button.img:getWidth() and y > button_left.y + camera.y and y < button_left.y + button.img:getHeight() + camera.y then - control_left = true - end end end function controls.draw() - love.graphics.draw(controls.img_right, controls.right_x, controls.right_y) + for key, button in pairs(BUTTONS) do + button.animation:draw(button.img, button.x, button.y) + end end function controls.keypressed(key, scancode, isrepeat) @@ -49,9 +51,43 @@ function controls.keyreleased(key, scancode) end function controls.mousepressed(x, y, button, istouch) + local buttons_pressends = {} + for key, button in pairs(BUTTONS) do + if button.x <= x and x <= (button.x + (button.img:getWidth() / 2)) and button.y <= y and y <= (button.y + button.img:getHeight()) then + table.insert(buttons_pressends, button.name) + button.animation:gotoFrame(2) + mouse_actions(button.name) + end + end end function controls.mousereleased(x, y, button, istouch) + CONTROL_UP, CONTROL_RIGHT, CONTROL_LEFT, CONTROL_QUIT = false, false, false, false + for key, button in pairs(BUTTONS) do + button.animation:gotoFrame(1) + end +end + +function controls.new_button(name, x, y, img) + img_temp = img + g = anim8.newGrid(img_temp:getWidth() / 2, img_temp:getHeight(), img_temp:getWidth(), img_temp:getHeight()) + table.insert(BUTTONS, { + name=name, + x=x, + y=y, + img=img_temp, + animation = anim8.newAnimation(g('1-2', 1), 1) + }) +end + +function mouse_actions(name) + if name == 'button_left' then + CONTROL_LEFT = true + elseif name == 'button_right' then + CONTROL_RIGHT = true + elseif name == 'button_up' then + CONTROL_UP = true + end end return controls \ No newline at end of file diff --git a/assets/scripts/game.lua b/assets/scripts/game.lua index 38ae59d..b26f09f 100644 --- a/assets/scripts/game.lua +++ b/assets/scripts/game.lua @@ -10,6 +10,7 @@ function game.load() game.level = 1 game.play = true -- Physics + DEBUG = true local world_meter = 64 local gravity = 2 love.physics.setMeter(world_meter) -- Height earth in meters diff --git a/assets/scripts/vendor/lovebird.lua b/assets/scripts/vendor/lovebird.lua new file mode 100755 index 0000000..1195372 --- /dev/null +++ b/assets/scripts/vendor/lovebird.lua @@ -0,0 +1,724 @@ +-- +-- lovebird +-- +-- Copyright (c) 2016 rxi +-- +-- This library is free software; you can redistribute it and/or modify it +-- under the terms of the MIT license. See LICENSE for details. +-- + +local socket = require "socket" + +local lovebird = { _version = "0.4.1" } + +lovebird.loadstring = loadstring or load +lovebird.inited = false +lovebird.host = "*" +lovebird.buffer = "" +lovebird.lines = {} +lovebird.connections = {} +lovebird.pages = {} + +lovebird.wrapprint = true +lovebird.timestamp = true +lovebird.allowhtml = false +lovebird.echoinput = true +lovebird.port = 8000 +lovebird.whitelist = { "127.0.0.1" } +lovebird.maxlines = 200 +lovebird.updateinterval = .5 + + +lovebird.pages["index"] = [[ + + + + + + + lovebird + + + + +
+
+
+
+
+ +
+
+
+
+
+
+
+
+ + + +]] + + +lovebird.pages["buffer"] = [[ ]] + + +lovebird.pages["env.json"] = [[ + +{ + "valid": true, + "path": "", + "vars": [ + + { + "key": "", + "value": , + "type": "", + }, + + ] +} +]] + + + +function lovebird.init() + -- Init server + lovebird.server = assert(socket.bind(lovebird.host, lovebird.port)) + lovebird.addr, lovebird.port = lovebird.server:getsockname() + lovebird.server:settimeout(0) + -- Wrap print + lovebird.origprint = print + if lovebird.wrapprint then + local oldprint = print + print = function(...) + oldprint(...) + lovebird.print(...) + end + end + -- Compile page templates + for k, page in pairs(lovebird.pages) do + lovebird.pages[k] = lovebird.template(page, "lovebird, req", + "pages." .. k) + end + lovebird.inited = true +end + + +function lovebird.template(str, params, chunkname) + params = params and ("," .. params) or "" + local f = function(x) return string.format(" echo(%q)", x) end + str = ("?>"..str.."(.-)<%?lua", f) + str = "local echo " .. params .. " = ..." .. str + local fn = assert(lovebird.loadstring(str, chunkname)) + return function(...) + local output = {} + local echo = function(str) table.insert(output, str) end + fn(echo, ...) + return table.concat(lovebird.map(output, tostring)) + end +end + + +function lovebird.map(t, fn) + local res = {} + for k, v in pairs(t) do res[k] = fn(v) end + return res +end + + +function lovebird.trace(...) + local str = "[lovebird] " .. table.concat(lovebird.map({...}, tostring), " ") + print(str) + if not lovebird.wrapprint then lovebird.print(str) end +end + + +function lovebird.unescape(str) + local f = function(x) return string.char(tonumber("0x"..x)) end + return (str:gsub("%+", " "):gsub("%%(..)", f)) +end + + +function lovebird.parseurl(url) + local res = {} + res.path, res.search = url:match("/([^%?]*)%??(.*)") + res.query = {} + for k, v in res.search:gmatch("([^&^?]-)=([^&^#]*)") do + res.query[k] = lovebird.unescape(v) + end + return res +end + + +function lovebird.htmlescape(str) + return str:gsub("<", "<") +end + + +function lovebird.truncate(str, len) + if #str <= len then + return str + end + return str:sub(1, len - 3) .. "..." +end + + +function lovebird.compare(a, b) + local na, nb = tonumber(a), tonumber(b) + if na then + if nb then return na < nb end + return false + elseif nb then + return true + end + return tostring(a) < tostring(b) +end + + +function lovebird.checkwhitelist(addr) + if lovebird.whitelist == nil then return true end + for _, a in pairs(lovebird.whitelist) do + local ptn = "^" .. a:gsub("%.", "%%."):gsub("%*", "%%d*") .. "$" + if addr:match(ptn) then return true end + end + return false +end + + +function lovebird.clear() + lovebird.lines = {} + lovebird.buffer = "" +end + + +function lovebird.pushline(line) + line.time = os.time() + line.count = 1 + table.insert(lovebird.lines, line) + if #lovebird.lines > lovebird.maxlines then + table.remove(lovebird.lines, 1) + end + lovebird.recalcbuffer() +end + + +function lovebird.recalcbuffer() + local function doline(line) + local str = line.str + if not lovebird.allowhtml then + str = lovebird.htmlescape(line.str):gsub("\n", "
") + end + if line.type == "input" then + str = '' .. str .. '' + else + if line.type == "error" then + str = '! ' .. str + str = '' .. str .. '' + end + if line.count > 1 then + str = '' .. line.count .. ' ' .. str + end + if lovebird.timestamp then + str = os.date('%H:%M:%S ', line.time) .. + str + end + end + return str + end + lovebird.buffer = table.concat(lovebird.map(lovebird.lines, doline), "
") +end + + +function lovebird.print(...) + local t = {} + for i = 1, select("#", ...) do + table.insert(t, tostring(select(i, ...))) + end + local str = table.concat(t, " ") + local last = lovebird.lines[#lovebird.lines] + if last and str == last.str then + -- Update last line if this line is a duplicate of it + last.time = os.time() + last.count = last.count + 1 + lovebird.recalcbuffer() + else + -- Create new line + lovebird.pushline({ type = "output", str = str }) + end +end + + +function lovebird.onerror(err) + lovebird.pushline({ type = "error", str = err }) + if lovebird.wrapprint then + lovebird.origprint("[lovebird] ERROR: " .. err) + end +end + + +function lovebird.onrequest(req, client) + local page = req.parsedurl.path + page = page ~= "" and page or "index" + -- Handle "page not found" + if not lovebird.pages[page] then + return "HTTP/1.1 404\r\nContent-Length: 8\r\n\r\nBad page" + end + -- Handle page + local str + xpcall(function() + local data = lovebird.pages[page](lovebird, req) + str = "HTTP/1.1 200 OK\r\n" .. + "Content-Length: " .. #data .. "\r\n" .. + "\r\n" .. data + end, lovebird.onerror) + return str +end + + +function lovebird.receive(client, pattern) + while 1 do + local data, msg = client:receive(pattern) + if not data then + if msg == "timeout" then + -- Wait for more data + coroutine.yield(true) + else + -- Disconnected -- yielding nil means we're done + coroutine.yield(nil) + end + else + return data + end + end +end + + +function lovebird.send(client, data) + local idx = 1 + while idx < #data do + local res, msg = client:send(data, idx) + if not res and msg == "closed" then + -- Handle disconnect + coroutine.yield(nil) + else + idx = idx + res + coroutine.yield(true) + end + end +end + + +function lovebird.onconnect(client) + -- Create request table + local requestptn = "(%S*)%s*(%S*)%s*(%S*)" + local req = {} + req.socket = client + req.addr, req.port = client:getsockname() + req.request = lovebird.receive(client, "*l") + req.method, req.url, req.proto = req.request:match(requestptn) + req.headers = {} + while 1 do + local line, msg = lovebird.receive(client, "*l") + if not line or #line == 0 then break end + local k, v = line:match("(.-):%s*(.*)$") + req.headers[k] = v + end + if req.headers["Content-Length"] then + req.body = lovebird.receive(client, req.headers["Content-Length"]) + end + -- Parse body + req.parsedbody = {} + if req.body then + for k, v in req.body:gmatch("([^&]-)=([^&^#]*)") do + req.parsedbody[k] = lovebird.unescape(v) + end + end + -- Parse request line's url + req.parsedurl = lovebird.parseurl(req.url) + -- Handle request; get data to send and send + local data = lovebird.onrequest(req) + lovebird.send(client, data) + -- Clear up + client:close() +end + + +function lovebird.update() + if not lovebird.inited then lovebird.init() end + -- Handle new connections + while 1 do + -- Accept new connections + local client = lovebird.server:accept() + if not client then break end + client:settimeout(0) + local addr = client:getsockname() + if lovebird.checkwhitelist(addr) then + -- Connection okay -- create and add coroutine to set + local conn = coroutine.wrap(function() + xpcall(function() lovebird.onconnect(client) end, function() end) + end) + lovebird.connections[conn] = true + else + -- Reject connection not on whitelist + lovebird.trace("got non-whitelisted connection attempt: ", addr) + client:close() + end + end + -- Handle existing connections + for conn in pairs(lovebird.connections) do + -- Resume coroutine, remove if it has finished + local status = conn() + if status == nil then + lovebird.connections[conn] = nil + end + end +end + + +return lovebird diff --git a/assets/sprites/hui/button.png b/assets/sprites/hui/button.png deleted file mode 100644 index fd2cbb7..0000000 Binary files a/assets/sprites/hui/button.png and /dev/null differ diff --git a/assets/sprites/hui/button_left.png b/assets/sprites/hui/button_left.png new file mode 100644 index 0000000..7b6157a Binary files /dev/null and b/assets/sprites/hui/button_left.png differ diff --git a/assets/sprites/hui/button_right.png b/assets/sprites/hui/button_right.png new file mode 100644 index 0000000..3ff9a4a Binary files /dev/null and b/assets/sprites/hui/button_right.png differ diff --git a/assets/sprites/hui/button_up.png b/assets/sprites/hui/button_up.png new file mode 100644 index 0000000..9ba91c9 Binary files /dev/null and b/assets/sprites/hui/button_up.png differ diff --git a/main.lua b/main.lua index a1a94c0..f8c8b11 100644 --- a/main.lua +++ b/main.lua @@ -19,6 +19,9 @@ end -- UPDATE function love.update(dt) + if DEBUG then + require('assets/scripts/vendor/lovebird').update() + end game.world:update(dt) background.update(dt) asteroids.update(dt, game)