star fish
This commit is contained in:
parent
00f4f5a30b
commit
0cf9e962b6
10 changed files with 110 additions and 41 deletions
BIN
assets/audio/sfx/explode.ogg
Normal file
BIN
assets/audio/sfx/explode.ogg
Normal file
Binary file not shown.
BIN
assets/sprites/header/moneyflash.png
Normal file
BIN
assets/sprites/header/moneyflash.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 807 B |
BIN
assets/sprites/header/optionsbutton_down.png
Normal file
BIN
assets/sprites/header/optionsbutton_down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
assets/sprites/header/optionsbutton_hover.png
Normal file
BIN
assets/sprites/header/optionsbutton_hover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue