Compare commits
No commits in common. "0f0d092339db27cd1e8dc71ed3ae254f0b1b9d67" and "6ecbf07dbf2150d00a4da5df18687ffac3cdd7e3" have entirely different histories.
0f0d092339
...
6ecbf07dbf
Before Width: | Height: | Size: 8.6 KiB |
BIN
assets/sprites/footer/gif/HatchANIMATION.gif
Executable file
After Width: | Height: | Size: 4.2 KiB |
BIN
assets/sprites/footer/gif/_HatchANIMATION.gif
Executable file
After Width: | Height: | Size: 1.3 KiB |
BIN
assets/sprites/footer/gif/_MBREFLECTION.gif
Executable file
After Width: | Height: | Size: 1.1 KiB |
BIN
assets/sprites/footer/gif/_mbuttond.gif
Executable file
After Width: | Height: | Size: 411 B |
BIN
assets/sprites/footer/gif/_mbuttono.gif
Executable file
After Width: | Height: | Size: 430 B |
BIN
assets/sprites/footer/gif/_mbuttonu.gif
Executable file
After Width: | Height: | Size: 434 B |
BIN
assets/sprites/footer/gif/_menubar.gif
Executable file
After Width: | Height: | Size: 628 B |
BIN
assets/sprites/footer/gif/mbuttond.gif
Executable file
After Width: | Height: | Size: 1.5 KiB |
BIN
assets/sprites/footer/gif/mbuttono.gif
Executable file
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/sprites/footer/gif/mbuttonu.gif
Executable file
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/sprites/footer/gif/menubar.gif
Executable file
After Width: | Height: | Size: 17 KiB |
|
@ -18,9 +18,9 @@ function self.fish(x, y)
|
||||||
render = {
|
render = {
|
||||||
x = 0,
|
x = 0,
|
||||||
y = 0,
|
y = 0,
|
||||||
prevx = math.random() - 0.5,
|
prevx = 0,
|
||||||
prevy = math.random() - 0.5,
|
prevy = 0,
|
||||||
turn = math.random(),
|
turn = 0,
|
||||||
swim = 0,
|
swim = 0,
|
||||||
angle = 0,
|
angle = 0,
|
||||||
xspeed = 0,
|
xspeed = 0,
|
||||||
|
|
138
main.lua
|
@ -10,45 +10,12 @@ bench = require 'lib.benchmark'
|
||||||
sprites = {}
|
sprites = {}
|
||||||
sound_path = {}
|
sound_path = {}
|
||||||
music_path = {}
|
music_path = {}
|
||||||
fonts = {}
|
|
||||||
|
|
||||||
debug = false
|
debug = false
|
||||||
|
|
||||||
food = {}
|
food = {}
|
||||||
feesh = {}
|
feesh = {}
|
||||||
|
|
||||||
footerbuttons = {
|
|
||||||
{
|
|
||||||
cost = 100,
|
|
||||||
sprite = 'guppy',
|
|
||||||
openanim = 1,
|
|
||||||
open = true,
|
|
||||||
func = function()
|
|
||||||
table.insert(feesh, constr.fish(math.random(), 0.3))
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cost = 200,
|
|
||||||
sprite = 'food',
|
|
||||||
tier = 1,
|
|
||||||
openanim = 1,
|
|
||||||
open = true,
|
|
||||||
func = function()
|
|
||||||
--table.insert(feesh, constr.fish(math.random(), 0.3))
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
cost = 300,
|
|
||||||
sprite = 'foodcount',
|
|
||||||
tier = 3,
|
|
||||||
openanim = 1,
|
|
||||||
open = true,
|
|
||||||
func = function()
|
|
||||||
--table.insert(feesh, constr.fish(math.random(), 0.3))
|
|
||||||
end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local sheets = {}
|
local sheets = {}
|
||||||
|
|
||||||
local function newAnimation(image, width, height)
|
local function newAnimation(image, width, height)
|
||||||
|
@ -84,18 +51,10 @@ function love.load()
|
||||||
sheets.waveside = newAnimation(sprites['wave/waveside'], sprites['wave/waveside']:getWidth(), sprites['wave/waveside']:getHeight()/12)
|
sheets.waveside = newAnimation(sprites['wave/waveside'], sprites['wave/waveside']:getWidth(), sprites['wave/waveside']:getHeight()/12)
|
||||||
|
|
||||||
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.food3 = newAnimation(sprites['food/3'], sprites['food/3']:getWidth()/10, sprites['food/3']:getHeight())
|
|
||||||
|
|
||||||
sheets.buttonopen = newAnimation(sprites['footer/button_open'], sprites['footer/button_open']:getWidth()/3, sprites['footer/button_open']:getHeight())
|
|
||||||
|
|
||||||
for i = 1, 3 do
|
for i = 1, 3 do
|
||||||
table.insert(feesh, constr.fish(math.random(), math.random()))
|
table.insert(feesh, constr.fish(math.random(), math.random()))
|
||||||
end
|
end
|
||||||
|
|
||||||
fonts.pix = love.graphics.newFont('assets/fonts/pix.ttf', 6)
|
|
||||||
fonts.continuum = love.graphics.newFont('assets/fonts/cont.ttf', 14)
|
|
||||||
fonts.default = love.graphics.newFont(12)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local frame = 0
|
local frame = 0
|
||||||
|
@ -293,7 +252,7 @@ function love.update(dt)
|
||||||
n.render.turn = n.render.turn + dt * math.sign(n.render.x - n.render.prevx) * 2
|
n.render.turn = n.render.turn + dt * math.sign(n.render.x - n.render.prevx) * 2
|
||||||
n.render.turn = clamp(n.render.turn, 0, 1)
|
n.render.turn = clamp(n.render.turn, 0, 1)
|
||||||
if n.render.turn == 0 or n.render.turn == 1 then
|
if n.render.turn == 0 or n.render.turn == 1 then
|
||||||
n.render.swim = (n.render.swim + dt * math.abs(n.render.xspeed) * 300) % 1
|
n.render.swim = (n.render.swim + dt * math.abs(n.render.xspeed) * 100) % 1
|
||||||
else
|
else
|
||||||
n.render.swim = 0
|
n.render.swim = 0
|
||||||
end
|
end
|
||||||
|
@ -330,7 +289,6 @@ function love.update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
love.graphics.setFont(fonts.default)
|
|
||||||
bench.startBenchmark('render')
|
bench.startBenchmark('render')
|
||||||
|
|
||||||
bench.startBenchmark('render_tank')
|
bench.startBenchmark('render_tank')
|
||||||
|
@ -372,9 +330,7 @@ function love.draw()
|
||||||
bench.startBenchmark('render_shadow')
|
bench.startBenchmark('render_shadow')
|
||||||
for i, n in ipairs(feesh) do
|
for i, n in ipairs(feesh) do
|
||||||
love.graphics.setColor(1, 1, 1, n.render.y + 0.2 - n.render.deathanim)
|
love.graphics.setColor(1, 1, 1, n.render.y + 0.2 - n.render.deathanim)
|
||||||
local sizes = {0.55, 0.7, 1}
|
love.graphics.draw(sprites['shadow'], n.render.x * sw - (sprites['shadow']:getWidth() * spritescale)/2, sh - sh * 0.18 - (sprites['shadow']:getHeight() * spritescale)/2 + n.render.y * sh * 0.08, 0, spritescale, spritescale)
|
||||||
local size = sizes[n.size + 1] or 1
|
|
||||||
love.graphics.draw(sprites['shadow'], n.render.x * sw - (sprites['shadow']:getWidth() * spritescale * size)/2, sh - sh * 0.18 - (sprites['shadow']:getHeight() * spritescale * size)/2 + n.render.y * sh * 0.08, 0, spritescale * size, spritescale * size)
|
|
||||||
end
|
end
|
||||||
bench.stopBenchmark('render_shadow')
|
bench.stopBenchmark('render_shadow')
|
||||||
-- all the fish
|
-- all the fish
|
||||||
|
@ -524,72 +480,23 @@ function love.draw()
|
||||||
|
|
||||||
-- 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
|
|
||||||
for b = 1, 7 do
|
for b = 1, 7 do
|
||||||
local hovered = mouseOverBox(x * size, y * size, sprites['footer/buttonbg']:getWidth() * size, sprites['footer/buttonbg']:getHeight() * size)
|
local hovered = mouseOverBox(x, 3, sprites['footer/buttonbg']:getWidth(), sprites['footer/buttonbg']:getHeight())
|
||||||
local btn = footerbuttons[b]
|
|
||||||
|
|
||||||
if (btn and not btn.open) or not btn then
|
if hovered and love.mouse.isDown(1) then
|
||||||
-- draw nothing
|
love.graphics.draw(sprites['footer/buttonbg_down'], x, 3)
|
||||||
elseif hovered and love.mouse.isDown(1) then
|
|
||||||
love.graphics.draw(sprites['footer/buttonbg_down'], x * size, y * size, 0, size, size)
|
|
||||||
elseif hovered then
|
elseif hovered then
|
||||||
love.graphics.draw(sprites['footer/buttonbg_hover'], x * size, y * size, 0, size, size)
|
love.graphics.draw(sprites['footer/buttonbg_hover'], x, 3)
|
||||||
else
|
else
|
||||||
love.graphics.draw(sprites['footer/buttonbg'], x * size, y * size, 0, size, size)
|
love.graphics.draw(sprites['footer/buttonbg'], x, 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
if btn and btn.open then
|
-- insert sprite of item here
|
||||||
-- sprite inside
|
-- insert price of item here
|
||||||
if btn.sprite == 'guppy' then
|
|
||||||
local sheet = fishsprite('medium', false, 'swim')
|
|
||||||
local frame = math.floor((love.timer.getTime() * 2) % 1 * #sheet.quads) + 1
|
|
||||||
local scale = (sprites['footer/buttonbg']:getWidth() / sheet.width) * 0.9
|
|
||||||
local offset = (sprites['footer/buttonbg']:getWidth() * size) / 2
|
|
||||||
love.graphics.draw(sheet.spriteSheet, sheet.quads[frame], x * size + offset, y * size + offset*0.75, 0, size * scale, size * scale, sheet.width/2, sheet.width/2)
|
|
||||||
elseif btn.sprite == 'food' then
|
|
||||||
local sheets = {sheets.food2, sheets.food3}
|
|
||||||
local sheet = sheets[btn.tier]
|
|
||||||
|
|
||||||
local scale = (sprites['footer/buttonbg']:getWidth() / sheet.width) * 0.65
|
|
||||||
local offset = (sprites['footer/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)
|
|
||||||
elseif btn.sprite == 'foodcount' then
|
|
||||||
love.graphics.setFont(fonts.continuum)
|
|
||||||
local offset = (sprites['footer/buttonbg']:getWidth() * size) / 2
|
|
||||||
|
|
||||||
local bordersize = 1
|
|
||||||
for _,p in ipairs({{0, 1}, {1, 0}, {1, 1}, {-1, 0}, {0, -1}, {-1, -1}, {1, -1}, {-1, 1}}) do
|
|
||||||
love.graphics.setColor(0, 0, 0, 0.5)
|
|
||||||
love.graphics.printf(btn.tier + 1, round(x * size) + p[1] * bordersize, round(y * size + offset*0.75 - fonts.continuum:getHeight()/2) + p[2] * bordersize, round(sprites['footer/buttonbg']:getWidth() * size), 'center')
|
|
||||||
end
|
|
||||||
|
|
||||||
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['footer/buttonbg']:getWidth() * size), 'center')
|
|
||||||
end
|
|
||||||
|
|
||||||
-- price
|
|
||||||
love.graphics.setFont(fonts.pix)
|
|
||||||
local font = love.graphics.getFont()
|
|
||||||
love.graphics.setColor(0, 1, 0)
|
|
||||||
love.graphics.printf('$' .. btn.cost, round(x * size), round(y * size + 51 * size - font:getHeight()/2), round(sprites['footer/buttonbg']:getWidth() * size), 'center')
|
|
||||||
love.graphics.setColor(1, 1, 1)
|
|
||||||
love.graphics.setFont(fonts.default)
|
|
||||||
|
|
||||||
-- reflection
|
|
||||||
love.graphics.setBlendMode('add')
|
love.graphics.setBlendMode('add')
|
||||||
love.graphics.draw(sprites['footer/reflection'], x * size, y * size, 0, size, size)
|
love.graphics.draw(sprites['footer/reflection'], x, 3)
|
||||||
love.graphics.setBlendMode('alpha')
|
love.graphics.setBlendMode('alpha')
|
||||||
|
-- insert closing/opening animation here
|
||||||
-- open/close anim
|
|
||||||
if (btn and not btn.openanim == 1) then
|
|
||||||
local sheet = sheets.buttonopen
|
|
||||||
local anim = 0
|
|
||||||
if btn then anim = btn.openanim end
|
|
||||||
local frame = math.floor(anim % 1 * #sheet.quads) + 1
|
|
||||||
love.graphics.draw(sheet.spriteSheet, sheet.quads[frame], x * size, y * size, 0, size, size)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local incr = 69 -- its like button positions but forcefully shoved into a recursive function :D
|
local incr = 69 -- its like button positions but forcefully shoved into a recursive function :D
|
||||||
if b == 2 then incr = 57 end
|
if b == 2 then incr = 57 end
|
||||||
|
@ -611,29 +518,6 @@ function love.mousepressed(x, y, b)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.mousereleased(x, y, b)
|
|
||||||
local footerheight = FOOTER_HEIGHT * love.graphics.getWidth()/640
|
|
||||||
local size = footerheight / FOOTER_HEIGHT
|
|
||||||
|
|
||||||
if b == 1 then
|
|
||||||
local x = 19
|
|
||||||
for i = 1, 7 do
|
|
||||||
local hovered = mouseOverBox(x * size, 3 * size, sprites['footer/buttonbg']:getWidth() * size, sprites['footer/buttonbg']:getHeight() * size)
|
|
||||||
|
|
||||||
if hovered then
|
|
||||||
if footerbuttons[i] and footerbuttons[i].open then
|
|
||||||
footerbuttons[i].func()
|
|
||||||
end
|
|
||||||
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
|
|
||||||
end
|
|
||||||
|
|
||||||
function love.keypressed(key)
|
function love.keypressed(key)
|
||||||
if key == 'f3' then
|
if key == 'f3' then
|
||||||
debug = not debug
|
debug = not debug
|
||||||
|
|