diff --git a/src/extra.lua b/src/extra.lua index dc0c20f..3c38873 100644 --- a/src/extra.lua +++ b/src/extra.lua @@ -21,10 +21,21 @@ function math.lerp(v1, v2, t) return v1 * t + v2 * (1 - t) end +-- don't use this with sparse arrays function table.rchoice(t) return t[math.floor(math.random() * #t) + 1] end +function table.count(t) + local count = 0 + for i,v in pairs(t) do + if v ~= nil then + count = count + 1 + end + end + return count +end + function table.find(t, predicate) for i,v in pairs(t) do if predicate(v) then diff --git a/src/game.lua b/src/game.lua index e47f2d1..0cae70b 100644 --- a/src/game.lua +++ b/src/game.lua @@ -23,7 +23,7 @@ local TRDTS = { } local function get_initial_game_state(seed) - local STARTING_MONEY = 100 + local STARTING_MONEY = 100000 -- 2014 local map, world = random_map() @@ -41,7 +41,7 @@ local function get_initial_game_state(seed) time_until_next_wave = 15, time_until_next_break = 0, spawning = false, - spawn_chance = 25, + spawn_chance = 55, selected_tower_type = false, selected_toolbelt_button = 9, @@ -96,11 +96,11 @@ function select_toolbelt_button(i) end local function get_wave_time(current_wave) - return math.log(current_wave) + 90 + return 90 end local function get_break_time(current_wave) - return math.log(current_wave) + 15 + return 15 end function do_day_night_cycle() @@ -140,13 +140,14 @@ local function game_action(scene) state.time = state.time + am.delta_time state.score = state.score + am.delta_time - state.spawn_chance = state.spawn_chance - math.floor(state.time / 100) + --state.spawn_chance = math.clamp(state.spawn_chance - math.floor(state.time / 100), 1, 25) if state.spawning then state.time_until_next_break = state.time_until_next_break - am.delta_time if state.time_until_next_break <= 0 then state.time_until_next_break = 0 + state.current_wave = state.current_wave + 1 state.spawning = false state.time_until_next_wave = get_wave_time(state.current_wave) @@ -156,7 +157,6 @@ local function game_action(scene) if state.time_until_next_wave <= 0 then state.time_until_next_wave = 0 - state.current_wave = state.current_wave + 1 state.spawning = true state.time_until_next_break = get_break_time(state.current_wave) diff --git a/src/tower.lua b/src/tower.lua index d63fc9c..bc568e4 100644 --- a/src/tower.lua +++ b/src/tower.lua @@ -217,11 +217,14 @@ end function tower_type_is_buildable_on(hex, tile, tower_type) if not tower_type then return false end + -- @TODO remove this shit + if hex == HEX_GRID_CENTER then return false end + local blocking_towers = towers_on_hex(hex) local blocking_mobs = mobs_on_hex(hex) - local towers_blocking = #blocking_towers ~= 0 - local mobs_blocking = #blocking_mobs ~= 0 + local towers_blocking = table.count(blocking_towers) ~= 0 + local mobs_blocking = table.count(blocking_mobs) ~= 0 local blocked = mobs_blocking or towers_blocking diff --git a/texture.lua b/texture.lua index e947869..64fd963 100644 --- a/texture.lua +++ b/texture.lua @@ -1,4 +1,5 @@ + local function load_texture(filepath) local status, texture = pcall(am.texture2d, filepath)