Green dirt

Just random pattern

rect( 0, 0, w, h, ()=> color( rand(0x44), rand(0x55), rand(0x22) ) );

Dirt with grass

px.frameRate = 24; const grassLayer = px.createLayer(1); const grasses = []; for(let i = 0; i < w*h/32; i++){ let grass = new Point( i * 13 %w, i *666* (sin(i)+13) %h ); grass.direction = -PI/2+rand(360)/360/4; grass.length = 6+rand(10); grass.color = 0x061300 + color(rand(0x44),rand(0x66),rand(0x22)); grasses.push(grass); } const updateGrass = (wind = 0)=>{ grassLayer.clear(); grasses.forEach((grass, n)=> grassLayer.line(grass, grass.addClone( new Point(grass.length, 0) .rotate(grass.direction+wind*(sin(n*18)+1)/2) ), grass.color) ) }; updateGrass() update = (dt, t)=>{ updateGrass((sin(t)**2+1)/3); }

Pixelart part

Hey, that dirt and grass are not pixelart, they are just random noise and sticks drawn point by point. So, let's recreate it in the right way.

Four colored dirt

Made rect take function as color, so now it is that easy:

const dirtColors = [ 0x2b0507, 0x1a2706, 0x3d140f, 0x141313 ]; rect(0, 0, w, h, () => rand(dirtColors));

Two colored grass

px.frameRate = 10; const grassColors = [0x0a3715, 0x28421b], grassLayer = px.createLayer(1), initGrasses = (count, length, top = 0) => { for(let i = 0; i < count; i++){ let grass = new Point( rand(w), length + rand(h-length-top) + top ); grass.direction = rand(6)-2; grass.length = length+rand(length); grass.color = rand(grassColors); grasses.push(grass); } /* far grass should be drawn first, so I sort grasses by distance */ grasses.sort((a,b)=>a.y-b.y); }; let grasses = []; initGrasses(1, 10); grasses[0].length = 14; grasses[0].x = w/2-3; grasses[0].y = h-2; grasses[0].direction = 2; grasses[0].color = grassColors[1] const updateGrass = (wind = 0) => { grassLayer.clear(); const point = new Point(); grasses.forEach((plant, n) => { // set point x and y to plants x and y point.borrow(plant); let angle = -PI/2; for(let l = 0, _l = plant.length; l < _l; l++){ // added Point method. It takes Point as argument and draw point grassLayer.Point(point, plant.color); grassLayer.point(point.x+1, point.y, 0x1b1c06); point.add(cos(angle), sin(angle)); angle += (plant.direction+wind*cos(n))/40; } }) }; updateGrass() update = (dt, t)=>{ updateGrass((sin(t)**2+1)); }

Field of grass

initGrasses(w*h/24, 7); update = (dt, t)=>{ updateGrass((sin(t)**2+1)); }

And the sky

clear(); rect(0, h/2, w, h/2, () => rand(dirtColors)); const center = new Point(w/2, h/2), p = new Point(); rect(0, 0, w, h/2, (x, y)=> dither( center.distance(p.set(x,y))/w*1.5, 0x000000, 0x201050 )); grasses.pop(); initGrasses(w*h/24, 7, h/2); update = (dt, t)=>{ updateGrass((sin(t)**2+1)); }

Log

const woodColors = [0x773333, 0x884455,0x661122]; const drawLog = (x, y, r)=>{ let lastColor, PI2 = 2*PI; for(let i = 0; i < r; i++){ let color; do{ color = rand(woodColors); }while(color === lastColor); lastColor = color; let count = floor(2*PI*i)*2; for(let a = 0; a < PI2; a+=PI2/count){ point(round(x+cos(a)*i), round(y+sin(a)*i), color); } } } drawLog(8,8, 6)