Have it be a coinflip whether you or a slime will die

This commit is contained in:
Juhani Krekelä 2019-06-29 23:35:02 +03:00
parent 500fe1caed
commit 3303c52fbc
2 changed files with 18 additions and 3 deletions

2
README
View File

@ -1,7 +1,7 @@
A dungeon crawler. That is, you are crawling around in a dungeon.
Find the Orb of Èitmer hidden within the dungeon, and beware the slimes for
they will consume you if they catch up to you.
it is up to chance whether you or they will prevail should you meet.
Movement:

View File

@ -602,7 +602,7 @@ function newGame()
end
function moveSlimes()
for i, slime in ipairs(slimes) do
for i, slime in pairs(slimes) do
local dx = 0
local dy = 0
@ -651,6 +651,17 @@ function moveSlimes()
end
end
function killSlime()
local body_x, body_y = getBodyLocation()
for i, slime in pairs(slimes) do
if slime.x == player_x and slime.y == player_y or slime.x == body_x and slime.y == body_y then
cavern[slime.x][slime.y] = tiletypes.empty
slimes[i] = nil
end
end
end
function step(direction)
if game_mode == gamemodes.normal then
if last_direction_moved == direction then
@ -673,7 +684,11 @@ function step(direction)
end
if collidedPlayerSlime() then
newGame()
if math.random(0, 1) == 0 then
newGame()
else
killSlime()
end
end
end
end