Browse Source

fix bagel stacking

master
Nicholas Hayashi 4 years ago
parent
commit
43a2dd6f70
  1. 11
      src/extra.lua
  2. 12
      src/game.lua
  3. 7
      src/tower.lua
  4. 1
      texture.lua

11
src/extra.lua

@ -21,10 +21,21 @@ function math.lerp(v1, v2, t)
return v1 * t + v2 * (1 - t) return v1 * t + v2 * (1 - t)
end end
-- don't use this with sparse arrays
function table.rchoice(t) function table.rchoice(t)
return t[math.floor(math.random() * #t) + 1] return t[math.floor(math.random() * #t) + 1]
end 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) function table.find(t, predicate)
for i,v in pairs(t) do for i,v in pairs(t) do
if predicate(v) then if predicate(v) then

12
src/game.lua

@ -23,7 +23,7 @@ local TRDTS = {
} }
local function get_initial_game_state(seed) local function get_initial_game_state(seed)
local STARTING_MONEY = 100
local STARTING_MONEY = 100000
-- 2014 -- 2014
local map, world = random_map() local map, world = random_map()
@ -41,7 +41,7 @@ local function get_initial_game_state(seed)
time_until_next_wave = 15, time_until_next_wave = 15,
time_until_next_break = 0, time_until_next_break = 0,
spawning = false, spawning = false,
spawn_chance = 25,
spawn_chance = 55,
selected_tower_type = false, selected_tower_type = false,
selected_toolbelt_button = 9, selected_toolbelt_button = 9,
@ -96,11 +96,11 @@ function select_toolbelt_button(i)
end end
local function get_wave_time(current_wave) local function get_wave_time(current_wave)
return math.log(current_wave) + 90
return 90
end end
local function get_break_time(current_wave) local function get_break_time(current_wave)
return math.log(current_wave) + 15
return 15
end end
function do_day_night_cycle() function do_day_night_cycle()
@ -140,13 +140,14 @@ local function game_action(scene)
state.time = state.time + am.delta_time state.time = state.time + am.delta_time
state.score = state.score + 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 if state.spawning then
state.time_until_next_break = state.time_until_next_break - am.delta_time state.time_until_next_break = state.time_until_next_break - am.delta_time
if state.time_until_next_break <= 0 then if state.time_until_next_break <= 0 then
state.time_until_next_break = 0 state.time_until_next_break = 0
state.current_wave = state.current_wave + 1
state.spawning = false state.spawning = false
state.time_until_next_wave = get_wave_time(state.current_wave) 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 if state.time_until_next_wave <= 0 then
state.time_until_next_wave = 0 state.time_until_next_wave = 0
state.current_wave = state.current_wave + 1
state.spawning = true state.spawning = true
state.time_until_next_break = get_break_time(state.current_wave) state.time_until_next_break = get_break_time(state.current_wave)

7
src/tower.lua

@ -217,11 +217,14 @@ end
function tower_type_is_buildable_on(hex, tile, tower_type) function tower_type_is_buildable_on(hex, tile, tower_type)
if not tower_type then return false end 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_towers = towers_on_hex(hex)
local blocking_mobs = mobs_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 local blocked = mobs_blocking or towers_blocking

1
texture.lua

@ -1,4 +1,5 @@
local function load_texture(filepath) local function load_texture(filepath)
local status, texture = pcall(am.texture2d, filepath) local status, texture = pcall(am.texture2d, filepath)

Loading…
Cancel
Save