diff --git a/assets/audio/sfx/explode.ogg b/assets/audio/sfx/explode.ogg new file mode 100644 index 0000000..80b4caa Binary files /dev/null and b/assets/audio/sfx/explode.ogg differ diff --git a/assets/sprites/header/moneyflash.png b/assets/sprites/header/moneyflash.png new file mode 100644 index 0000000..f6e262a Binary files /dev/null and b/assets/sprites/header/moneyflash.png differ diff --git a/assets/sprites/header/optionsbutton_down.png b/assets/sprites/header/optionsbutton_down.png new file mode 100644 index 0000000..533ac1e Binary files /dev/null and b/assets/sprites/header/optionsbutton_down.png differ diff --git a/assets/sprites/header/optionsbutton_hover.png b/assets/sprites/header/optionsbutton_hover.png new file mode 100644 index 0000000..d0090e4 Binary files /dev/null and b/assets/sprites/header/optionsbutton_hover.png differ diff --git a/constructors.lua b/constructors.lua index 500b5cf..b6e5ca9 100644 --- a/constructors.lua +++ b/constructors.lua @@ -11,6 +11,7 @@ function self.fish(x, y, type) eattimer = 0 + math.random() * 2, -- starts out hungry, with a 2s delay moneytimer = 10 + math.random() * 5, -- min 10s before it can make money dead = false, + star = false, lifetime = 0, @@ -54,7 +55,7 @@ function self.food(x, y, type) speed = 0.2, time = math.random(), deathtimer = 0, - type = type + type = type -- 1 = tier 1, 2 = tier 2, 3 = tier 3, 4 = star potion } return food diff --git a/scenes/gameplay/draw/fish.lua b/scenes/gameplay/draw/fish.lua index 7e2ef5e..fe6724c 100644 --- a/scenes/gameplay/draw/fish.lua +++ b/scenes/gameplay/draw/fish.lua @@ -65,11 +65,24 @@ return function(feesh, spritescale, fishsprite) local sadsheet = fishsprite(size, true, anim) local alpha = n.render.hungry == 1 and 0 or 1 - love.graphics.setColor(1, 1, 1, alpha - n.render.deathanim) + local allalpha = 1 + if n.star then allalpha = 0.8 end + love.graphics.setColor(1, 1, 1, (alpha - n.render.deathanim) * allalpha) love.graphics.draw(sheet.spriteSheet, sheet.quads[math.max(math.min(frame, #sample.quads), 1)], x, y, angle, sizex * spritescale, spritescale, sample.width/2, sample.height/2) - love.graphics.setColor(1, 1, 1, n.render.hungry - n.render.deathanim) + love.graphics.setColor(1, 1, 1, (n.render.hungry - n.render.deathanim) * allalpha) love.graphics.draw(sadsheet.spriteSheet, sheet.quads[math.max(math.min(frame, #sample.quads), 1)], x, y, angle, sizex * spritescale, spritescale, sample.width/2, sample.height/2) + if n.star then + local mult = (math.sin(love.timer.getTime() / 4) / 2 + 0.5) * 0.1 + 0.9 + + love.graphics.setBlendMode('add') + love.graphics.setColor(1, 1, 1, (alpha - n.render.deathanim) * mult) + love.graphics.draw(sheet.spriteSheet, sheet.quads[math.max(math.min(frame, #sample.quads), 1)], x, y, angle, sizex * spritescale, spritescale, sample.width/2, sample.height/2) + love.graphics.setColor(1, 1, 1, (n.render.hungry - n.render.deathanim) * mult) + love.graphics.draw(sadsheet.spriteSheet, sheet.quads[math.max(math.min(frame, #sample.quads), 1)], x, y, angle, sizex * spritescale, spritescale, sample.width/2, sample.height/2) + love.graphics.setBlendMode('alpha') + end + love.graphics.setColor(1, 1, 1) if debug then love.graphics.print(shrt(n.eattimer), x + 20, y + 20) end diff --git a/scenes/gameplay/draw/food.lua b/scenes/gameplay/draw/food.lua index 99d0a2e..e79e074 100644 --- a/scenes/gameplay/draw/food.lua +++ b/scenes/gameplay/draw/food.lua @@ -1,7 +1,11 @@ -return function(food, sheets, spritescale) +local sheetNames = { + 'food1', 'food2', 'food3', 'potion' +} + +return function(food, sheets, spritescale, starpotionequipped) local sw, sh = love.graphics.getDimensions() for _,f in ipairs(food) do - local sheet = sheets['food' .. (f.type)] + local sheet = sheets[sheetNames[f.type]] local x = f.x * sw local y = f.y * sh local frame = math.floor((f.time%1) * #sheet.quads) + 1 @@ -10,4 +14,10 @@ return function(food, sheets, spritescale) love.graphics.draw(sheet.spriteSheet, sheet.quads[math.max(math.min(frame, #sheet.quads), 1)], x, y, 0, spritescale, spritescale, sheet.width/2, sheet.height/2) end + + if starpotionequipped then + local sheet = sheets.potion + love.graphics.setColor(1, 1, 1, 0.8) + love.graphics.draw(sheet.spriteSheet, sheet.quads[1], love.mouse.getX(), love.mouse.getY(), 0, spritescale, spritescale, sheet.width/2, sheet.height/2) + end end \ No newline at end of file diff --git a/scenes/gameplay/draw/header.lua b/scenes/gameplay/draw/header.lua index 07c4e09..972d02c 100644 --- a/scenes/gameplay/draw/header.lua +++ b/scenes/gameplay/draw/header.lua @@ -1,4 +1,4 @@ -return function(headerheight, fishsprite, headerbuttons, sheets, balance) +return function(headerheight, fishsprite, headerbuttons, sheets, balance, moneyflashtimer) local sw, sh = love.graphics.getDimensions() local base = sprites['header/base'] local size = headerheight / HEADER_HEIGHT @@ -68,6 +68,12 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance) love.graphics.setColor(0, 1, 0) love.graphics.printf(btn.tier + 1, round(x * size), round(y * size + offset*0.75 - fonts.continuum:getHeight()/2), round(sprites['header/buttonbg']:getWidth() * size), 'center') + elseif btn.sprite == 'starpotion' then + local sheet = sheets.potion + + local scale = (sprites['header/buttonbg']:getWidth() / sheet.width) * 0.65 + local offset = (sprites['header/buttonbg']:getWidth() * size) / 2 + love.graphics.draw(sheet.spriteSheet, sheet.quads[1], x * size + offset, y * size + offset*0.75, 0, size * scale, size * scale, sheet.width/2, sheet.width/2) end -- price @@ -101,11 +107,13 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance) end -- money count + if love.timer.getTime() % 0.25 < 0.125 and moneyflashtimer > 0 then love.graphics.draw(sprites['header/moneyflash'], sw * 0.851, (HEADER_HEIGHT - 29) * size, 0, size, size) end love.graphics.setFont(fonts.continuum) love.graphics.setColor(179/255, 254/255, 89/255) local leftpad = 100 - love.graphics.printf(balance, round(sw * 0.965 - leftpad), round(HEADER_HEIGHT - 25), leftpad, 'right') + love.graphics.printf(balance, round(sw * 0.965 - leftpad), round((HEADER_HEIGHT - 25) * size), leftpad, 'right') + -- tooltips if tooltipText then love.graphics.setColor(254/255, 254/255, 199/255) love.graphics.rectangle('fill', round(tooltipx - 5), round(tooltipy - 5), round(tooltipText:getWidth() + 10), round(tooltipText:getHeight() + 10)) diff --git a/scenes/gameplay/main.lua b/scenes/gameplay/main.lua index 1c00aa2..c776d49 100644 --- a/scenes/gameplay/main.lua +++ b/scenes/gameplay/main.lua @@ -11,6 +11,9 @@ local balance = 100 local foodtier = 1 local foodcount = 1 +local starpotionequipped = false +local moneyflashtimer = 0 + local headerbuttons = { { cost = 100, @@ -73,6 +76,17 @@ local headerbuttons = { playSound('splash', 0.7, 0.8) table.insert(feesh, constr.fish(math.random(), 0.3, 4)) end + }, + { + cost = 250, + sprite = 'starpotion', + tooltip = 'buy star potion', + openanim = 1, + open = true, + closed = false, + func = function() + starpotionequipped = true + end } } @@ -94,6 +108,7 @@ function self.load() sheets.food1 = newAnimation(sprites['food/1'], sprites['food/1']:getWidth()/10, sprites['food/1']:getHeight()) sheets.food2 = newAnimation(sprites['food/2'], sprites['food/2']:getWidth()/10, sprites['food/2']:getHeight()) sheets.food3 = newAnimation(sprites['food/3'], sprites['food/3']:getWidth()/10, sprites['food/3']:getHeight()) + sheets.potion = newAnimation(sprites['food/potion'], sprites['food/potion']:getWidth()/10, sprites['food/potion']:getHeight()) sheets.buttonopen = newAnimation(sprites['header/button_open'], sprites['header/button_open']:getWidth()/3, sprites['header/button_open']:getHeight()) @@ -111,6 +126,8 @@ end function self.update(dt) bench.startBenchmark('update_buttons') + moneyflashtimer = moneyflashtimer - dt + local x = 19 local y = 3 for b,btn in ipairs(headerbuttons) do @@ -172,7 +189,7 @@ function self.draw() bench.stopBenchmark('render_shadow') bench.startBenchmark('render_food') - require('scenes.gameplay.draw.food')(food, sheets, spritescale) + require('scenes.gameplay.draw.food')(food, sheets, spritescale, starpotionequipped) bench.stopBenchmark('render_food') -- all the fish @@ -182,7 +199,7 @@ function self.draw() bench.stopBenchmark('render_tank') bench.startBenchmark('render_header') - require('scenes.gameplay.draw.header')(headerheight, fishsprite, headerbuttons, sheets, balance) + require('scenes.gameplay.draw.header')(headerheight, fishsprite, headerbuttons, sheets, balance, moneyflashtimer) bench.stopBenchmark('render_header') bench.startBenchmark('render_money') @@ -193,7 +210,7 @@ end function self.mousepressed(x, y, b) if b == 1 then for _,m in ipairs(money) do - local dist = math.abs(x/love.graphics.getWidth() - m.x) + math.abs(y/love.graphics.getHeight() - m.y) + local dist = math.abs(x - m.x * love.graphics.getWidth()) + math.abs(y - m.y * love.graphics.getHeight()) if dist < sheets.coin1.width/2 and not m.collected then m.collected = true m.deathtimer = 0 @@ -210,14 +227,23 @@ function self.mousepressed(x, y, b) end end - if b == 1 and y > HEADER_HEIGHT and #food < foodcount then - if balance >= 5 or debug then - table.insert(food, constr.food(x/love.graphics.getWidth(), y/love.graphics.getHeight(), foodtier)) + if b == 1 and y > HEADER_HEIGHT then + if starpotionequipped then + table.insert(food, constr.food(x/love.graphics.getWidth(), y/love.graphics.getHeight(), 4)) playSound('dropfood') - balance = balance - 5 - else - playSound('buzzer') + starpotionequipped = false + elseif #food < foodcount then + if balance >= 5 or debug then + table.insert(food, constr.food(x/love.graphics.getWidth(), y/love.graphics.getHeight(), foodtier)) + playSound('dropfood') + balance = balance - 5 + else + playSound('buzzer') + moneyflashtimer = 1.2 + end end + + return end local headerheight = HEADER_HEIGHT * love.graphics.getWidth()/640 @@ -236,6 +262,7 @@ function self.mousepressed(x, y, b) balance = balance - headerbuttons[i].cost else playSound('buzzer') + moneyflashtimer = 1.2 end end end diff --git a/scenes/gameplay/update/fish.lua b/scenes/gameplay/update/fish.lua index c0110f3..3aa7407 100644 --- a/scenes/gameplay/update/fish.lua +++ b/scenes/gameplay/update/fish.lua @@ -129,6 +129,7 @@ return function(feesh, dt, food, headerbuttons, money) if n.size == 1 then type = 1 end if n.size == 3 then type = 3 end if n.size == 4 then type = 4 end + if n.star then type = 3 end table.insert(money, constr.money(n.render.x, n.render.y, type)) end end @@ -174,39 +175,48 @@ return function(feesh, dt, food, headerbuttons, money) table.remove(food, n.shortestfood) local cooldowns = {FISH_FOOD_1_COOLDOWN, FISH_FOOD_2_COOLDOWN, FISH_FOOD_3_COOLDOWN} - n.eattimer = cooldowns[f.type] + n.eattimer = cooldowns[f.type] or FISH_FOOD_3_COOLDOWN n.render.eattimer = 0 n.shortestfood = -1 - if n.lifetime > FISH_AGE_MEDIUM and n.size == 0 then - n.size = 1 - playSound('grow') + if f.type == 4 then -- star potion + if n.size == 2 or n.size == 3 then + n.star = true + else + n.eattimer = -9e9 + playSound('explode') + end + else + if n.lifetime > FISH_AGE_MEDIUM and n.size == 0 then + n.size = 1 + playSound('grow') - if not headerbuttons[1].open and not headerbuttons[1].closed then - headerbuttons[1].open = true - headerbuttons[1].openanim = 0 + if not headerbuttons[1].open and not headerbuttons[1].closed then + headerbuttons[1].open = true + headerbuttons[1].openanim = 0 + end end - end - if n.lifetime > FISH_AGE_BIG and n.size == 1 then - n.size = 2 - playSound('grow') + if n.lifetime > FISH_AGE_BIG and n.size == 1 then + n.size = 2 + playSound('grow') - if not headerbuttons[2].open and not headerbuttons[2].closed then - headerbuttons[2].open = true - headerbuttons[2].openanim = 0 + if not headerbuttons[2].open and not headerbuttons[2].closed then + headerbuttons[2].open = true + headerbuttons[2].openanim = 0 + end + if not headerbuttons[3].open and not headerbuttons[3].closed then + headerbuttons[3].open = true + headerbuttons[3].openanim = 0 + end + if not headerbuttons[4].open and not headerbuttons[4].closed then + headerbuttons[4].open = true + headerbuttons[4].openanim = 0 + end end - if not headerbuttons[3].open and not headerbuttons[3].closed then - headerbuttons[3].open = true - headerbuttons[3].openanim = 0 + if n.lifetime > FISH_AGE_KING and n.size == 2 then + n.size = 3 + playSound('grow') end - if not headerbuttons[4].open and not headerbuttons[4].closed then - headerbuttons[4].open = true - headerbuttons[4].openanim = 0 - end - end - if n.lifetime > FISH_AGE_KING and n.size == 2 then - n.size = 3 - playSound('grow') end end end