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"
author = "nick hayashi"
shortname = "hexyz"
version = "0.1.1"
version = "0.1.2"
support_email = ""
copyright_message = "Copyright © 2021 Nick Hayashi"

20
src/game.lua

@ -108,6 +108,12 @@ end
local function game_deserialize(json_string)
-- @TODO decode from some compressed format or whatever
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.seed = nil
@ -221,7 +227,8 @@ local function game_action(scene)
state.spawning = true
-- 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)
end
@ -580,7 +587,7 @@ local function game_scene()
state.current_wave = state.current_wave + 1
-- 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)
@ -624,7 +631,8 @@ local function game_scene()
)
:tag"game"
scene:action(game_action)
-- dangling actions run before the main action
scene:late_action(game_action)
return scene
end
@ -647,6 +655,12 @@ function game_init(saved_state)
if saved_state then
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,
-- but you don't have a built tower cursor node, so hovering a buildable tile throws an error
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
local from = hex_map_get(state.map, mob.hex)
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.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)
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)
-- is within some angle range...? if the mob is heading directly away from the tower, then
-- the lighthouse shouldn't do much
@ -443,6 +443,7 @@ function update_tower_lighthouse(tower, tower_index)
if made_it then
m.path = path
m.seen_lighthouse = true
--[[
local area = spiral_map(tower.hex, tower.range)

Loading…
Cancel
Save