diff --git a/vacation.p8 b/vacation.p8 index 7e1e02f..9725293 100644 --- a/vacation.p8 +++ b/vacation.p8 @@ -482,6 +482,76 @@ function fuzzy_stripey:draw() end end + +--@musurca & @felice +function cminskycirc(r,c) + local j,k,rat=r,0,1/r + poke(0x5f25,c) --set color + for i=1,r*0.785 do + k-=rat*j + j+=rat*k + pset(63.5+j,63.5+k) + pset(63.5+j,63.5-k) + pset(63.5-j,63.5+k) + pset(63.5-j,63.5-k) + pset(63.5+k,63.5+j) + pset(63.5+k,63.5-j) + pset(63.5-k,63.5+j) + pset(63.5-k,63.5-j) + end + pset(63.5,63.5-r) + pset(63.5,63.5+r) + pset(63.5-r,63.5) + pset(63.5+r,63.5) +end + +breather = { + colors = {1,2,4,2,1}, + sep = 5, + speed=240, + f=0, +} +mknew(breather) + +function breather:update() + local f = self.f + 1 + if (not self.on) f = 0 + if (f >= self.speed) f = -self.speed + if f == 0 and self.nextspeed then + self.speed = self.nextspeed + self.nextspeed = nil + end + self.f = f +end + +function easeinout(t) + if(t<.5) then + return t*t*t*4 + else + t-=1 + return 1-t*t*t*-4 + end +end + +function breather:draw() + fillp(0) + local cols, f, spd, sep = self.colors, self.f, self.speed, self.sep + local stall = sep * (#cols - 1) + local cap = spd-stall + if (f >= 0) f += stall + for i,c in ipairs(cols) do + local ef = f - (i-1)*sep + ef = abs(ef) - stall + if ef <= cap and ef > 0 then + cminskycirc(easeinout(ef/cap)<<6,c) + end + end +end + +function breather:starting_reverse() + return self.f + self.speed < self.sep * #self.colors +end + -->8 -- awakener @@ -1027,7 +1097,11 @@ function start_game() f = function() pal() clear_alt_pal_bits() - return view.of{bg.new(), fuzzy_stripey.new{interval=7, tries=5}} + return view.of{ + bg.new(), + fuzzy_stripey.new{interval=7, tries=5}, + breather.new{on=true}, + } end, }, }