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. 9
      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 saving by name
-- -- allow loading by name -- -- allow loading by name
-- -- investigate saving as lua instead, and having as a consequence a less janky map serialization -- -- investigate saving as lua instead, and having as a consequence a less janky map serialization
-- -- encode/decode save game data (low priority)
-- --
-- map editor -- map editor
-- -- paint terrain elevation levels -- -- paint terrain elevation levels
@ -262,7 +261,6 @@ function main_scene(do_backdrop, do_logo)
) )
end end
-- @TODO add a hyperlink to an 'about' page or something
group:append( group:append(
am.translate(win.right - 10, win.bottom + 10) am.translate(win.right - 10, win.bottom + 10)
^ am.text(string.format("v%s, by %s", version, author), COLORS.WHITE, "right", "bottom") ^ 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 selected = true
self"sprite".color = vec4(1) self"sprite".color = vec4(1)
if win:mouse_pressed("left") then if win:mouse_pressed("left") then
vplay_sfx(math.random(1000000000))
end end
else else
selected = false 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 state.spawning = true
-- calculate spawn chance for next wave -- 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) state.time_until_next_break = get_wave_time(state.current_wave)
end end
@ -441,6 +441,7 @@ local function make_game_toolbelt()
-- TOWER_TYPE, and none are missing. -- TOWER_TYPE, and none are missing.
local toolbelt_options = { local toolbelt_options = {
TOWER_TYPE.WALL, TOWER_TYPE.WALL,
TOWER_TYPE.GATTLER,
TOWER_TYPE.HOWITZER, TOWER_TYPE.HOWITZER,
TOWER_TYPE.REDEYE, TOWER_TYPE.REDEYE,
TOWER_TYPE.MOAT, TOWER_TYPE.MOAT,

9
src/grid.lua

@ -1,7 +1,7 @@
do do
-- add padding, because we terraform the very outer edge and it looks ugly, so hide it -- 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), -- the size of the grid should basically always be constant (i think),
-- but different aspect ratios complicate this in an annoying way -- but different aspect ratios complicate this in an annoying way
@ -12,7 +12,7 @@ do
HEX_GRID_DIMENSIONS = vec2(HEX_GRID_WIDTH, HEX_GRID_HEIGHT) HEX_GRID_DIMENSIONS = vec2(HEX_GRID_WIDTH, HEX_GRID_HEIGHT)
HEX_GRID_CENTER = evenq_to_hex(vec2(math.floor(HEX_GRID_WIDTH/2) HEX_GRID_CENTER = evenq_to_hex(vec2(math.floor(HEX_GRID_WIDTH/2)
, -math.floor(HEX_GRID_HEIGHT/2)))
, -math.floor(HEX_GRID_HEIGHT/2)))
-- pixel distance from hex centerpoint to any vertex -- pixel distance from hex centerpoint to any vertex
-- given a grid width gx, and window width wx, what's the smallest size a hex can be to fill the whole screen? -- given a grid width gx, and window width wx, what's the smallest size a hex can be to fill the whole screen?
@ -72,13 +72,12 @@ function grid_cost(map, from, to)
-- equivalent paths are found and mobs backpedal trying to decide between them -- equivalent paths are found and mobs backpedal trying to decide between them
-- (seed 2014 at time of writing has this at the bottom) -- (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_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 epsilon = elevation_epsilon
local cost = elevation_cost local cost = elevation_cost
return 1
return cost
end end
function grid_neighbours(map, hex) function grid_neighbours(map, hex)

4
src/projectile.lua

@ -172,9 +172,9 @@ local function update_projectile_laser(projectile, projectile_index)
end end
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) 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) vplay_sfx(SOUNDS.HIT1, 0.5)
end end

42
src/tower.lua

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

2
texture.lua

@ -38,6 +38,8 @@ TEXTURES = {
-- tower stuff -- tower stuff
TOWER_WALL = load_texture("res/tower_wall.png"), TOWER_WALL = load_texture("res/tower_wall.png"),
TOWER_WALL_ICON = load_texture("res/tower_wall_icon.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"), TOWER_HOWITZER = load_texture("res/tower_howitzer.png"),
CANNON1 = load_texture("res/cannon1.png"), CANNON1 = load_texture("res/cannon1.png"),
TOWER_HOWITZER_ICON = load_texture("res/tower_howitzer_icon.png"), TOWER_HOWITZER_ICON = load_texture("res/tower_howitzer_icon.png"),

Loading…
Cancel
Save