From 57fa26dfb7646112f1373eae37a714171703d662 Mon Sep 17 00:00:00 2001 From: jill Date: Mon, 25 Jan 2021 17:48:31 +0300 Subject: [PATCH] carnivore --- assets/audio/sfx/chomp.ogg | Bin 0 -> 3936 bytes .../fish/{biig_die.png => carnivore_die.png} | Bin .../fish/{biig_eat.png => carnivore_eat.png} | Bin ...ungry_eat.png => carnivore_hungry_eat.png} | Bin ...gry_swim.png => carnivore_hungry_swim.png} | Bin ...gry_turn.png => carnivore_hungry_turn.png} | Bin .../{biig_swim.png => carnivore_swim.png} | Bin .../{biig_turn.png => carnivore_turn.png} | Bin const.lua | 1 + constructors.lua | 5 +- scenes/gameplay/draw/fish.lua | 2 + scenes/gameplay/draw/money.lua | 6 +- scenes/gameplay/main.lua | 37 ++++++-- scenes/gameplay/update/fish.lua | 83 ++++++++++++++---- 14 files changed, 106 insertions(+), 28 deletions(-) create mode 100644 assets/audio/sfx/chomp.ogg rename assets/sprites/fish/{biig_die.png => carnivore_die.png} (100%) rename assets/sprites/fish/{biig_eat.png => carnivore_eat.png} (100%) rename assets/sprites/fish/{biig_hungry_eat.png => carnivore_hungry_eat.png} (100%) rename assets/sprites/fish/{biig_hungry_swim.png => carnivore_hungry_swim.png} (100%) rename assets/sprites/fish/{biig_hungry_turn.png => carnivore_hungry_turn.png} (100%) rename assets/sprites/fish/{biig_swim.png => carnivore_swim.png} (100%) rename assets/sprites/fish/{biig_turn.png => carnivore_turn.png} (100%) diff --git a/assets/audio/sfx/chomp.ogg b/assets/audio/sfx/chomp.ogg new file mode 100644 index 0000000000000000000000000000000000000000..e10f11ff78cc55d5001f45da0c9c80ac571d2619 GIT binary patch literal 3936 zcmcImc~n!!_kY2K04X9xzo@7Qg_3|Ep`eCVWL5HliVqM>6ly}mET9rW5uqrH3IP#A z#9bso6G#+lqDG}wNKn9t2*DC@SC#-SxYSbQI}dHo`JMCo_dDmjdH3GW%$+-PKX=|+ znUD|xnL%G${J?=VsJJwiU5A;2N!^spQLQ z{B1=a`=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`C+Z` zNSM>SrLl2u(-+#h=@Xbc8@(!jkvuTY-M>tB%br^Ky@jtE@ve38Xv@uA4?q9)0%=|9 z_x{hsL(N66Z`IJ|4b(4xS`_NRi6aj_No~+i5tDXDcITMkcda<(Iu>`4@>gr0+v3mC zl-OZy*sz{%URCH*!rI@xD9(L-W7m+iasK;2Ih+`%lZR$rF@$i z z)Quf4?gtv*XJYvugCgSZBC{zEAHTCYdi4>O>l-N^@QzW%!&=)sr)Q4u`ZEg)UJ%Uw(-(+h`&4p{W{%Z=U* z4b6RL{`@0Mu*5U0*~;3=D&x_<^58|r&s$nfpUWpd9A53`aOTJ=vlBc&Lp21&O|X#_ zR531Iz4VT5?J{z0lj&Ik{os-XFYg^(cIXp*WPhmBje--`o(=17Y8+y>7|tu}%&1gq z%f5pXzoojGFJfdmsy~_E?Qd8@YhM4>EmBn8uZz3A?O0T}c^$)kF(`^vUg4|C75qX-4z(1)<- m4R7?X{fmnDXWAPB|4zHOHgDmo)= headerbuttons[i].cost then + if balance >= headerbuttons[i].cost or debug then headerbuttons[i].func(headerbuttons[i]) playSound('buttonclick') balance = balance - headerbuttons[i].cost diff --git a/scenes/gameplay/update/fish.lua b/scenes/gameplay/update/fish.lua index b5437dd..ec612e1 100644 --- a/scenes/gameplay/update/fish.lua +++ b/scenes/gameplay/update/fish.lua @@ -32,26 +32,49 @@ return function(feesh, dt, food, headerbuttons, money) if n.eattimer <= 0 and not n.dead then -- needs to follow something local mx, my if n.eattimer <= 0 then - if n.shortestfood and food[n.shortestfood] then - local f = food[n.shortestfood] - mx, my = f.x, f.y - elseif frame % FISH_FOOD_CHECK_FREQ == 0 then - local minfood = 0 - local mindist = 9e9 + if n.size == 4 then -- carnivore + if n.shortestfood and feesh[n.shortestfood] then + local f = feesh[n.shortestfood] + mx, my = f.x, f.y + elseif frame % FISH_FOOD_CHECK_FREQ == 0 then + local minfood = 0 + local mindist = 9e9 - for i,f in ipairs(food) do - local dist = math.sqrt(math.pow(math.abs(f.x - n.render.x), 2) + math.pow(math.abs(f.y - n.render.y), 2)) - if dist < mindist then - mindist = dist - minfood = i + for i,f in ipairs(feesh) do + if f.size == 0 then + local dist = math.sqrt(math.pow(math.abs(f.render.x - n.render.x), 2) + math.pow(math.abs(f.render.y - n.render.y), 2)) + if dist < mindist then + mindist = dist + minfood = i + end + end + end + + if minfood ~= 0 then + n.shortestfood = minfood end end + else + if n.shortestfood and food[n.shortestfood] then + local f = food[n.shortestfood] + mx, my = f.x, f.y + elseif frame % FISH_FOOD_CHECK_FREQ == 0 then + local minfood = 0 + local mindist = 9e9 - if minfood ~= 0 then - n.shortestfood = minfood + for i,f in ipairs(food) do + local dist = math.sqrt(math.pow(math.abs(f.x - n.render.x), 2) + math.pow(math.abs(f.y - n.render.y), 2)) + if dist < mindist then + mindist = dist + minfood = i + end + end + + if minfood ~= 0 then + n.shortestfood = minfood + end end end - end if mx and my then angle = math.deg(math.atan2(my - n.y, mx - n.x)) + math.random(-FISH_FOLLOW_RANDOM, FISH_FOLLOW_RANDOM) @@ -102,6 +125,8 @@ return function(feesh, dt, food, headerbuttons, money) if n.size > 0 then local type = 2 if n.size == 1 then type = 1 end + if n.size == 3 then type = 3 end + if n.size == 4 then type = 4 end table.insert(money, constr.money(n.render.x, n.render.y, type)) end end @@ -123,13 +148,27 @@ return function(feesh, dt, food, headerbuttons, money) bench.stopBenchmark('update_fish_position') bench.startBenchmark('update_fish_colission') - if n.shortestfood and food[n.shortestfood] and frame % FISH_COLISSION_CHECK_FREQ == 0 then - local f = food[n.shortestfood] - if f then + if n.size == 4 then + if n.shortestfood and feesh[n.shortestfood] and frame % FISH_COLISSION_CHECK_FREQ == 0 and not n.dead then + local f = feesh[n.shortestfood] + local dist = math.abs(n.render.x - f.render.x) + math.abs(n.render.y - f.render.y) + + if dist < FOOD_HITBOX then + playSound('chomp', 1, 1 + math.random() * 0.1 - 0.05) + table.remove(feesh, n.shortestfood) + + n.eattimer = FISH_FOOD_3_COOLDOWN + n.render.eattimer = 0 + n.shortestfood = -1 + end + end + else + if n.shortestfood and food[n.shortestfood] and frame % FISH_COLISSION_CHECK_FREQ == 0 and not n.dead then + local f = food[n.shortestfood] local dist = math.abs(n.render.x - f.x) + math.abs(n.render.y - f.y) if dist < FOOD_HITBOX then - playSound('slurp') + playSound('slurp', 1, 1 + math.random() * 0.1 - 0.05) table.remove(food, n.shortestfood) local cooldowns = {FISH_FOOD_1_COOLDOWN, FISH_FOOD_2_COOLDOWN, FISH_FOOD_3_COOLDOWN} @@ -158,6 +197,14 @@ return function(feesh, dt, food, headerbuttons, money) 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 n.lifetime > FISH_AGE_KING and n.size == 2 then + n.size = 3 + playSound('grow') end end end