Browse Source

tracks, balancing

master
Nicholas Hayashi 3 years ago
parent
commit
18e654b3e9
  1. 55
      main.lua
  2. 15
      sound.lua
  3. 2
      src/mob.lua
  4. 2
      src/projectile.lua

55
main.lua

@ -92,6 +92,44 @@ require "src/mob"
require "src/projectile" require "src/projectile"
require "src/tower" require "src/tower"
local sound_toggle_node_tag = "sound-on-off-icon"
local function make_sound_toggle_node(on)
local sprite
if on then
sprite = pack_texture_into_sprite(TEXTURES.SOUND_ON1, 40, 30)
else
sprite = pack_texture_into_sprite(TEXTURES.SOUND_OFF, 40, 30)
end
return (am.translate(win.right - 30, win.top - 60) ^ sprite)
:tag(sound_toggle_node_tag)
:action(function()
end)
end
local cached_music_volume = 0.2
local cached_sfx_volume = 0.1
local function toggle_mute()
settings.sound_on = not settings.sound_on
if settings.sound_on then
settings.music_volume = cached_music_volume
settings.sfx_volume = cached_sfx_volume
else
cached_music_volume = settings.music_volume
cached_sfx_volume = settings.sfx_volume
settings.music_volume = 0
settings.sfx_volume = 0
end
update_music_volume(settings.music_volume)
win.scene:replace(sound_toggle_node_tag, make_sound_toggle_node(settings.sound_on))
end
-- text popup in the middle of the screen that dissapates, call from anywhere -- text popup in the middle of the screen that dissapates, call from anywhere
function alert(message, color) function alert(message, color)
win.scene:append( win.scene:append(
@ -117,6 +155,8 @@ function main_action(self)
end end
elseif win:key_pressed("f4") then elseif win:key_pressed("f4") then
win:close() win:close()
elseif win:key_pressed("m") then
toggle_mute()
end end
if self"hex_backdrop" then if self"hex_backdrop" then
self"hex_backdrop""rotate".angle = math.wrapf(self"hex_backdrop""rotate".angle - 0.005 * am.delta_time, math.pi*2) self"hex_backdrop""rotate".angle = math.wrapf(self"hex_backdrop""rotate".angle - 0.005 * am.delta_time, math.pi*2)
@ -236,21 +276,6 @@ function make_main_scene_toolbelt()
return am.translate(pixel_offset) ^ group return am.translate(pixel_offset) ^ group
end end
function make_sound_toggle_node(on)
local sprite
if on then
sprite = pack_texture_into_sprite(TEXTURES.SOUND_ON1, 40, 30)
else
sprite = pack_texture_into_sprite(TEXTURES.SOUND_OFF, 40, 30)
end
return (am.translate(win.right - 30, win.top - 60) ^ sprite)
end
function toggle_mute()
settings.sound_on = not settings.sound_on
win.scene:replace("sound-on-off-icon", make_sound_toggle_node(settings.sound_on))
end
function main_scene(do_backdrop, do_logo) function main_scene(do_backdrop, do_logo)
local group = am.group() local group = am.group()

15
sound.lua

@ -24,6 +24,16 @@ SOUNDS = {
MAIN_THEME = am.track(am.load_audio("res/maintheme.ogg"), true, 1, settings.music_volume) MAIN_THEME = am.track(am.load_audio("res/maintheme.ogg"), true, 1, settings.music_volume)
} }
-- doesn't get unset when a track is 'done' playing automatically
CURRENT_TRACK = nil
function update_sfx_volume() end
function update_music_volume(volume)
if CURRENT_TRACK then
CURRENT_TRACK.volume = math.clamp(volume, 0, 1)
end
end
-- play sound effect with variable pitch -- play sound effect with variable pitch
function vplay_sfx(sound, pitch_range) function vplay_sfx(sound, pitch_range)
local pitch = (math.random() + 0.5)/(pitch_range and 1/pitch_range or 2) local pitch = (math.random() + 0.5)/(pitch_range and 1/pitch_range or 2)
@ -34,7 +44,8 @@ function play_sfx(sound)
win.scene:action(am.play(sound, false, 1, settings.sfx_volume)) win.scene:action(am.play(sound, false, 1, settings.sfx_volume))
end end
function play_track(track)
win.scene:action(am.play(track))
function play_track(track, loop)
CURRENT_TRACK = track
win.scene:action(am.play(track, loop or true))
end end

2
src/mob.lua

@ -36,7 +36,7 @@ local function grow_mob_speed(mob_type, spec_speed, time)
return spec_speed + math.log(state.current_wave + 1) return spec_speed + math.log(state.current_wave + 1)
end end
local function grow_mob_bounty(mob_type, spec_bounty, time) local function grow_mob_bounty(mob_type, spec_bounty, time)
return spec_bounty + math.pow(state.current_wave - 1, 2)
return spec_bounty + (state.current_wave - 1) * 2
end end
function mobs_on_hex(hex) function mobs_on_hex(hex)

2
src/projectile.lua

@ -18,7 +18,7 @@ local PROJECTILE_SPECS = {
}, },
[PROJECTILE_TYPE.BULLET] = { [PROJECTILE_TYPE.BULLET] = {
velocity = 25, velocity = 25,
damage = 5,
damage = 4,
hitbox_radius = 10 hitbox_radius = 10
} }
} }

Loading…
Cancel
Save