From cee584832e2d87fa225f84a254c4c07b3e02e64f Mon Sep 17 00:00:00 2001 From: Linus_Probert Date: Mon, 26 Mar 2018 13:53:45 +0200 Subject: [PATCH] Fixed multiple pits in layout file --- data/maproombuilder.lua | 23 +++++++-------- data/pitlayouts.dat | 65 +++++++++++++++++++++++++++++++++++++++++ src/player.c | 2 +- 3 files changed, 76 insertions(+), 14 deletions(-) diff --git a/data/maproombuilder.lua b/data/maproombuilder.lua index 5612126..7604d15 100644 --- a/data/maproombuilder.lua +++ b/data/maproombuilder.lua @@ -157,7 +157,7 @@ local function add_pits_to_room(map) if CURRENT_LEVEL < 2 then return - elseif not random(4) == 1 then + elseif not random(4) ~= 1 then return end @@ -166,8 +166,6 @@ local function add_pits_to_room(map) local cleanData = "" for i=1, #pitdata do local c = pitdata:sub(i+1, i+1) - local col = i % 16 - local row = (i - (i % 16))/16 if c == "#" or c == "-" then cleanData = cleanData .. c end @@ -175,24 +173,23 @@ local function add_pits_to_room(map) local matrix = {} - for i=0, 16 do - matrix[i] = {} - for j=0, 12 do - matrix[i][j] = false - end - end - for i=0, #cleanData-1 do local c = cleanData:sub(i, i) local col = i % 16 - local row = (i - (i % 16))/16 + local row = (i - col)/16 + local layout = 1 + (row - (row % 12))/12 + local row = row % 12 + if not matrix[layout] then matrix[layout] = {} end + if not matrix[layout][col] then matrix[layout][col] = {} end if c == "#" then - matrix[col][row] = true + matrix[layout][col][row] = true elseif c == "-" then - matrix[col][row] = false + matrix[layout][col][row] = false end end + print(#matrix) + matrix = matrix[random(#matrix)] for i=0, 11 do for j=0, 15 do if matrix[j][i] then diff --git a/data/pitlayouts.dat b/data/pitlayouts.dat index ba098d0..776ba93 100644 --- a/data/pitlayouts.dat +++ b/data/pitlayouts.dat @@ -10,3 +10,68 @@ --##--------##-- ---------------- ---------------- + +---------------- +---------------- +---------------- +---------------- +-----##-##------ +-----##-##------ +---------------- +-----##-##------ +-----##-##------ +---------------- +---------------- +---------------- + +---------------- +---------------- +---------------- +--############-- +---------------- +---------------- +---------------- +---------------- +--############-- +---------------- +---------------- +---------------- + +---------------- +---------------- +---------------- +--############-- +---------------- +--############-- +--############-- +---------------- +--############-- +---------------- +---------------- +---------------- + +---------------- +---------------- +--############-- +--############-- +---------------- +---------------- +---------------- +---------------- +--############-- +--############-- +---------------- +---------------- + +---------------- +---------------- +-------#-------- +------###------- +-------#-------- +------###------- +------###------- +-------#-------- +------###------- +-------#-------- +---------------- +---------------- diff --git a/src/player.c b/src/player.c index 4022e98..1896ab8 100644 --- a/src/player.c +++ b/src/player.c @@ -504,7 +504,7 @@ player_reset_steps(Player *p) void player_update(UpdateData *data) { Player *player = data->player; - if (player->state == FALLING) { + if (player->state == FALLING && player->stats.hp > 0) { if (!timer_started(player->animationTimer)) { timer_start(player->animationTimer); player->sprite->clip = CLIP16(0, 0);