Last active
October 17, 2020 23:31
-
-
Save lucatronica/d0382f2fc00bb194903d798d159872e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pal({130,2,136,8,142,135},1) | |
function _draw() | |
cls(5) | |
srand(0x2152) | |
local f=t() | |
--sun | |
circfill(110,18,4,6) | |
--iterate 4 hillsides | |
for n=0,3 do | |
--width of hillside | |
local w=137+n*60 | |
--probability of tree per pixel | |
local tree_p=({0.25,0.15,0.1,0.035})[1+n] | |
for x=1,w do | |
local u=flr((x-f*(6+n*6))%w-9) | |
local r1=rnd() | |
local r2=rnd(1.2) | |
local r3=rnd() | |
if u<137 then | |
local a=x/w | |
local y=35+n*7+sin(a)*cos(a*3)*(4+n*3) | |
--hill | |
line(u,y,u,72,4-n) | |
--stump | |
if x==15 and n==3 then | |
pal(9,4-n) | |
--a simple 3x8 sprite :) | |
spr(1,u-2,y-8) | |
end | |
--tree | |
if r1<tree_p then | |
local h=(3+n*4)*(.8+r2) | |
local parts=3+r3 | |
for i=0,h do | |
local tx=u+cos(f/2+i/120)*.6 | |
local v=y-i+n | |
local m=(h-i)*.3+((h-i)%(h/parts))*0.32 | |
line(tx-m,v,tx+m,v) | |
end | |
end | |
end | |
end | |
end | |
--reflection | |
for y=72,127 do | |
local dx=(y/4+f*4)%2 | |
for x=0,127 do | |
pset(x,y,pget(min(x+dx,127),144-y)) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment