<html>
  <head></head>
</html>
function setup(){
  createCanvas(500, 1024);
}

function draw(){ 
  // draw background every frame
  background(0, 100, 100);
  
  // Draw robot head
  stroke(0);
  fill(50);
  rect(100,100, 100, 120);
  
  // Draw robot eyes
  fill(random(255), random(255), 0);
  stroke(255,0,0);
  rect(110, 120, 20, 10);
  rect(170, 120, 20, 10);
  stroke(0);  
  
  // draw nose
  fill(255, 0, 0);  
  triangle(150, 140, 140, 150, 160, 150)
  
  // draw mouth
  fill(255);    
  rect(110, 170, 80, 10);  
  
  // draw body
  fill(60);
  ellipse(150, 440, 150, 440);
  
  // draw gun
  rect(220, 400, 100, 10);
  
  // draw laser
  strokeWeight(10);
  stroke(255, 0, 0);
  line(320, 400, width, random(height));
  strokeWeight(1);  
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.js