From 0cf9e962b6798a604f2d8bf6de111d92344f14c2 Mon Sep 17 00:00:00 2001 From: jill Date: Mon, 25 Jan 2021 21:05:06 +0300 Subject: [PATCH] star fish --- assets/audio/sfx/explode.ogg | Bin 0 -> 5036 bytes assets/sprites/header/moneyflash.png | Bin 0 -> 807 bytes assets/sprites/header/optionsbutton_down.png | Bin 0 -> 2597 bytes assets/sprites/header/optionsbutton_hover.png | Bin 0 -> 2483 bytes constructors.lua | 3 +- scenes/gameplay/draw/fish.lua | 17 ++++- scenes/gameplay/draw/food.lua | 14 +++- scenes/gameplay/draw/header.lua | 12 +++- scenes/gameplay/main.lua | 45 ++++++++++--- scenes/gameplay/update/fish.lua | 60 ++++++++++-------- 10 files changed, 110 insertions(+), 41 deletions(-) create mode 100644 assets/audio/sfx/explode.ogg create mode 100644 assets/sprites/header/moneyflash.png create mode 100644 assets/sprites/header/optionsbutton_down.png create mode 100644 assets/sprites/header/optionsbutton_hover.png diff --git a/assets/audio/sfx/explode.ogg b/assets/audio/sfx/explode.ogg new file mode 100644 index 0000000000000000000000000000000000000000..80b4caad3e1935c3836475f7c87976e6ccd00acf GIT binary patch literal 5036 zcmcIndpMJQ_0poXoQt-T)1Hr3BPZ_vLV{g#@fc(daJdqp(&Oanm`~$ha0*_A0x%ZL{o^- z@d$-UE%0{tarJd`$8HBzsnMZfq$na}(QnIIF0T8)Sr9-2s|`0^>yII*uYR{4DgnZ;KJ%R{_DI!Rb;5;lAT}p-7hZ%=z+wT&L;FGQG^U7RIo0>)$ z7+*6jqecaI0RXTJc;*1QE!#gEZGs4BL#dVisfqfe9V*5O>G-TYqHKQ+eR0X&V#FEIcLFz*;Eb8VtCvY^b12b5eiX6^TL?2 z8}iZWmU+_kvYRv?j0vM*HTGo%P3mI42mn;Jfp?%JPzC_dbJ9Z4ls` z5$OhlR2D(HVS2K%idAOHVtqPMIeNX4b+U}fs$}swOcp2VL@`N$79&_JkR`KN@{6p< zmzCAMyipc!ytO|1etk_}F{_owkKJ0&A%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WxnGHWl>C;Nhshud^ zM9~P@;mAe?$qMYB8l=RRe7s+VI8A?TKsU;Sm<06Yyn}VlEDdrOp}OK4lkXWdGY$}Q LS4wurJy`TVlfxN* literal 0 HcmV?d00001 diff --git a/assets/sprites/header/moneyflash.png b/assets/sprites/header/moneyflash.png new file mode 100644 index 0000000000000000000000000000000000000000..f6e262a7eb6e4c75c09a700439bd8d442ab97be9 GIT binary patch literal 807 zcmV+?1K9kDP)1DYb%Cm*h5Sg(M9(DNlIVHAUiV@hVWwUADy&@p}2PD1~y5jMh;DX0rf_XNx2>3-$snEho3$r3Oh^L9ehF)fk^N5=SRdZ#T z@))gg*vKG>1SBXZV-q?YL@Apzv-ZAN-M54ic^LgIRKUqmK#{x=Qp?m;rL2*z(x;;$ z=Kg=4wl)*@x(5?L_p9rEP5?doK&|S!zo)KSI|BkQz_r=*muOCN-=tTYTKE_U?EsfI zO-(rfu6BWuXG`XCT?)|hYZ~xz0Sx4Tp?jcj-J4ZoALma%cAK8)4mdmlCaFHO@dqgt zXdPuIoU#A_010qNS#tmY3labT3lag+-G2N400CP`L_t(o!|m8TOT$1M$MIic6b&Lu zQ3R7dPzN6dZM#^U1i|7W=q8HJU3?|tYjDt);3iRU)KVOZLyL`xv`J0Dp;bW|dx8Qxn@6wZMajZH@Y)hITOC{2)30xR+nQApukN9kgqQ| z#C~HT)jaFez%Jj1E+vDNr8x+mDjU?-I=&Y%ahZj1(Oa!QawPJNQg>AxooL{RqP4C^ zWx{JG!XrGwBRs;R2#@dxkMJnMYcbt+XUV+>urul_p7(-kj`j|YwJ_W7UP%$)=S4ST z&V6V3z(B+-Av7HTAA1zR>1YhK2%(~el;HcYxKr8E{{Uns lE?Pfv8;Kw);xh^b6E8iKcLb_Ub!Pwo002ovPDHLkV1i1KVw3;? literal 0 HcmV?d00001 diff --git a/assets/sprites/header/optionsbutton_down.png b/assets/sprites/header/optionsbutton_down.png new file mode 100644 index 0000000000000000000000000000000000000000..533ac1e6b312a5d653795bc48627896a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&tiIRe+%`^j8NHF4~9_~<8261<^79^ zBK$N4^)w)jFbrmxX`#PR(#a>-$mBsSwpnQT-s4r5NR zz92X}dARNN9X7tg!7U;t1KKN#>Lk|06jbvm#* zoPpi`-zRY1&#TS&NNJjfOA-!EQ&2~bMw;4g_Nd~Gt9$|I$Kyd`o93AXr`)qJh-;{@ z%I~FomzRzdfdzvsgq|%YuU`&JFYco6W6esSvB-D?U{sOv3S%EHwo*`E-Kd5{EUDf9 zIi2{SM88whEh_!py+93#!+R+`_@yNUDcsJ`tMUu;GbC)h#5mL4h?F%l30yiD*}^jl z6d8{oiJzV82GRE35;KoKJM(i{IxXe?h*NS_hW_lirRVIL=K**Je8vHZ!*jSKI{T&j zj(_6ecM6*!`$F>KtTTGXQ=H5HQRQbWn4X$Tb7KSKAI+tQ84zclt~w3s@Jm)15{4Ja z0ow44tmRUA%(E{x25p*!B{L9+Q5l)FAHVs8d#Um}AbH~^LrI9D5&?2PHXc>3+DFgU zTF-CoVFBH!w@wk&Vw4Ex9gOB_ohtW^oA*N3Ew3DO2!WmAYk#7BmXrK*YG%6b9+jdt z)@y*_^&kk5_E%=pcdy@~yuXMV7k$8)=dQ^PPL3!?OeEI4$`F&1#V{dRf{wcE}Wpa#B zXs6Ke$pj@4u7niy?BKBk1;}?c#E^eV7T5ihXT2TNIxU@7I14WAphLEGT*{Q>xDqs(;YtXAEfCoC_Ni~Fy0%#}28!gY z$QK!~Crl*mr=Wr8GTVYjDECv$ zF8e78qR#RaJtHQ&t@T=ok{HzbK?)8$Kvaxl6VvGLKgxL9kFas{J9pIKAWsJ5DSA_k}-CTc7_YjAR4+X4l^{ucXp-UTy#Y002ovPDHLkV1l{urFj4V literal 0 HcmV?d00001 diff --git a/constructors.lua b/constructors.lua index 500b5cf..b6e5ca9 100644 --- a/constructors.lua +++ b/constructors.lua @@ -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 diff --git a/scenes/gameplay/draw/fish.lua b/scenes/gameplay/draw/fish.lua index 7e2ef5e..fe6724c 100644 --- a/scenes/gameplay/draw/fish.lua +++ b/scenes/gameplay/draw/fish.lua @@ -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 diff --git a/scenes/gameplay/draw/food.lua b/scenes/gameplay/draw/food.lua index 99d0a2e..e79e074 100644 --- a/scenes/gameplay/draw/food.lua +++ b/scenes/gameplay/draw/food.lua @@ -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 \ No newline at end of file diff --git a/scenes/gameplay/draw/header.lua b/scenes/gameplay/draw/header.lua index 07c4e09..972d02c 100644 --- a/scenes/gameplay/draw/header.lua +++ b/scenes/gameplay/draw/header.lua @@ -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)) diff --git a/scenes/gameplay/main.lua b/scenes/gameplay/main.lua index 1c00aa2..c776d49 100644 --- a/scenes/gameplay/main.lua +++ b/scenes/gameplay/main.lua @@ -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 diff --git a/scenes/gameplay/update/fish.lua b/scenes/gameplay/update/fish.lua index c0110f3..3aa7407 100644 --- a/scenes/gameplay/update/fish.lua +++ b/scenes/gameplay/update/fish.lua @@ -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