Compare commits
2 commits
e764082a80
...
18d9d681b8
Author | SHA1 | Date | |
---|---|---|---|
|
18d9d681b8 | ||
|
057e9d3d41 |
4 changed files with 53 additions and 9 deletions
13
main.lua
13
main.lua
|
@ -91,6 +91,17 @@ function love.draw()
|
|||
love.graphics.setColor(1, 1, 1, 1)
|
||||
love.graphics.print('FPS: ' .. 1 / love.timer.getDelta(), 0, sh - 16)
|
||||
|
||||
if paused then
|
||||
love.graphics.setBlendMode('subtract')
|
||||
love.graphics.setColor(1, 1, 1, 0.1)
|
||||
love.graphics.rectangle('fill', 0, 0, sw, sh)
|
||||
love.graphics.setBlendMode('alpha')
|
||||
love.graphics.setColor(0, 0, 0, 0.6)
|
||||
love.graphics.rectangle('fill', 0, 0, sw, sh)
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.print('paused, space to unpause', 20, 20)
|
||||
end
|
||||
|
||||
if debug then bench.renderBenchmark() end
|
||||
bench.stopBenchmark('render')
|
||||
end
|
||||
|
@ -106,5 +117,7 @@ end
|
|||
function love.keypressed(key)
|
||||
if key == 'f3' then
|
||||
debug = not debug
|
||||
elseif key == 'space' then
|
||||
paused = false
|
||||
end
|
||||
end
|
|
@ -14,7 +14,7 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance, moneyf
|
|||
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 hovered = mouseOverBox(x * size, y * size, sprites['header/buttonbg']:getWidth() * size, sprites['header/buttonbg']:getHeight() * size) and not paused
|
||||
local btn = headerbuttons[b]
|
||||
|
||||
if (btn and not btn.open) or not btn then
|
||||
|
@ -35,8 +35,8 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance, moneyf
|
|||
end
|
||||
|
||||
tooltipText = btn.tooltipText
|
||||
tooltipx = x + sprites['header/buttonbg']:getWidth() * size * 0.5 - tooltipText:getWidth()/2
|
||||
tooltipy = y + sprites['header/buttonbg']:getWidth() * size
|
||||
tooltipx = x * size + sprites['header/buttonbg']:getWidth() * size * 0.5 - tooltipText:getWidth()/2
|
||||
tooltipy = y * size + sprites['header/buttonbg']:getWidth() * size
|
||||
end
|
||||
|
||||
if btn then
|
||||
|
@ -106,6 +106,16 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance, moneyf
|
|||
x = x + incr
|
||||
end
|
||||
|
||||
-- options text
|
||||
local s = sprites['header/optionsbutton_hover']
|
||||
local hovered = mouseOverBox(sw - 115 * size, size * (HEADER_HEIGHT - 65), s:getWidth() * size, s:getHeight() * size) and not paused
|
||||
|
||||
if hovered and love.mouse.isDown(1) then
|
||||
love.graphics.draw(sprites['header/optionsbutton_down'], sw - 115 * size, size * (HEADER_HEIGHT - 65), 0, size, size)
|
||||
elseif hovered then
|
||||
love.graphics.draw(sprites['header/optionsbutton_hover'], sw - 115 * size, size * (HEADER_HEIGHT - 65), 0, size, size)
|
||||
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)
|
||||
|
@ -114,7 +124,7 @@ return function(headerheight, fishsprite, headerbuttons, sheets, balance, moneyf
|
|||
love.graphics.printf(balance, round(sw * 0.965 - leftpad), round((HEADER_HEIGHT - 25) * size), leftpad, 'right')
|
||||
|
||||
-- tooltips
|
||||
if tooltipText then
|
||||
if tooltipText and not paused 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)
|
||||
|
|
|
@ -82,7 +82,7 @@ local headerbuttons = {
|
|||
sprite = 'starpotion',
|
||||
tooltip = 'buy star potion',
|
||||
openanim = 1,
|
||||
open = true,
|
||||
open = false,
|
||||
closed = false,
|
||||
func = function()
|
||||
starpotionequipped = true
|
||||
|
@ -91,6 +91,7 @@ local headerbuttons = {
|
|||
}
|
||||
|
||||
local sheets = {}
|
||||
paused = false
|
||||
|
||||
local function fishsprite(size, hungry, anim)
|
||||
-- anim is turn, swim, eat or die
|
||||
|
@ -124,6 +125,8 @@ function self.load()
|
|||
end
|
||||
|
||||
function self.update(dt)
|
||||
if paused then dt = 0 end
|
||||
|
||||
bench.startBenchmark('update_buttons')
|
||||
|
||||
moneyflashtimer = moneyflashtimer - dt
|
||||
|
@ -135,7 +138,7 @@ function self.update(dt)
|
|||
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
|
||||
if btn.open and hovered and not paused then
|
||||
setCursor(cursors.hover)
|
||||
end
|
||||
|
||||
|
@ -145,6 +148,13 @@ function self.update(dt)
|
|||
x = x + incr
|
||||
end
|
||||
|
||||
local s = sprites['header/optionsbutton_hover']
|
||||
local size = love.graphics.getWidth() / 640
|
||||
local hovered = mouseOverBox(love.graphics.getWidth() - 115 * size, size * (HEADER_HEIGHT - 65), s:getWidth() * size, s:getHeight() * size)
|
||||
if hovered and not paused then
|
||||
setCursor(cursors.hover)
|
||||
end
|
||||
|
||||
bench.stopBenchmark('update_buttons')
|
||||
|
||||
bench.startBenchmark('update_food')
|
||||
|
@ -208,7 +218,14 @@ function self.draw()
|
|||
end
|
||||
|
||||
function self.mousepressed(x, y, b)
|
||||
if b == 1 then
|
||||
if b == 1 and not paused then
|
||||
local s = sprites['header/optionsbutton_hover']
|
||||
local size = love.graphics.getWidth() / 640
|
||||
local hovered = mouseOverBox(love.graphics.getWidth() - 115 * size, size * (HEADER_HEIGHT - 65), s:getWidth() * size, s:getHeight() * size)
|
||||
if hovered then
|
||||
paused = true
|
||||
end
|
||||
|
||||
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
|
||||
|
@ -227,7 +244,7 @@ function self.mousepressed(x, y, b)
|
|||
end
|
||||
end
|
||||
|
||||
if b == 1 and y > HEADER_HEIGHT then
|
||||
if b == 1 and y > HEADER_HEIGHT and not paused then
|
||||
if starpotionequipped then
|
||||
table.insert(food, constr.food(x/love.graphics.getWidth(), y/love.graphics.getHeight(), 4))
|
||||
playSound('dropfood')
|
||||
|
@ -249,7 +266,7 @@ function self.mousepressed(x, y, b)
|
|||
local headerheight = HEADER_HEIGHT * love.graphics.getWidth()/640
|
||||
local size = headerheight / HEADER_HEIGHT
|
||||
|
||||
if b == 1 then
|
||||
if b == 1 and not paused then
|
||||
local x = 19
|
||||
for i = 1, 7 do
|
||||
local hovered = mouseOverBox(x * size, 3 * size, sprites['header/buttonbg']:getWidth() * size, sprites['header/buttonbg']:getHeight() * size)
|
||||
|
|
|
@ -212,6 +212,10 @@ return function(feesh, dt, food, headerbuttons, money)
|
|||
headerbuttons[4].open = true
|
||||
headerbuttons[4].openanim = 0
|
||||
end
|
||||
if not headerbuttons[5].open and not headerbuttons[5].closed then
|
||||
headerbuttons[5].open = true
|
||||
headerbuttons[5].openanim = 0
|
||||
end
|
||||
end
|
||||
if n.lifetime > FISH_AGE_KING and n.size == 2 then
|
||||
n.size = 3
|
||||
|
|
Loading…
Reference in a new issue