diff --git a/assets/audio/sfx/explode.ogg b/assets/audio/sfx/explode.ogg deleted file mode 100644 index 80b4caa..0000000 Binary files a/assets/audio/sfx/explode.ogg and /dev/null differ diff --git a/assets/sprites/cursor/dragging.png b/assets/sprites/cursor/dragging.png deleted file mode 100644 index 5d3d6e6..0000000 Binary files a/assets/sprites/cursor/dragging.png and /dev/null differ diff --git a/assets/sprites/cursor/hand.png b/assets/sprites/cursor/hand.png deleted file mode 100644 index f278e72..0000000 Binary files a/assets/sprites/cursor/hand.png and /dev/null differ diff --git a/assets/sprites/cursor/pointer.png b/assets/sprites/cursor/pointer.png deleted file mode 100644 index 6553162..0000000 Binary files a/assets/sprites/cursor/pointer.png and /dev/null differ diff --git a/assets/sprites/header/moneyflash.png b/assets/sprites/header/moneyflash.png deleted file mode 100644 index f6e262a..0000000 Binary files a/assets/sprites/header/moneyflash.png and /dev/null differ diff --git a/assets/sprites/header/optionsbutton_down.png b/assets/sprites/header/optionsbutton_down.png deleted file mode 100644 index 533ac1e..0000000 Binary files a/assets/sprites/header/optionsbutton_down.png and /dev/null differ diff --git a/assets/sprites/header/optionsbutton_hover.png b/assets/sprites/header/optionsbutton_hover.png deleted file mode 100644 index d0090e4..0000000 Binary files a/assets/sprites/header/optionsbutton_hover.png and /dev/null differ diff --git a/constructors.lua b/constructors.lua index b6e5ca9..c1f5077 100644 --- a/constructors.lua +++ b/constructors.lua @@ -7,11 +7,10 @@ function self.fish(x, y, type) local fish = { x = x, y = y, - size = 2, -- 0 for small, 1 for medium, 2 for big, 3 for king, 4 for carnivore + size = type, -- 0 for small, 1 for medium, 2 for big, 3 for king, 4 for carnivore 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, @@ -55,7 +54,7 @@ function self.food(x, y, type) speed = 0.2, time = math.random(), deathtimer = 0, - type = type -- 1 = tier 1, 2 = tier 2, 3 = tier 3, 4 = star potion + type = type } return food diff --git a/main.lua b/main.lua index ca3143a..d0fe3a2 100644 --- a/main.lua +++ b/main.lua @@ -20,7 +20,6 @@ sprites = {} sound_path = {} music_path = {} fonts = {} -cursors = {} debug = false @@ -49,22 +48,10 @@ function love.load() fonts.default = love.graphics.newFont(12) if scene.load then scene.load() end - - cursors.default = love.mouse.newCursor('assets/sprites/cursor/pointer.png', sprites['cursor/pointer']:getWidth()/2, sprites['cursor/pointer']:getHeight()/2) - cursors.hover = love.mouse.newCursor('assets/sprites/cursor/hand.png', sprites['cursor/hand']:getWidth()/2, sprites['cursor/hand']:getHeight()/2) - cursors.drag = love.mouse.newCursor('assets/sprites/cursor/dragging.png', sprites['cursor/dragging']:getWidth()/2, sprites['cursor/dragging']:getHeight()/2) - - love.mouse.setCursor(cursors.default) -end - -local cursor -function setCursor(mouse) - cursor = mouse end frame = 0 function love.update(dt) - cursor = nil frame = frame + 1 bench.update() tick.update(dt) @@ -72,12 +59,6 @@ function love.update(dt) bench.startBenchmark('update') if scene.update then scene.update(dt) end bench.stopBenchmark('update') - - if cursor then - love.mouse.setCursor(cursor) - else - love.mouse.setCursor(cursors.default) - end end function love.draw() diff --git a/scenes/gameplay/draw/fish.lua b/scenes/gameplay/draw/fish.lua index fe6724c..7e2ef5e 100644 --- a/scenes/gameplay/draw/fish.lua +++ b/scenes/gameplay/draw/fish.lua @@ -65,24 +65,11 @@ return function(feesh, spritescale, fishsprite) local sadsheet = fishsprite(size, true, anim) local alpha = n.render.hungry == 1 and 0 or 1 - local allalpha = 1 - if n.star then allalpha = 0.8 end - love.graphics.setColor(1, 1, 1, (alpha - n.render.deathanim) * allalpha) + love.graphics.setColor(1, 1, 1, alpha - n.render.deathanim) 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) * allalpha) + love.graphics.setColor(1, 1, 1, n.render.hungry - n.render.deathanim) 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 e79e074..99d0a2e 100644 --- a/scenes/gameplay/draw/food.lua +++ b/scenes/gameplay/draw/food.lua @@ -1,11 +1,7 @@ -local sheetNames = { - 'food1', 'food2', 'food3', 'potion' -} - -return function(food, sheets, spritescale, starpotionequipped) +return function(food, sheets, spritescale) local sw, sh = love.graphics.getDimensions() for _,f in ipairs(food) do - local sheet = sheets[sheetNames[f.type]] + local sheet = sheets['food' .. (f.type)] local x = f.x * sw local y = f.y * sh local frame = math.floor((f.time%1) * #sheet.quads) + 1 @@ -14,10 +10,4 @@ return function(food, sheets, spritescale, starpotionequipped) 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 972d02c..8449f86 100644 --- a/scenes/gameplay/draw/header.lua +++ b/scenes/gameplay/draw/header.lua @@ -1,44 +1,27 @@ -return function(headerheight, fishsprite, headerbuttons, sheets, balance, moneyflashtimer) +return function(headerheight, fishsprite, headerbuttons, sheets, balance) local sw, sh = love.graphics.getDimensions() local base = sprites['header/base'] local size = headerheight / HEADER_HEIGHT love.graphics.setColor(1, 1, 1, 1) love.graphics.draw(base, 0, 0, 0, size, size) - local tooltip - local tooltipText - local tooltipx - local tooltipy - -- the game is making me do this. im sorry local x = 19 local y = 3 for b = 1, 7 do local hovered = mouseOverBox(x * size, y * size, sprites['header/buttonbg']:getWidth() * size, sprites['header/buttonbg']:getHeight() * size) local btn = headerbuttons[b] - + if (btn and not btn.open) or not btn then -- draw nothing elseif hovered and love.mouse.isDown(1) then love.graphics.draw(sprites['header/buttonbg_down'], x * size, y * size, 0, size, size) - if not tooltip then tooltip = btn.tooltip end elseif hovered then love.graphics.draw(sprites['header/buttonbg_hover'], x * size, y * size, 0, size, size) - if not tooltip then tooltip = btn.tooltip end else love.graphics.draw(sprites['header/buttonbg'], x * size, y * size, 0, size, size) end - if tooltip and btn and not tooltipText then - if not btn.tooltipText then - btn.tooltipText = love.graphics.newText(fonts.pix, tooltip) - end - - tooltipText = btn.tooltipText - tooltipx = x + sprites['header/buttonbg']:getWidth() * size * 0.5 - tooltipText:getWidth()/2 - tooltipy = y + sprites['header/buttonbg']:getWidth() * size - end - if btn then if btn.open then -- sprite inside @@ -68,12 +51,6 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance, moneyf 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 @@ -107,22 +84,9 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance, moneyf 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) * 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)) - love.graphics.setColor(2/255, 2/255, 2/255) - love.graphics.rectangle('line', round(tooltipx - 5), round(tooltipy - 5), round(tooltipText:getWidth() + 10), round(tooltipText:getHeight() + 10)) - - love.graphics.setFont(fonts.pix) - love.graphics.draw(tooltipText, round(tooltipx), round(tooltipy)) - end - + love.graphics.printf(balance, round(sw * 0.965 - leftpad), round(HEADER_HEIGHT - 25), leftpad, 'right') love.graphics.setFont(fonts.default) end \ No newline at end of file diff --git a/scenes/gameplay/main.lua b/scenes/gameplay/main.lua index c776d49..5609f16 100644 --- a/scenes/gameplay/main.lua +++ b/scenes/gameplay/main.lua @@ -11,15 +11,11 @@ local balance = 100 local foodtier = 1 local foodcount = 1 -local starpotionequipped = false -local moneyflashtimer = 0 - local headerbuttons = { { cost = 100, sprite = 'guppy', openanim = 1, - tooltip = 'buy guppy', open = false, closed = false, func = function() @@ -32,7 +28,6 @@ local headerbuttons = { sprite = 'food', tier = foodtier, openanim = 1, - tooltip = 'upgrade food quality', open = false, closed = false, func = function(self) @@ -51,7 +46,6 @@ local headerbuttons = { sprite = 'foodcount', tier = foodcount, openanim = 1, - tooltip = 'upgrade food quantity', open = false, closed = false, func = function(self) @@ -68,7 +62,6 @@ local headerbuttons = { { cost = 1000, sprite = 'carnivore', - tooltip = 'buy carnivore', openanim = 1, open = false, closed = false, @@ -76,17 +69,6 @@ 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 } } @@ -108,7 +90,6 @@ 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()) @@ -125,26 +106,9 @@ 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 + for _,btn in ipairs(headerbuttons) do btn.openanim = btn.openanim + dt * 6 - local size = (love.graphics.getWidth()/640) - local hovered = mouseOverBox(x * size, y * size, sprites['header/buttonbg']:getWidth() * size, sprites['header/buttonbg']:getHeight() * size) - - if btn.open and hovered then - setCursor(cursors.hover) - end - - local incr = 69 -- its like button positions but forcefully shoved into a recursive function :D - if b == 2 then incr = 57 end - if b >= 3 then incr = 73 end - x = x + incr end - bench.stopBenchmark('update_buttons') bench.startBenchmark('update_food') @@ -152,7 +116,7 @@ function self.update(dt) bench.stopBenchmark('update_food') bench.startBenchmark('update_money') - require('scenes.gameplay.update.money')(money, dt, sheets) + require('scenes.gameplay.update.money')(money, dt) bench.stopBenchmark('update_money') bench.startBenchmark('update_fish') @@ -189,7 +153,7 @@ function self.draw() bench.stopBenchmark('render_shadow') bench.startBenchmark('render_food') - require('scenes.gameplay.draw.food')(food, sheets, spritescale, starpotionequipped) + require('scenes.gameplay.draw.food')(food, sheets, spritescale) bench.stopBenchmark('render_food') -- all the fish @@ -199,7 +163,7 @@ function self.draw() bench.stopBenchmark('render_tank') bench.startBenchmark('render_header') - require('scenes.gameplay.draw.header')(headerheight, fishsprite, headerbuttons, sheets, balance, moneyflashtimer) + require('scenes.gameplay.draw.header')(headerheight, fishsprite, headerbuttons, sheets, balance) bench.stopBenchmark('render_header') bench.startBenchmark('render_money') @@ -210,8 +174,8 @@ end function self.mousepressed(x, y, b) if b == 1 then for _,m in ipairs(money) do - 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 + local dist = math.abs(x/love.graphics.getWidth() - m.x) + math.abs(y/love.graphics.getHeight() - m.y) + if dist < 0.1 and not m.collected then m.collected = true m.deathtimer = 0 playSound('collect', 1, 1 + math.random() * 0.2 - 0.1) @@ -227,23 +191,14 @@ function self.mousepressed(x, y, b) end end - 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)) + 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)) playSound('dropfood') - 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 + balance = balance - 5 + else + playSound('buzzer') end - - return end local headerheight = HEADER_HEIGHT * love.graphics.getWidth()/640 @@ -262,7 +217,6 @@ 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 3aa7407..ec612e1 100644 --- a/scenes/gameplay/update/fish.lua +++ b/scenes/gameplay/update/fish.lua @@ -29,7 +29,6 @@ return function(feesh, dt, food, headerbuttons, money) local str = math.random(70, 200)/200/4 angle = mix(angle, math.deg(math.atan2((0.5 + math.sin(love.timer.getTime()/10 + fi) * 0.2) - n.y, 0)), 0.1) -- slightly head towards the middle, to prevent getting stuck at the bottom or top - local followingObj = (n.shortestfood and food[n.shortestfood] and n.size ~= 4) or (n.shortestfood and feesh[n.shortestfood] and n.size == 4) if n.eattimer <= 0 and not n.dead then -- needs to follow something local mx, my if n.eattimer <= 0 then @@ -86,7 +85,7 @@ return function(feesh, dt, food, headerbuttons, money) local x = math.cos(math.rad(angle)) * str local y = math.sin(math.rad(angle)) * str - if not (followingObj or n.dead) then + if not ((n.shortestfood and food[n.shortestfood]) or n.dead) then x = x * math.sign(n.render.x - n.render.prevx) end @@ -102,9 +101,8 @@ return function(feesh, dt, food, headerbuttons, money) end e.speed = 1 / (math.sqrt(math.pow(math.abs(e.x - e.fromx), 2) + math.pow(math.abs(e.y - e.fromy), 2))/2) / 15 - if n.eattimer < FISH_FOOD_HUNGRY or followingObj then + if n.eattimer < FISH_FOOD_HUNGRY or (n.shortestfood and food[n.shortestfood]) then e.speed = e.speed * 1.3 - if n.size == 4 then e.speed = e.speed * 1.1 end end if n.dead then e.speed = e.speed * 0.2 @@ -129,7 +127,6 @@ 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 @@ -175,48 +172,39 @@ 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] or FISH_FOOD_3_COOLDOWN + n.eattimer = cooldowns[f.type] n.render.eattimer = 0 n.shortestfood = -1 - 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 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 - end + if not headerbuttons[1].open and not headerbuttons[1].closed then + headerbuttons[1].open = true + headerbuttons[1].openanim = 0 end - if n.lifetime > FISH_AGE_BIG and n.size == 1 then - n.size = 2 - playSound('grow') + end + 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 - 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 + if not headerbuttons[2].open and not headerbuttons[2].closed then + headerbuttons[2].open = true + headerbuttons[2].openanim = 0 end - if n.lifetime > FISH_AGE_KING and n.size == 2 then - n.size = 3 - playSound('grow') + 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 n.lifetime > FISH_AGE_KING and n.size == 2 then + n.size = 3 + playSound('grow') end end end diff --git a/scenes/gameplay/update/money.lua b/scenes/gameplay/update/money.lua index 5fc4fba..1220fb1 100644 --- a/scenes/gameplay/update/money.lua +++ b/scenes/gameplay/update/money.lua @@ -1,4 +1,4 @@ -return function(money, dt, sheets) +return function(money, dt) for i,f in ipairs(money) do if not f.collected then f.y = f.y + dt * f.speed @@ -16,10 +16,5 @@ return function(money, dt, sheets) if f.deathtimer > 1 or f.collecttimer > 1 then table.remove(money, i) end - - local dist = math.abs(love.mouse.getX() - f.x * love.graphics.getWidth()) + math.abs(love.mouse.getY() - f.y * love.graphics.getHeight()) - if dist < sheets.coin1.width/2 and not f.collected then - setCursor(cursors.hover) - end end end \ No newline at end of file