Compare commits

...

3 Commits

Author SHA1 Message Date
jill 0cf9e962b6
star fish 2021-01-25 21:05:06 +03:00
jill 00f4f5a30b
more cursor stuff 2021-01-25 19:42:27 +03:00
jill c4d1846765
cursors 2021-01-25 18:17:32 +03:00
15 changed files with 191 additions and 49 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -7,10 +7,11 @@ function self.fish(x, y, type)
local fish = { local fish = {
x = x, x = x,
y = y, y = y,
size = type, -- 0 for small, 1 for medium, 2 for big, 3 for king, 4 for carnivore size = 2, -- 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 eattimer = 0 + math.random() * 2, -- starts out hungry, with a 2s delay
moneytimer = 10 + math.random() * 5, -- min 10s before it can make money moneytimer = 10 + math.random() * 5, -- min 10s before it can make money
dead = false, dead = false,
star = false,
lifetime = 0, lifetime = 0,
@ -54,7 +55,7 @@ function self.food(x, y, type)
speed = 0.2, speed = 0.2,
time = math.random(), time = math.random(),
deathtimer = 0, deathtimer = 0,
type = type type = type -- 1 = tier 1, 2 = tier 2, 3 = tier 3, 4 = star potion
} }
return food return food

View File

@ -20,6 +20,7 @@ sprites = {}
sound_path = {} sound_path = {}
music_path = {} music_path = {}
fonts = {} fonts = {}
cursors = {}
debug = false debug = false
@ -48,10 +49,22 @@ function love.load()
fonts.default = love.graphics.newFont(12) fonts.default = love.graphics.newFont(12)
if scene.load then scene.load() end 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 end
frame = 0 frame = 0
function love.update(dt) function love.update(dt)
cursor = nil
frame = frame + 1 frame = frame + 1
bench.update() bench.update()
tick.update(dt) tick.update(dt)
@ -59,6 +72,12 @@ function love.update(dt)
bench.startBenchmark('update') bench.startBenchmark('update')
if scene.update then scene.update(dt) end if scene.update then scene.update(dt) end
bench.stopBenchmark('update') bench.stopBenchmark('update')
if cursor then
love.mouse.setCursor(cursor)
else
love.mouse.setCursor(cursors.default)
end
end end
function love.draw() function love.draw()

View File

@ -65,11 +65,24 @@ return function(feesh, spritescale, fishsprite)
local sadsheet = fishsprite(size, true, anim) local sadsheet = fishsprite(size, true, anim)
local alpha = n.render.hungry == 1 and 0 or 1 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.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) 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) love.graphics.setColor(1, 1, 1)
if debug then love.graphics.print(shrt(n.eattimer), x + 20, y + 20) end if debug then love.graphics.print(shrt(n.eattimer), x + 20, y + 20) end

View File

@ -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() local sw, sh = love.graphics.getDimensions()
for _,f in ipairs(food) do for _,f in ipairs(food) do
local sheet = sheets['food' .. (f.type)] local sheet = sheets[sheetNames[f.type]]
local x = f.x * sw local x = f.x * sw
local y = f.y * sh local y = f.y * sh
local frame = math.floor((f.time%1) * #sheet.quads) + 1 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) 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 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 end

View File

@ -1,10 +1,15 @@
return function(headerheight, fishsprite, headerbuttons, sheets, balance) return function(headerheight, fishsprite, headerbuttons, sheets, balance, moneyflashtimer)
local sw, sh = love.graphics.getDimensions() local sw, sh = love.graphics.getDimensions()
local base = sprites['header/base'] local base = sprites['header/base']
local size = headerheight / HEADER_HEIGHT local size = headerheight / HEADER_HEIGHT
love.graphics.setColor(1, 1, 1, 1) love.graphics.setColor(1, 1, 1, 1)
love.graphics.draw(base, 0, 0, 0, size, size) 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 -- the game is making me do this. im sorry
local x = 19 local x = 19
local y = 3 local y = 3
@ -16,12 +21,24 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance)
-- draw nothing -- draw nothing
elseif hovered and love.mouse.isDown(1) then elseif hovered and love.mouse.isDown(1) then
love.graphics.draw(sprites['header/buttonbg_down'], x * size, y * size, 0, size, size) 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 elseif hovered then
love.graphics.draw(sprites['header/buttonbg_hover'], x * size, y * size, 0, size, size) love.graphics.draw(sprites['header/buttonbg_hover'], x * size, y * size, 0, size, size)
if not tooltip then tooltip = btn.tooltip end
else else
love.graphics.draw(sprites['header/buttonbg'], x * size, y * size, 0, size, size) love.graphics.draw(sprites['header/buttonbg'], x * size, y * size, 0, size, size)
end 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 then
if btn.open then if btn.open then
-- sprite inside -- sprite inside
@ -51,6 +68,12 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance)
love.graphics.setColor(0, 1, 0) 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') 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 end
-- price -- price
@ -84,9 +107,22 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance)
end end
-- money count -- 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.setFont(fonts.continuum)
love.graphics.setColor(179/255, 254/255, 89/255) love.graphics.setColor(179/255, 254/255, 89/255)
local leftpad = 100 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))
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.setFont(fonts.default) love.graphics.setFont(fonts.default)
end end

View File

@ -11,11 +11,15 @@ local balance = 100
local foodtier = 1 local foodtier = 1
local foodcount = 1 local foodcount = 1
local starpotionequipped = false
local moneyflashtimer = 0
local headerbuttons = { local headerbuttons = {
{ {
cost = 100, cost = 100,
sprite = 'guppy', sprite = 'guppy',
openanim = 1, openanim = 1,
tooltip = 'buy guppy',
open = false, open = false,
closed = false, closed = false,
func = function() func = function()
@ -28,6 +32,7 @@ local headerbuttons = {
sprite = 'food', sprite = 'food',
tier = foodtier, tier = foodtier,
openanim = 1, openanim = 1,
tooltip = 'upgrade food quality',
open = false, open = false,
closed = false, closed = false,
func = function(self) func = function(self)
@ -46,6 +51,7 @@ local headerbuttons = {
sprite = 'foodcount', sprite = 'foodcount',
tier = foodcount, tier = foodcount,
openanim = 1, openanim = 1,
tooltip = 'upgrade food quantity',
open = false, open = false,
closed = false, closed = false,
func = function(self) func = function(self)
@ -62,6 +68,7 @@ local headerbuttons = {
{ {
cost = 1000, cost = 1000,
sprite = 'carnivore', sprite = 'carnivore',
tooltip = 'buy carnivore',
openanim = 1, openanim = 1,
open = false, open = false,
closed = false, closed = false,
@ -69,6 +76,17 @@ local headerbuttons = {
playSound('splash', 0.7, 0.8) playSound('splash', 0.7, 0.8)
table.insert(feesh, constr.fish(math.random(), 0.3, 4)) table.insert(feesh, constr.fish(math.random(), 0.3, 4))
end end
},
{
cost = 250,
sprite = 'starpotion',
tooltip = 'buy star potion',
openanim = 1,
open = true,
closed = false,
func = function()
starpotionequipped = true
end
} }
} }
@ -90,6 +108,7 @@ function self.load()
sheets.food1 = newAnimation(sprites['food/1'], sprites['food/1']:getWidth()/10, sprites['food/1']:getHeight()) 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.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.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()) sheets.buttonopen = newAnimation(sprites['header/button_open'], sprites['header/button_open']:getWidth()/3, sprites['header/button_open']:getHeight())
@ -106,9 +125,26 @@ end
function self.update(dt) function self.update(dt)
bench.startBenchmark('update_buttons') bench.startBenchmark('update_buttons')
for _,btn in ipairs(headerbuttons) do
moneyflashtimer = moneyflashtimer - dt
local x = 19
local y = 3
for b,btn in ipairs(headerbuttons) do
btn.openanim = btn.openanim + dt * 6 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 end
bench.stopBenchmark('update_buttons') bench.stopBenchmark('update_buttons')
bench.startBenchmark('update_food') bench.startBenchmark('update_food')
@ -116,7 +152,7 @@ function self.update(dt)
bench.stopBenchmark('update_food') bench.stopBenchmark('update_food')
bench.startBenchmark('update_money') bench.startBenchmark('update_money')
require('scenes.gameplay.update.money')(money, dt) require('scenes.gameplay.update.money')(money, dt, sheets)
bench.stopBenchmark('update_money') bench.stopBenchmark('update_money')
bench.startBenchmark('update_fish') bench.startBenchmark('update_fish')
@ -153,7 +189,7 @@ function self.draw()
bench.stopBenchmark('render_shadow') bench.stopBenchmark('render_shadow')
bench.startBenchmark('render_food') 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') bench.stopBenchmark('render_food')
-- all the fish -- all the fish
@ -163,7 +199,7 @@ function self.draw()
bench.stopBenchmark('render_tank') bench.stopBenchmark('render_tank')
bench.startBenchmark('render_header') 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.stopBenchmark('render_header')
bench.startBenchmark('render_money') bench.startBenchmark('render_money')
@ -174,8 +210,8 @@ end
function self.mousepressed(x, y, b) function self.mousepressed(x, y, b)
if b == 1 then if b == 1 then
for _,m in ipairs(money) do 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 < 0.1 and not m.collected then if dist < sheets.coin1.width/2 and not m.collected then
m.collected = true m.collected = true
m.deathtimer = 0 m.deathtimer = 0
playSound('collect', 1, 1 + math.random() * 0.2 - 0.1) playSound('collect', 1, 1 + math.random() * 0.2 - 0.1)
@ -191,14 +227,23 @@ function self.mousepressed(x, y, b)
end end
end end
if b == 1 and y > HEADER_HEIGHT and #food < foodcount then if b == 1 and y > HEADER_HEIGHT then
if balance >= 5 or debug then if starpotionequipped then
table.insert(food, constr.food(x/love.graphics.getWidth(), y/love.graphics.getHeight(), foodtier)) table.insert(food, constr.food(x/love.graphics.getWidth(), y/love.graphics.getHeight(), 4))
playSound('dropfood') playSound('dropfood')
balance = balance - 5 starpotionequipped = false
else elseif #food < foodcount then
playSound('buzzer') 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 end
return
end end
local headerheight = HEADER_HEIGHT * love.graphics.getWidth()/640 local headerheight = HEADER_HEIGHT * love.graphics.getWidth()/640
@ -217,6 +262,7 @@ function self.mousepressed(x, y, b)
balance = balance - headerbuttons[i].cost balance = balance - headerbuttons[i].cost
else else
playSound('buzzer') playSound('buzzer')
moneyflashtimer = 1.2
end end
end end
end end

View File

@ -29,6 +29,7 @@ return function(feesh, dt, food, headerbuttons, money)
local str = math.random(70, 200)/200/4 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 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 if n.eattimer <= 0 and not n.dead then -- needs to follow something
local mx, my local mx, my
if n.eattimer <= 0 then if n.eattimer <= 0 then
@ -85,7 +86,7 @@ return function(feesh, dt, food, headerbuttons, money)
local x = math.cos(math.rad(angle)) * str local x = math.cos(math.rad(angle)) * str
local y = math.sin(math.rad(angle)) * str local y = math.sin(math.rad(angle)) * str
if not ((n.shortestfood and food[n.shortestfood]) or n.dead) then if not (followingObj or n.dead) then
x = x * math.sign(n.render.x - n.render.prevx) x = x * math.sign(n.render.x - n.render.prevx)
end end
@ -101,8 +102,9 @@ return function(feesh, dt, food, headerbuttons, money)
end 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 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 (n.shortestfood and food[n.shortestfood]) then if n.eattimer < FISH_FOOD_HUNGRY or followingObj then
e.speed = e.speed * 1.3 e.speed = e.speed * 1.3
if n.size == 4 then e.speed = e.speed * 1.1 end
end end
if n.dead then if n.dead then
e.speed = e.speed * 0.2 e.speed = e.speed * 0.2
@ -127,6 +129,7 @@ return function(feesh, dt, food, headerbuttons, money)
if n.size == 1 then type = 1 end if n.size == 1 then type = 1 end
if n.size == 3 then type = 3 end if n.size == 3 then type = 3 end
if n.size == 4 then type = 4 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)) table.insert(money, constr.money(n.render.x, n.render.y, type))
end end
end end
@ -172,39 +175,48 @@ return function(feesh, dt, food, headerbuttons, money)
table.remove(food, n.shortestfood) table.remove(food, n.shortestfood)
local cooldowns = {FISH_FOOD_1_COOLDOWN, FISH_FOOD_2_COOLDOWN, FISH_FOOD_3_COOLDOWN} 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.render.eattimer = 0
n.shortestfood = -1 n.shortestfood = -1
if n.lifetime > FISH_AGE_MEDIUM and n.size == 0 then if f.type == 4 then -- star potion
n.size = 1 if n.size == 2 or n.size == 3 then
playSound('grow') 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 if not headerbuttons[1].open and not headerbuttons[1].closed then
headerbuttons[1].open = true headerbuttons[1].open = true
headerbuttons[1].openanim = 0 headerbuttons[1].openanim = 0
end
end end
end if n.lifetime > FISH_AGE_BIG and n.size == 1 then
if n.lifetime > FISH_AGE_BIG and n.size == 1 then n.size = 2
n.size = 2 playSound('grow')
playSound('grow')
if not headerbuttons[2].open and not headerbuttons[2].closed then if not headerbuttons[2].open and not headerbuttons[2].closed then
headerbuttons[2].open = true headerbuttons[2].open = true
headerbuttons[2].openanim = 0 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 end
if not headerbuttons[3].open and not headerbuttons[3].closed then if n.lifetime > FISH_AGE_KING and n.size == 2 then
headerbuttons[3].open = true n.size = 3
headerbuttons[3].openanim = 0 playSound('grow')
end 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 end
end end

View File

@ -1,4 +1,4 @@
return function(money, dt) return function(money, dt, sheets)
for i,f in ipairs(money) do for i,f in ipairs(money) do
if not f.collected then if not f.collected then
f.y = f.y + dt * f.speed f.y = f.y + dt * f.speed
@ -16,5 +16,10 @@ return function(money, dt)
if f.deathtimer > 1 or f.collecttimer > 1 then if f.deathtimer > 1 or f.collecttimer > 1 then
table.remove(money, i) table.remove(money, i)
end 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
end end