Tut­o­r­i­a­l week 12

by Brittany Klaassens

keystrokes

  • Show Sketch
/** @peep sketchcode */
float x = 10, y = 10;
 
void setup() {
  size(400, 400);
  background(0);
}
 
void draw() {
  noStroke();
  fill(0, 12);
  rect(0, 0, width, height);
  fill(255);
  ellipse(width/2, height/2, x, y);
  if(keyPressed == true) {
    if(key == 'd') {x -= random(5, 10);}
    if(key == 'f') {x += random(5, 10);}
    if(key == 'g') {y += random(5, 10);}
    if(key == 'h') {y -= random(5, 10);}
    if(key == 'j') {background(0);}
  }
  x = constrain(x, 0, width);
  y = constrain(y, 0, height);
  translate(width/2+x, height/2+y);
}

Comments

Nobody has said anything yet.