Browse Source

better spawn rates

master
Nicholas Hayashi 4 years ago
parent
commit
00cdb68a81
  1. 2
      conf.lua
  2. 20
      src/game.lua
  3. 3
      src/mob.lua
  4. 3
      src/tower.lua

2
conf.lua

@ -2,7 +2,7 @@
title = "hexyz" title = "hexyz"
author = "nick hayashi" author = "nick hayashi"
shortname = "hexyz" shortname = "hexyz"
version = "0.1.1"
version = "0.1.2"
support_email = "" support_email = ""
copyright_message = "Copyright © 2021 Nick Hayashi" copyright_message = "Copyright © 2021 Nick Hayashi"

20
src/game.lua

@ -108,6 +108,12 @@ end
local function game_deserialize(json_string) local function game_deserialize(json_string)
-- @TODO decode from some compressed format or whatever -- @TODO decode from some compressed format or whatever
local new_state = am.parse_json(json_string) local new_state = am.parse_json(json_string)
if new_state.version ~= version then
log("loading old save data.")
return nil
end
new_state.map, new_state.world = random_map(new_state.seed) new_state.map, new_state.world = random_map(new_state.seed)
new_state.seed = nil new_state.seed = nil
@ -221,7 +227,8 @@ local function game_action(scene)
state.spawning = true state.spawning = true
-- calculate spawn chance for next wave -- calculate spawn chance for next wave
state.spawn_chance = math.log(state.current_wave)/2 + 0.002
state.spawn_chance = math.log(state.current_wave)/100 + 0.002
log(state.spawn_chance)
state.time_until_next_break = get_wave_time(state.current_wave) state.time_until_next_break = get_wave_time(state.current_wave)
end end
@ -580,7 +587,7 @@ local function game_scene()
state.current_wave = state.current_wave + 1 state.current_wave = state.current_wave + 1
-- calculate spawn chance for next wave -- calculate spawn chance for next wave
state.spawn_chance = math.log(state.current_wave)/2 + 0.002
state.spawn_chance = math.log(state.current_wave)/100 + 0.002
state.time_until_next_break = state.time_until_next_break + get_break_time(state.current_wave) state.time_until_next_break = state.time_until_next_break + get_break_time(state.current_wave)
@ -624,7 +631,8 @@ local function game_scene()
) )
:tag"game" :tag"game"
scene:action(game_action)
-- dangling actions run before the main action
scene:late_action(game_action)
return scene return scene
end end
@ -647,6 +655,12 @@ function game_init(saved_state)
if saved_state then if saved_state then
state = game_deserialize(saved_state) state = game_deserialize(saved_state)
if not state then
-- failed to load a save
win.scene:append(main_scene(true, true))
return
end
-- @HACK fixes a bug where loading game state with a tower type selected, -- @HACK fixes a bug where loading game state with a tower type selected,
-- but you don't have a built tower cursor node, so hovering a buildable tile throws an error -- but you don't have a built tower cursor node, so hovering a buildable tile throws an error
select_tower_type(nil) select_tower_type(nil)

3
src/mob.lua

@ -221,7 +221,8 @@ local function update_mob_spooder(mob, mob_index)
if mob_can_pass_through(mob, mob.frame_target) then if mob_can_pass_through(mob, mob.frame_target) then
local from = hex_map_get(state.map, mob.hex) local from = hex_map_get(state.map, mob.hex)
local to = hex_map_get(state.map, mob.frame_target) local to = hex_map_get(state.map, mob.frame_target)
local rate = math.abs(from.elevation - to.elevation) + 0.01 * mob.speed * am.delta_time
local spider_speed = ((math.simplex(mob.hex) + 1.5) * 1.5) ^ 2
local rate = (spider_speed * mob.speed - math.abs(to.elevation - from.elevation)) * am.delta_time
mob.position = mob.position + math.normalize(hex_to_pixel(mob.frame_target, vec2(HEX_SIZE)) - mob.position) * rate mob.position = mob.position + math.normalize(hex_to_pixel(mob.frame_target, vec2(HEX_SIZE)) - mob.position) * rate
mob.node.position2d = mob.position mob.node.position2d = mob.position

3
src/tower.lua

@ -434,7 +434,7 @@ function update_tower_lighthouse(tower, tower_index)
local mobs = mobs_on_hex(h) local mobs = mobs_on_hex(h)
for _,m in pairs(mobs) do for _,m in pairs(mobs) do
if not m.path then
if not m.path and not m.seen_lighthouse then
-- @TODO only attract the mob if its frame target (direction vector) -- @TODO only attract the mob if its frame target (direction vector)
-- is within some angle range...? if the mob is heading directly away from the tower, then -- is within some angle range...? if the mob is heading directly away from the tower, then
-- the lighthouse shouldn't do much -- the lighthouse shouldn't do much
@ -443,6 +443,7 @@ function update_tower_lighthouse(tower, tower_index)
if made_it then if made_it then
m.path = path m.path = path
m.seen_lighthouse = true
--[[ --[[
local area = spiral_map(tower.hex, tower.range) local area = spiral_map(tower.hex, tower.range)

Loading…
Cancel
Save