diff --git a/src/game.lua b/src/game.lua index 2c3025d..af1f722 100644 --- a/src/game.lua +++ b/src/game.lua @@ -16,7 +16,7 @@ local TRDTS = { } local function get_initial_game_state(seed) - local STARTING_MONEY = 50 + local STARTING_MONEY = 75 local map = random_map(seed) local world = make_hex_grid_scene(map) @@ -90,13 +90,15 @@ local function get_wave_time(current_wave) return 45 end +local BASE_BREAK_TIME = 20 local function get_break_time(current_wave) - return 20 + return BASE_BREAK_TIME - math.min(BASE_BREAK_TIME, BASE_BREAK_TIME / (1 / math.log(state.current_wave + 1))) end local function do_day_night_cycle() - local tstep = (math.sin(state.time * am.delta_time) + 1) / 100 - state.world"negative_mask".color = vec4(tstep){a=1} + -- + --local tstep = (math.sin(state.time * am.delta_time) + 1) / 100 + --state.world"negative_mask".color = vec4(tstep){a=1} end local function game_pause() @@ -226,7 +228,7 @@ local function game_action(scene) state.spawning = true -- calculate spawn chance for next wave - state.spawn_chance = math.log(state.current_wave)/90 + 0.002 + state.spawn_chance = math.log(state.current_wave)/80 + 0.002 state.time_until_next_break = get_wave_time(state.current_wave) end diff --git a/src/mob.lua b/src/mob.lua index b60b4b6..b9551d9 100644 --- a/src/mob.lua +++ b/src/mob.lua @@ -1,7 +1,8 @@ MOB_TYPE = { BEEPER = 1, - SPOODER = 2 + SPOODER = 2, + VELKOOZ = 3, } MAX_MOB_SIZE = hex_height(HEX_SIZE, HEX_ORIENTATION.FLAT) / 2 @@ -10,16 +11,22 @@ MOB_SIZE = MAX_MOB_SIZE local MOB_SPECS = { [MOB_TYPE.BEEPER] = { health = 30, - speed = 8, + speed = 6, bounty = 5, hurtbox_radius = MOB_SIZE/2 }, [MOB_TYPE.SPOODER] = { - health = 20, + health = 15, speed = 10, bounty = 5, hurtbox_radius = MOB_SIZE/2 - } + }, + [MOB_TYPE.VELKOOZ] = { + health = 10, + speed = 20, + bounty = 40, + hurtbox_radius = MOB_SIZE/2 - 2 + }, } function get_mob_health(mob_type) @@ -112,6 +119,13 @@ function make_mob_node(mob_type, mob) am.translate(0, -10) ^ healthbar } + elseif mob_type == MOB_TYPE.VELKOOZ then + return am.group{ + am.rotate(0) + ^ pack_texture_into_sprite(TEXTURES.MOB_VELKOOZ, MOB_SIZE*2, MOB_SIZE*2):tag"velk_sprite", + am.translate(0, -10) + ^ healthbar + } end end @@ -205,6 +219,45 @@ local function resolve_frame_target_for_mob(mob, mob_index) end end +local function update_mob_velkooz(mob, mob_index) + resolve_frame_target_for_mob(mob, mob_index) + + if mob.frame_target then + 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 = mob.speed * 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 + + else + mob.frame_target = false + end + else + --log('no targetssdsdsdsdsd') + end + + local theta = math.rad(90) - math.atan((HEX_GRID_CENTER.y - mob.position.y)/(HEX_GRID_CENTER.x - mob.position.x)) + local diff = mob.node("rotate").angle - theta + + mob.node("rotate").angle = -theta + math.pi/2 + + local roll = math.floor((state.time - mob.TOB) * 10) % 4 + if roll == 0 then + mob.node"velk_sprite".source = "res/mob_velkooz0.png" + + elseif roll == 1 then + mob.node"velk_sprite".source = "res/mob_velkooz1.png" + + elseif roll == 2 then + mob.node"velk_sprite".source = "res/mob_velkooz2.png" + + elseif roll == 3 then + mob.node"velk_sprite".source = "res/mob_velkooz3.png" + end +end + local function update_mob_spooder(mob, mob_index) resolve_frame_target_for_mob(mob, mob_index) @@ -270,6 +323,9 @@ local function get_mob_update_function(mob_type) elseif mob_type == MOB_TYPE.SPOODER then return update_mob_spooder + + elseif mob_type == MOB_TYPE.VELKOOZ then + return update_mob_velkooz end end @@ -289,6 +345,15 @@ local function make_and_register_mob(mob_type) mob.hurtbox_radius = spec.hurtbox_radius mob.healthbar = mob.node:child(1):child(2):child(1) -- lmao + if mob.type == MOB_TYPE.VELKOOZ then + mob.states = { + pack_texture_into_sprite(TEXTURES.VELKOOZ, MOB_SIZE, MOB_SIZE):tag"velk_sprite", + pack_texture_into_sprite(TEXTURES.VELKOOZ1, MOB_SIZE, MOB_SIZE):tag"velk_sprite", + pack_texture_into_sprite(TEXTURES.VELKOOZ2, MOB_SIZE, MOB_SIZE):tag"velk_sprite", + pack_texture_into_sprite(TEXTURES.VELKOOZ3, MOB_SIZE, MOB_SIZE):tag"velk_sprite", + } + end + register_entity(state.mobs, mob) return mob end @@ -325,10 +390,11 @@ end function do_mob_spawning() if can_spawn_mob() then + make_and_register_mob(MOB_TYPE.VELKOOZ) if state.current_wave % 2 == 0 then - make_and_register_mob(MOB_TYPE.SPOODER) + --make_and_register_mob(MOB_TYPE.SPOODER) else - make_and_register_mob(MOB_TYPE.BEEPER) + --make_and_register_mob(MOB_TYPE.BEEPER) end end end diff --git a/src/projectile.lua b/src/projectile.lua index 8868a5a..88afec4 100644 --- a/src/projectile.lua +++ b/src/projectile.lua @@ -13,7 +13,7 @@ local PROJECTILE_SPECS = { }, [PROJECTILE_TYPE.LASER] = { velocity = 35, - damage = 20, + damage = 14, hitbox_radius = 20 }, [PROJECTILE_TYPE.BULLET] = { diff --git a/src/tower.lua b/src/tower.lua index 9fb4fb1..369e2d7 100644 --- a/src/tower.lua +++ b/src/tower.lua @@ -39,7 +39,7 @@ local TOWER_SPECS = { }, [TOWER_TYPE.HOWITZER] = { name = "Howitzer", - placement_rules_text = "Place on non-Water, non-Mountain", + placement_rules_text = "Place on Ground, with a 1 space gap between other towers and mountains - walls/moats don't count.", short_description = "Medium-range, medium fire-rate area of effect artillery tower.", texture = TEXTURES.TOWER_HOWITZER, icon_texture = TEXTURES.TOWER_HOWITZER_ICON, @@ -51,11 +51,11 @@ local TOWER_SPECS = { }, [TOWER_TYPE.REDEYE] = { name = "Redeye", - placement_rules_text = "Place on Mountains", + placement_rules_text = "Place on Mountains.", short_description = "Long-range, penetrating high-velocity laser tower.", texture = TEXTURES.TOWER_REDEYE, icon_texture = TEXTURES.TOWER_REDEYE_ICON, - cost = 140, + cost = 75, range = 9, fire_rate = 3, size = 0, @@ -451,6 +451,9 @@ function tower_type_is_buildable_on(hex, tile, tower_type) -- this function gets polled a lot, and sometimes with nil/false tower types if not tower_type then return false end + -- you can't build anything in the center + if hex == HEX_GRID_CENTER then return false end + local blocking_towers = {} local blocking_mobs = {} local has_water = false @@ -481,17 +484,50 @@ function tower_type_is_buildable_on(hex, tile, tower_type) local mobs_blocking = table.count(blocking_mobs) ~= 0 local blocked = mobs_blocking or towers_blocking - -- @TODO i think the howitzer and gattler should not be placeable next to other towers other than the wall and moat, and perhaps not next to mountains either if tower_type == TOWER_TYPE.GATTLER then + local has_mountain_neighbour = false + local has_non_wall_non_moat_tower_neighbour = false + for _,h in pairs(hex_neighbours(hex)) do + local tile = hex_map_get(state.map, h) + + if tile and tile.elevation >= 0.5 then + has_mountain_neighbour = true + break + end + end return not (blocked or has_water or has_mountain) elseif tower_type == TOWER_TYPE.HOWITZER then - return not (blocked or has_water or has_mountain) + local has_mountain_neighbour = false + local has_non_wall_non_moat_tower_neighbour = false + for _,h in pairs(hex_neighbours(hex)) do + local towers = towers_on_hex(h) + local wall_on_hex = false + has_non_wall_non_moat_tower_neighbour = table.find(towers, function(tower) + if tower.type == TOWER_TYPE.WALL then + wall_on_hex = true + return false + + elseif tower.type == TOWER_TYPE.MOAT then + return false + end + + return true + end) + if has_non_wall_non_moat_tower_neighbour then + break + end + + local tile = hex_map_get(state.map, h) + if not wall_on_hex and tile and tile.elevation >= 0.5 then + has_mountain_neighbour = true + break + end + end + return not (blocked or has_water or has_mountain or has_mountain_neighbour or has_non_wall_non_moat_tower_neighbour) elseif tower_type == TOWER_TYPE.REDEYE then return not blocked - and not has_water - and not has_ground and has_mountain elseif tower_type == TOWER_TYPE.LIGHTHOUSE then diff --git a/texture.lua b/texture.lua index ac934b0..0d64996 100644 --- a/texture.lua +++ b/texture.lua @@ -58,6 +58,10 @@ TEXTURES = { -- mob stuff MOB_BEEPER = load_texture("res/mob_beeper.png"), MOB_SPOODER = load_texture("res/mob_spooder.png"), + MOB_VELKOOZ = load_texture("res/mob_velkooz.png"), + MOB_VELKOOZ1 = load_texture("res/mob_velkooz1.png"), + MOB_VELKOOZ2 = load_texture("res/mob_velkooz2.png"), + MOB_VELKOOZ3 = load_texture("res/mob_velkooz3.png"), } function pack_texture_into_sprite(texture, width, height, color)