diff --git a/arena.lua b/arena.lua index bfe6f36..328d71e 100644 --- a/arena.lua +++ b/arena.lua @@ -7,7 +7,7 @@ function Arena:init(name) end -function Arena:on_enter(from, level) +function Arena:on_enter(from, level, units) self.hfx:add('condition1', 1) self.hfx:add('condition2', 1) self.level = level or 1 @@ -227,13 +227,13 @@ function Arena:update(dt) if self.win_condition == 'enemy_kill' then if self.can_quit then self.t:after(2, function() - TransitionEffect{group = main.transition, x = self.player.x, y = self.player.y, dont_tween_out = true, color = self.color, transition_action = function() + TransitionEffect{group = main.transitions, x = self.player.x, y = self.player.y, color = self.color, transition_action = function() main:add(BuyScreen'buy_screen') main:go_to('buy_screen', self, self.level, self.color) end, text = Text({ - {text = '[wavy, bg]resources gained: +' .. tostring(self.resources_gained), font = pixul_font, alignment = 'center', height_multiplier = 1.5}, - {text = '[wavy, bg]interest: +' .. tostring(math.floor(resource/10)), font = pixul_font, alignment = 'center', height_multiplier = 1.5}, - {text = '[wavy, bg]total: +' .. tostring(self.resources_gained + math.floor(resource/10)), font = pixul_font, alignment = 'center'} + {text = '[bg]resources gained: ' .. tostring(self.resources_gained), font = pixul_font, alignment = 'center', height_multiplier = 1.5}, + {text = '[bg]interest: ' .. tostring(math.floor(resource/10)), font = pixul_font, alignment = 'center', height_multiplier = 1.5}, + {text = '[bg]total: ' .. tostring(self.resources_gained + math.floor(resource/10)), font = pixul_font, alignment = 'center'} }, global_text_tags)} end) end @@ -245,13 +245,13 @@ function Arena:update(dt) if #self.main:get_objects_by_classes(self.enemies) > 0 then self.can_quit = true else - TransitionEffect{group = main.transition, x = self.player.x, y = self.player.y, dont_tween_out = true, color = self.color, transition_action = function() + TransitionEffect{group = main.transitions, x = self.player.x, y = self.player.y, color = self.color, transition_action = function() main:add(BuyScreen'buy_screen') main:go_to('buy_screen', self, self.level, self.color) end, text = Text({ - {text = '[wavy, bg]resources gained: +' .. tostring(self.resources_gained), font = pixul_font, alignment = 'center', height_multiplier = 1.5}, - {text = '[wavy, bg]interest: +' .. tostring(math.floor(resource/10)), font = pixul_font, alignment = 'center', height_multiplier = 1.5}, - {text = '[wavy, bg]total: +' .. tostring(self.resources_gained + math.floor(resource/10)), font = pixul_font, alignment = 'center'} + {text = '[bg]resources gained: ' .. tostring(self.resources_gained), font = pixul_font, alignment = 'center', height_multiplier = 1.5}, + {text = '[bg]interest: ' .. tostring(math.floor(resource/10)), font = pixul_font, alignment = 'center', height_multiplier = 1.5}, + {text = '[bg]total: ' .. tostring(self.resources_gained + math.floor(resource/10)), font = pixul_font, alignment = 'center'} }, global_text_tags)} end end) diff --git a/assets/sounds/Wind Bolt 8.ogg b/assets/sounds/Wind Bolt 8.ogg new file mode 100644 index 0000000..140e50d Binary files /dev/null and b/assets/sounds/Wind Bolt 8.ogg differ diff --git a/buy_screen.lua b/buy_screen.lua index 97c0a10..f23ec86 100644 --- a/buy_screen.lua +++ b/buy_screen.lua @@ -11,11 +11,10 @@ function BuyScreen:on_enter(from, level) self.level = level self.main = Group() - self.effects = Group() - self.ui = Group() - self.info_text = InfoText{group = self.ui} if self.level == 0 then + pop1:play{pitch = random:float(0.95, 1.05), volume = 0.5} + self.first_screen = true self.cards = {} self.selected_card_index = 1 local units = {'vagrant', 'swordsman', 'wizard', 'archer', 'scout', 'cleric'} @@ -24,6 +23,8 @@ function BuyScreen:on_enter(from, level) self.cards[2] = PairCard{group = self.main, x = gw/2, y = 155, w = gw, h = gh/4, unit_1 = random:table_remove(units), unit_2 = random:table_remove(units), i = 2, parent = self} local units = {'vagrant', 'swordsman', 'wizard', 'archer', 'scout', 'cleric'} self.cards[3] = PairCard{group = self.main, x = gw/2, y = 225, w = gw, h = gh/4, unit_1 = random:table_remove(units), unit_2 = random:table_remove(units), i = 3, parent = self} + + self.title_sy = 1 self.title = Text({{text = '[fg]choose your initial party', font = pixul_font, alignment = 'center'}}, global_text_tags) end end @@ -32,22 +33,48 @@ end function BuyScreen:update(dt) self:update_game_object(dt*slow_amount) self.main:update(dt*slow_amount) - self.effects:update(dt*slow_amount) - self.ui:update(dt*slow_amount) - if self.level == 0 then - self.title:update(dt) + if self.level == 0 and self.first_screen then + if self.title then self.title:update(dt) end + if input.move_up.pressed then self.selected_card_index = self.selected_card_index - 1 if self.selected_card_index == 0 then self.selected_card_index = 3 end for i = 1, 3 do self.cards[i]:unselect() end self.cards[self.selected_card_index]:select() + pop1:play{pitch = random:float(0.95, 1.05), volume = 0.5} end if input.move_down.pressed then self.selected_card_index = self.selected_card_index + 1 if self.selected_card_index == 4 then self.selected_card_index = 1 end for i = 1, 3 do self.cards[i]:unselect() end self.cards[self.selected_card_index]:select() + pop1:play{pitch = random:float(0.95, 1.05), volume = 0.5} + end + + if input.enter.pressed and not self.transitioning then + ui_switch:play{pitch = random:float(0.95, 1.05), volume = 0.5} + ui_transition:play{pitch = random:float(0.95, 1.05), volume = 0.5} + self.transitioning = true + self.t:tween(0.1, self, {title_sy = 0}, math.linear, function() self.title_sy = 0; self.title = nil end) + + local unit_1, unit_2 = self.cards[self.selected_card_index].unit_1, self.cards[self.selected_card_index].unit_2 + TransitionEffect{group = main.transitions, x = 50, y = 85 + (self.selected_card_index-1)*70, color = character_colors[unit_1], transition_action = function() + main:add(Arena'arena') + main:go_to('arena', 1, {{character = unit_1, level = 1}, {character = unit_2, level = 1}}) + end} + --[[ + , text = Text({ + {text = '[' .. character_color_strings[unit_1] .. ']' .. unit_1:upper() .. ' [yellow]Lv.1 [fg]- ' .. table.reduce(character_classes[unit_1], + function(memo, v) return memo .. '[' .. class_color_strings[v] .. ']' .. v .. '[fg], ' end, ''):sub(1, -3), font = pixul_font, height_multiplier = 1.7, alignment = 'center'}, + {text = character_stats[unit_1](1), font = pixul_font, height_multiplier = 1.3, alignment = 'center'}, + {text = character_descriptions[unit_1](get_character_stat(unit_1, 1, 'dmg')), font = pixul_font, alignment = 'center', height_multiplier = 3}, + {text = '[' .. character_color_strings[unit_2] .. ']' .. unit_2:upper() .. ' [yellow]Lv.1 [fg]- ' .. table.reduce(character_classes[unit_2], + function(memo, v) return memo .. '[' .. class_color_strings[v] .. ']' .. v .. '[fg], ' end, ''):sub(1, -3), font = pixul_font, height_multiplier = 1.7, alignment = 'center'}, + {text = character_stats[unit_2](1), font = pixul_font, height_multiplier = 1.3, alignment = 'center'}, + {text = character_descriptions[unit_2](get_character_stat(unit_2, 1, 'dmg')), font = pixul_font, alignment = 'center', height_multiplier = 1.5}, + }, global_text_tags)} + ]]-- end end end @@ -55,11 +82,12 @@ end function BuyScreen:draw() self.main:draw() - self.effects:draw() - self.ui:draw() if self.level == 0 then - self.title:draw(3.25*gw/4, 25) + if self.title then self.title:draw(3.25*gw/4, 25, 0, 1, self.title_sy) end + if self.unit_info_text then + self.unit_info_text:draw(gw/2, gh/2) + end end end @@ -91,15 +119,6 @@ function PairCard:select() end, 'pulse_2') end end, nil, nil, 'pulse') - - - self.parent.info_text:activate({ - {text = '[' .. character_color_strings[self.unit_1] .. ']' .. self.unit_1:upper() .. '[] - ' .. table.reduce(character_classes[self.unit_1], - function(memo, v) return memo .. '[' .. class_color_strings[v] .. ']' .. v .. '[fg], ' end, ''):sub(1, -3), font = pixul_font, height_multiplier = 1.1}, - {text = character_descriptions[self.unit_1](10), font = pixul_font}, - }, nil, nil, nil, nil, 20, 10, nil, 3) - self.parent.info_text.x = gw/2 - self.parent.info_text.y = gh/2 end diff --git a/main.lua b/main.lua index a246a10..38ec6eb 100644 --- a/main.lua +++ b/main.lua @@ -14,8 +14,11 @@ function init() input:bind('move_right', {'d', 'right'}) input:bind('move_up', {'w', 'up'}) input:bind('move_down', {'s', 'down'}) + input:bind('enter', {'space', 'return'}) local s = {tags = {sfx}} + ui_switch = Sound('Switch.ogg', s) + ui_transition = Sound('Wind Bolt 8.ogg', s) shoot1 = Sound('Shooting Projectile (Classic) 11.ogg', s) archer1 = Sound('Releasing Bow String 1.ogg', s) wizard1 = Sound('Wind Bolt 20.ogg', s) @@ -191,8 +194,43 @@ function init() ['engineer'] = function(dmg) return '[fg]drops sentries that shoot bursts of projectiles, each dealing [yellow]' .. dmg .. '[fg] damage' end, } - character_stats = { + get_character_stat_string = function(character, level) + local group = Group():set_as_physics_world(32, 0, 0, {'player', 'enemy', 'projectile', 'enemy_projectile'}) + local mock = Player{group = group, leader = true, character = character, level = level} + mock:update(1/60) + return '[red]HP: [red]' .. mock.max_hp .. '[fg], [red]DMG: [red]' .. mock.dmg .. '[fg], [green]ASPD: [green]' .. math.round(mock.aspd_m, 2) .. 'x[fg], [blue]AREA: [blue]' .. + math.round(mock.area_dmg_m*mock.area_size_m, 2) .. 'x[fg], [yellow]DEF: [yellow]' .. math.round(mock.def, 2) .. '[fg], [green]MVSPD: [green]' .. math.round(mock.v, 2) .. '[fg]' + end + get_character_stat = function(character, level, stat) + print(character) + local group = Group():set_as_physics_world(32, 0, 0, {'player', 'enemy', 'projectile', 'enemy_projectile'}) + local mock = Player{group = group, leader = true, character = character, level = level} + mock:update(1/60) + return math.round(mock[stat], 2) + end + + character_stats = { + ['vagrant'] = function(lvl) return get_character_stat_string('vagrant', lvl) end, + ['swordsman'] = function(lvl) return get_character_stat_string('swordsman', lvl) end, + ['wizard'] = function(lvl) return get_character_stat_string('wizard', lvl) end, + ['archer'] = function(lvl) return get_character_stat_string('archer', lvl) end, + ['scout'] = function(lvl) return get_character_stat_string('scout', lvl) end, + ['cleric'] = function(lvl) return get_character_stat_string('cleric', lvl) end, + ['outlaw'] = function(lvl) return get_character_stat_string('outlaw', lvl) end, + ['blade'] = function(lvl) return get_character_stat_string('blade', lvl) end, + ['elementor'] = function(lvl) return get_character_stat_string('elementor', lvl) end, + ['saboteur'] = function(lvl) return get_character_stat_string('saboteur', lvl) end, + ['stormweaver'] = function(lvl) return get_character_stat_string('stormweaver', lvl) end, + ['sage'] = function(lvl) return get_character_stat_string('sage', lvl) end, + ['squire'] = function(lvl) return get_character_stat_string('squire', lvl) end, + ['cannoneer'] = function(lvl) return get_character_stat_string('cannoneer', lvl) end, + ['dual_gunner'] = function(lvl) return get_character_stat_string('dual_gunner', lvl) end, + ['hunter'] = function(lvl) return get_character_stat_string('hunter', lvl) end, + ['chronomancer'] = function(lvl) return get_character_stat_string('chronomancer', lvl) end, + ['spellblade'] = function(lvl) return get_character_stat_string('spellblade', lvl) end, + ['psykeeper'] = function(lvl) return get_character_stat_string('psykeeper', lvl) end, + ['engineer'] = function(lvl) return get_character_stat_string('engineer', lvl) end, } units = {} diff --git a/shared.lua b/shared.lua index 3c118ac..6d79813 100644 --- a/shared.lua +++ b/shared.lua @@ -381,22 +381,21 @@ TransitionEffect = Object:extend() TransitionEffect:implement(GameObject) function TransitionEffect:init(args) self:init_game_object(args) - if not self.text then error('TransitionEffect must have a Text object defined to the .text attribute') end self.rs = 0 self.text_sx, self.text_sy = 0, 0 self.t:after(0.25, function() self.t:after(0.1, function() self.t:tween(0.1, self, {text_sx = 1, text_sy = 1}, math.cubic_in_out) end) - self.t:tween(0.75, self, {rs = gw}, math.linear, function() - if self.transition_action then self.transition_action(unpack(self.transition_action_args)) end - self.t:after(0.5, function() + self.t:tween(0.6, self, {rs = 1.2*gw}, math.linear, function() + if self.transition_action then self.transition_action(unpack(self.transition_action_args or {})) end + self.t:after(0.3, function() self.x, self.y = gw/2, gh/2 - self.t:after(0.7, function() self.t:tween(0.05, self, {text_sx = 0, text_sy = 0}, math.cubic_in_out) end) + self.t:after(0.6, function() self.t:tween(0.05, self, {text_sx = 0, text_sy = 0}, math.cubic_in_out) end) if not args.dont_tween_out then - self.t:tween(0.75, self, {rs = 0}, math.linear, function() self.text = nil; self.dead = true end) + self.t:tween(0.6, self, {rs = 0}, math.linear, function() self.text = nil; self.dead = true end) else - self.t:after(0.75, function() self.text = nil; self.dead = true end) + self.t:after(0.6, function() self.text = nil; self.dead = true end) end end) end) @@ -430,6 +429,7 @@ global_text_tags = { bg = TextTag{draw = function(c, i, text) graphics.set_color(bg[0]) end}, fg = TextTag{draw = function(c, i, text) graphics.set_color(fg[0]) end}, wavy = TextTag{update = function(c, dt, i, text) c.oy = 2*math.sin(4*time + i) end}, + wavy_lower = TextTag{update = function(c, dt, i, text) c.oy = math.sin(4*time + i) end}, } InfoText = Object:extend() @@ -451,7 +451,7 @@ end function InfoText:draw() graphics.push(self.x + self.ox, self.y + self.oy, 0, self.sx*self.spring.x, self.sy*self.spring.x) - graphics.rectangle(self.x + self.ox, self.y + self.oy, self.text.w + self.ow, self.text.h + self.oh, self.text.h/4, self.text.h/4, bg[-2]) + graphics.rectangle(self.x + self.ox, self.y + self.oy, self.text.w + self.ow, self.text.h + self.oh, self.text.h/12, self.text.h/12, bg[-2]) self.text:draw(self.x + self.ox + self.tox, self.y + self.oy + self.toy) graphics.pop() end