Skip to content

Instantly share code, notes, and snippets.

@lucatronica
Last active September 8, 2020 12:50
Show Gist options
  • Save lucatronica/efb4062d5be453bb5444ea9dcd66b023 to your computer and use it in GitHub Desktop.
Save lucatronica/efb4062d5be453bb5444ea9dcd66b023 to your computer and use it in GitHub Desktop.
-- Set the background color.
pal(0,140,1)
function _update60()
cls()
--Two iterations
-- 0: Splashes
-- 1: Rain
for j=0,1 do
srand(1)
-- Iterate each splash location
for i=0,350 do
-- Get splash location.
x=rnd(160)-16
y=rnd(144)-8
-- Progress through animation. Loops from 0 to 1.
k=(t()/3+rnd())%1
-- This line sets up the fade on the splash.
-- PICO-8 has a neat trick where some glyphs have an associated global
-- variable with the same name.
-- Most of the wide glyphs have fillp pattern values, which mimic the
-- glyph's appearance. That's why we use ▒ and ░ here!
-- Note when k is small then the table lookup will return `nil`, but
-- fillp will treat that as 0!
fillp(({▒,░})[flr(.2+k*20)])
-- Draw the splash!
-- `k<1/8` since the splash should be short.
if (j<1 and k<1/8) k=k*8 w=k*13 h=w/3 oval(x-w,y-h,x+w,y+h,12)
-- Draw the rain!
-- We're basically sucking the droplet into where it should land, using
-- `k=(k-1)*2` to get the distance away from the landing point.
if (j>0) k=(k-1)*2 y=y+k*280 x=x+k*110 line(x-1,y-3,x,y,7)
end
end
end
@gaycodegal
Copy link

add space on line 32: "1and" -> "1 and"

@lucatronica
Copy link
Author

add space on line 32: "1and" -> "1 and"

Fixed cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment