From 430edd02747e6b6b1d2bc2dc697f52011a011636 Mon Sep 17 00:00:00 2001 From: Nicholas Hayashi Date: Sat, 8 Jan 2022 22:49:55 -0500 Subject: [PATCH] remove radar --- src/entity.lua | 3 ++- src/game.lua | 4 ++-- src/tower.lua | 38 +++++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/entity.lua b/src/entity.lua index 5fd8efc..041d5a0 100644 --- a/src/entity.lua +++ b/src/entity.lua @@ -51,7 +51,8 @@ end function delete_entity(t, index) if not t then error("splat!") end - game_state.world:remove(t[index].node) + local entity = t[index] + game_state.world(world_layer_tag(entity.z)):remove(entity.node) t[index] = false -- leave empty indexes so other entities can learn that this entity was deleted end diff --git a/src/game.lua b/src/game.lua index 2677a69..797b6d3 100644 --- a/src/game.lua +++ b/src/game.lua @@ -66,8 +66,8 @@ local game_scene_menu_options = { } local function get_initial_game_state(seed) - local STARTING_MONEY = 75 - --local STARTING_MONEY = 10000 + --local STARTING_MONEY = 75 + local STARTING_MONEY = 10000 local map = random_map(seed) local world = make_hex_grid_scene(map, true) diff --git a/src/tower.lua b/src/tower.lua index 291a5a5..efb2157 100644 --- a/src/tower.lua +++ b/src/tower.lua @@ -280,21 +280,6 @@ function init_tower_specs() end, update_f = false }, - { - id = "RADAR", - name = "Radar", - placement_rules_text = "n/a", - short_description = "Doesn't do anything right now :(", - texture = TEXTURES.TOWER_RADAR, - icon_texture = TEXTURES.TOWER_RADAR_ICON, - cost = 100, - range = 0, - fire_rate = 1, - make_node_f = function(self) - return make_tower_sprite(self) - end, - update_f = false - }, { id = "LIGHTHOUSE", name = "Lighthouse", @@ -306,7 +291,11 @@ function init_tower_specs() range = 7, fire_rate = 1, height = 2, - make_node_f = function(self) + make_node_f = function(self, hex) + if hex then + self.perimeter = hex_spiral_map(hex, 6) + end + return am.group( make_tower_sprite(self), am.particles2d{ @@ -380,6 +369,9 @@ function init_tower_specs() cost = 50, size = 2, height = 0, + props = { + income = 1 + }, make_node_f = function(self) local quads = am.quads(2*7, {"vert", "vec2", "uv", "vec2", "color", "vec4"}) @@ -389,6 +381,16 @@ function init_tower_specs() end return am.blend("alpha") ^ am.use_program(make_hex_shader_program_node()) ^ am.bind{ texture = TEXTURES.TOWER_FARM } ^ quads + end, + update_f = function(tower, tower_index) + for _,h in pairs(tower.hexes) do + for _,m in pairs(mobs_on_hex(h)) do + if m then + tower.props.income = tower.props.income * 0.7 + end + end + end + game_state.money = game_state.money + tower.props.income * am.delta_time end } } @@ -576,7 +578,9 @@ function make_and_register_tower(hex, tower_type) local spec = get_tower_spec(tower_type) local tower = make_basic_entity( hex, - spec.update_f + spec.update_f, + false, + math.clamp(spec.height, 0, 10) ) table.merge(tower, spec)