From cc4415785fa17bbdba99762720043a868cbb7547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Mon, 1 Jul 2019 20:20:31 +0300 Subject: [PATCH] Autoeitmer --- Makefile | 6 +++--- README | 24 ++---------------------- bundle/conf.lua | 2 +- bundle/main.lua | 35 ++++++++++++++++++----------------- scripts/package-nix.sh | 6 +++--- scripts/package-win32.sh | 12 ++++++------ 6 files changed, 33 insertions(+), 52 deletions(-) diff --git a/Makefile b/Makefile index c6f85dd..5fc067b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ -LOVEFILE=eitmer.love -WIN32_ZIPBALL=eitmer-win32.zip -NIX_TARBALL=eitmer-nix.tar.gz +LOVEFILE=autoeitmer.love +WIN32_ZIPBALL=autoeitmer-win32.zip +NIX_TARBALL=autoeitmer-nix.tar.gz .PHONY: all clean distclean run diff --git a/README b/README index 836f79f..abd0d2c 100644 --- a/README +++ b/README @@ -1,25 +1,5 @@ -A dungeon crawler. That is, you are crawling around in a dungeon. This means -you can't easily turn around in tight spaces and your vision to where you -came from is limited. - -Find the Orb of Èitmer hidden within the dungeon, and beware the slimes for -it is up to chance whether you or they will prevail should you meet. It is -however better to face them head-on than to suffer an attack from behind. - -If you find yourself stuck in a corner, try moving diagonally backwards. - - i -jkl - movement up, left, down, right - -u o -m . - movement upleft, downleft, downright, upright - -a - autoexplore - -space - do nothing for a turn -r - restart -q - quit -c - configure keybindings +A dungeon crawler. That is, you are crawling around in a dungeon. Well, not you +in this version, but rather the computer. The game code and assets are under Creative Commons Zero 1.0 Universal license. If other code or data is distributed alongside them, see the diff --git a/bundle/conf.lua b/bundle/conf.lua index 73850aa..eb384b6 100644 --- a/bundle/conf.lua +++ b/bundle/conf.lua @@ -1,5 +1,5 @@ function love.conf(t) - t.window.title = "The Orb of Èitmer" + t.window.title = "The Automatic Orb of Èitmer" t.window.width = 1280 t.window.height = 960 t.window.resizable = true diff --git a/bundle/main.lua b/bundle/main.lua index dfbd9ba..1c21a3b 100644 --- a/bundle/main.lua +++ b/bundle/main.lua @@ -25,8 +25,7 @@ local heart_sprite = nil local slimes = {} -local last_key_pressed = nil -local move_repeat_counter = nil +local move_repeat_counter = 0.1 local gamemodes = {normal = 0, won = 1, lost = 2, config = 3} local game_mode = nil @@ -35,20 +34,13 @@ local configuration_steps = {quit = -4, restart = -3, configure = -2, autoexplor local configuration_step = nil local direction_keys = {} -direction_keys['i'] = directions.up -direction_keys['u'] = directions.upleft -direction_keys['j'] = directions.left -direction_keys['m'] = directions.downleft -direction_keys['k'] = directions.down -direction_keys['.'] = directions.downright -direction_keys['l'] = directions.right -direction_keys['o'] = directions.upright -direction_keys['space'] = directions.inplace -local control_keys = {quit = 'q', restart = 'r', configure = 'c', autoexplore = 'a'} +local control_keys = {quit = 'q', restart = '', configure = '', autoexplore = ''} local win_image = nil local win_is_raster = true +local reset_counter = nil + -- ------------------------------------------------------------------ -- Cavern generation -- ------------------------------------------------------------------ @@ -606,6 +598,7 @@ function newGame() if collidedPlayerOrb() then game_mode = gamemodes.won + reset_counter = 5 end end @@ -683,6 +676,7 @@ function step(direction) if collidedPlayerOrb() then game_mode = gamemodes.won + reset_counter = 5 end local body_x, body_y = getBodyLocation() @@ -749,7 +743,7 @@ function autoexplore() for x, list in ipairs(visibility_map) do for y, visible in ipairs(list) do - if not visible and remembered_cavern[x][y] == nil then + if not visible and remembered_cavern[x][y] == nil or cavern[x][y] == tiletypes.orb then distances[x][y] = {value = 0, direction = directions.inplace} neighbors(queue, x, y, 1) end @@ -1131,8 +1125,16 @@ end function love.update(dt) if move_repeat_counter ~= nil and move_repeat_counter > 0 then move_repeat_counter = move_repeat_counter - dt - if move_repeat_counter <= 0 and last_key_pressed ~= nil then - love.keypressed(last_key_pressed) + if move_repeat_counter <= 0 then + autoexplore() + move_repeat_counter = 0.1 + end + end + if reset_counter ~= nil then + reset_counter = reset_counter - dt + if reset_counter <= 0 then + newGame() + reset_counter = nil end end @@ -1143,6 +1145,7 @@ function love.update(dt) flash_player_damaged_counter = flash_player_damaged_counter - dt if hp == 0 and flash_player_damaged_counter <= 0 and game_mode ~= gamemodes.won then game_mode = gamemodes.lost + reset_counter = 5 end end end @@ -1198,8 +1201,6 @@ end function love.keyreleased(key) if last_key_pressed == key then - last_key_pressed = nil - move_repeat_counter = nil end end diff --git a/scripts/package-nix.sh b/scripts/package-nix.sh index 352494d..4b01be8 100644 --- a/scripts/package-nix.sh +++ b/scripts/package-nix.sh @@ -3,8 +3,8 @@ die() { exit 1 } -mkdir -p tmp/eitmer-nix || die mkdir -cp eitmer.love README CC0 tmp/eitmer-nix +mkdir -p tmp/autoeitmer-nix || die mkdir +cp autoeitmer.love README CC0 tmp/autoeitmer-nix cd tmp -tar czvf ../eitmer-nix.tar.gz eitmer-nix +tar czvf ../autoeitmer-nix.tar.gz autoeitmer-nix diff --git a/scripts/package-win32.sh b/scripts/package-win32.sh index 178ce3c..28c29df 100644 --- a/scripts/package-win32.sh +++ b/scripts/package-win32.sh @@ -11,15 +11,15 @@ get() { version="11.2" -mkdir -p tmp/eitmer-win32 || die mkdir +mkdir -p tmp/autoeitmer-win32 || die mkdir cd tmp test -e love-$version-win32/ || get cd love-$version-win32/ -cat love.exe ../../eitmer.love > ../eitmer-win32/eitmer.exe || die cat -cp *.dll license.txt ../eitmer-win32/ || die cp -cp ../../README ../eitmer-win32/readme.txt || die cp -cp ../../CC0 ../eitmer-win32/CC0.txt || die cp +cat love.exe ../../autoeitmer.love > ../autoeitmer-win32/autoeitmer.exe || die cat +cp *.dll license.txt ../autoeitmer-win32/ || die cp +cp ../../README ../autoeitmer-win32/readme.txt || die cp +cp ../../CC0 ../autoeitmer-win32/CC0.txt || die cp cd .. -zip -9 -r ../eitmer-win32.zip eitmer-win32 +zip -9 -r ../autoeitmer-win32.zip autoeitmer-win32