Browse Source

starting adding a gattler tower

master
Nicholas Hayashi 3 years ago
parent
commit
ee09e205e7
  1. 4
      main.lua
  2. BIN
      res/tower_gattler_icon.png
  3. 3
      src/game.lua
  4. 7
      src/grid.lua
  5. 4
      src/projectile.lua
  6. 42
      src/tower.lua
  7. 2
      texture.lua

4
main.lua

@ -9,7 +9,6 @@
-- -- allow saving by name
-- -- allow loading by name
-- -- investigate saving as lua instead, and having as a consequence a less janky map serialization
-- -- encode/decode save game data (low priority)
--
-- map editor
-- -- paint terrain elevation levels
@ -262,7 +261,6 @@ function main_scene(do_backdrop, do_logo)
)
end
-- @TODO add a hyperlink to an 'about' page or something
group:append(
am.translate(win.right - 10, win.bottom + 10)
^ am.text(string.format("v%s, by %s", version, author), COLORS.WHITE, "right", "bottom")
@ -281,7 +279,7 @@ function main_scene(do_backdrop, do_logo)
selected = true
self"sprite".color = vec4(1)
if win:mouse_pressed("left") then
vplay_sfx(math.random(1000000000))
end
else
selected = false

BIN
res/tower_gattler_icon.png

After

Width: 516  |  Height: 501  |  Size: 145 KiB

3
src/game.lua

@ -225,7 +225,7 @@ local function game_action(scene)
state.spawning = true
-- calculate spawn chance for next wave
state.spawn_chance = math.log(state.current_wave)/100 + 0.002
state.spawn_chance = math.log(state.current_wave)/90 + 0.002
state.time_until_next_break = get_wave_time(state.current_wave)
end
@ -441,6 +441,7 @@ local function make_game_toolbelt()
-- TOWER_TYPE, and none are missing.
local toolbelt_options = {
TOWER_TYPE.WALL,
TOWER_TYPE.GATTLER,
TOWER_TYPE.HOWITZER,
TOWER_TYPE.REDEYE,
TOWER_TYPE.MOAT,

7
src/grid.lua

@ -1,7 +1,7 @@
do
-- add padding, because we terraform the very outer edge and it looks ugly, so hide it
local padding = 2
local padding = 3
-- the size of the grid should basically always be constant (i think),
-- but different aspect ratios complicate this in an annoying way
@ -72,13 +72,12 @@ function grid_cost(map, from, to)
-- equivalent paths are found and mobs backpedal trying to decide between them
-- (seed 2014 at time of writing has this at the bottom)
local elevation_epsilon = HEX_GRID_MAXIMUM_ELEVATION - HEX_GRID_MINIMUM_ELEVATION + 0.2
local elevation_cost = math.abs(math.abs(t1.elevation)^0.5
- math.abs(t2.elevation)^0.5)
local elevation_cost = 2 + math.abs(t1.elevation)^0.5 - math.abs(t2.elevation)^0.5
local epsilon = elevation_epsilon
local cost = elevation_cost
return 1
return cost
end
function grid_neighbours(map, hex)

4
src/projectile.lua

@ -172,9 +172,9 @@ local function update_projectile_laser(projectile, projectile_index)
end
end
-- hit the mob, delete ourselves, affect the world
-- hit the mob, affect the world
do_hit_mob(closest_mob, projectile.damage, closest_mob_index)
delete_entity(state.projectiles, projectile_index)
-- delete_entity(state.projectiles, projectile_index) -- laser doesn't delete itself on mob hit
vplay_sfx(SOUNDS.HIT1, 0.5)
end

42
src/tower.lua

@ -1,22 +1,22 @@
TOWER_TYPE = {
WALL = 1,
HOWITZER = 2,
-- = 3,
REDEYE = 3,
GATTLER = 2,
HOWITZER = 3,
REDEYE = 4,
-- = 5,
MOAT = 4,
MOAT = 5,
-- = 7,
RADAR = 5,
RADAR = 6,
-- = 9,
LIGHTHOUSE = 6
LIGHTHOUSE = 7
}
local TOWER_SPECS = {
[TOWER_TYPE.WALL] = {
name = "Wall",
placement_rules_text = "Place on Ground",
short_description = "Restricts movement",
short_description = "Restricts movement, similar to a mountain.",
texture = TEXTURES.TOWER_WALL,
icon_texture = TEXTURES.TOWER_WALL_ICON,
cost = 10,
@ -25,13 +25,25 @@ local TOWER_SPECS = {
size = 0,
height = 1,
},
[TOWER_TYPE.GATTLER] = {
name = "Gattler",
placement_rules_text = "Place on Ground",
short_description = "Short-range, fast-fire rate single-target tower.",
texture = TEXTURES.TOWER_GATTLER,
icon_texture = TEXTURES.TOWER_GATTLER_ICON,
cost = 20,
range = 4,
fire_rate = 10,
size = 0,
height = 1,
},
[TOWER_TYPE.HOWITZER] = {
name = "Howitzer",
placement_rules_text = "Place on non-Water, non-Mountain",
short_description = "Fires area of effect artillery.",
texture = TEXTURES.TOWER_HOWITZER,
icon_texture = TEXTURES.TOWER_HOWITZER_ICON,
cost = 30,
cost = 50,
range = 6,
fire_rate = 4,
size = 0,
@ -40,10 +52,10 @@ local TOWER_SPECS = {
[TOWER_TYPE.REDEYE] = {
name = "Redeye",
placement_rules_text = "Place on Mountains",
short_description = "Long-range, single-target laser tower",
short_description = "Long-range, penetrating laser tower",
texture = TEXTURES.TOWER_REDEYE,
icon_texture = TEXTURES.TOWER_REDEYE_ICON,
cost = 20,
cost = 140,
range = 9,
fire_rate = 1,
size = 0,
@ -67,7 +79,7 @@ local TOWER_SPECS = {
short_description = "Doesn't do anything right now :(",
texture = TEXTURES.TOWER_RADAR,
icon_texture = TEXTURES.TOWER_RADAR_ICON,
cost = 20,
cost = 100,
range = 0,
fire_rate = 1,
size = 0,
@ -79,7 +91,7 @@ local TOWER_SPECS = {
short_description = "Attracts nearby mobs; temporarily redirects their path",
texture = TEXTURES.TOWER_LIGHTHOUSE,
icon_texture = TEXTURES.TOWER_LIGHTHOUSE_ICON,
cost = 70,
cost = 150,
range = 7,
fire_rate = 1,
size = 0,
@ -126,6 +138,9 @@ function make_tower_node(tower_type)
if tower_type == TOWER_TYPE.REDEYE then
return make_tower_sprite(tower_type)
elseif tower_type == TOWER_TYPE.GATTLER then
return make_tower_sprite(tower_type)
elseif tower_type == TOWER_TYPE.HOWITZER then
return am.group{
am.circle(vec2(0), HEX_SIZE, COLORS.VERY_DARK_GRAY, 6),
@ -492,6 +507,9 @@ function make_and_register_tower(hex, tower_type)
if tower.type == TOWER_TYPE.HOWITZER then
tower.props.z = tower.height
elseif tower.type == TOWER_TYPE.GATTLER then
tower.props.z = tower.height
elseif tower.type == TOWER_TYPE.LIGHTHOUSE then
tower.perimeter = hex_ring_map(tower.hex, tower.range)
end

2
texture.lua

@ -38,6 +38,8 @@ TEXTURES = {
-- tower stuff
TOWER_WALL = load_texture("res/tower_wall.png"),
TOWER_WALL_ICON = load_texture("res/tower_wall_icon.png"),
TOWER_GATTLER = load_texture("res/tower_gattler.png"),
TOWER_GATTLER_ICON = load_texture("res/tower_gattler_icon.png"),
TOWER_HOWITZER = load_texture("res/tower_howitzer.png"),
CANNON1 = load_texture("res/cannon1.png"),
TOWER_HOWITZER_ICON = load_texture("res/tower_howitzer_icon.png"),

Loading…
Cancel
Save