Index / 2016 / Q02 Mission 05
400×400 · p5.js instance mode
Q02_mission_05.pde 39 lines
int x = 100;
int y = 100;

void setup() {
  size(400, 400);
  background(255, 240, 240); 
  rect(x, y, 40, 40);
}

void draw() {
  fill(255, 0, 0);
  rect(x, y, 40, 40);

  // fill(255, 240, 240, 50); Prevous code that redrew a transparent rectangle to create a trail effect
  fill(255, 240, 240, 25); // To make the trail longer, we increase the transparency so it needs to redraw more times to clean up the trail
  rect(0, 0, 400, 400);
  
  // 5. The program creates a comet trail by adding a transparent layer
  // that frequently redraws itself to convey the illusion of the previous
  // squares slowly disappearing into the background.
}

void keyPressed() {
  if (keyCode == RIGHT) {
    x = x + 10;
  }

  if (keyCode == DOWN) {
    y = y + 10;
  }

  if (keyCode == LEFT) {
    x = x - 10;
  }

  if (keyCode == UP) {
    y = y - 10;
  }
}
read-only archive source from /2016/QUIZZES/Q-07 Processing 2/Q02_mission_05/Q02_mission_05.pde

Description

This page is generated from the Processing project folder at /2016/QUIZZES/Q-07 Processing 2/Q02_mission_05/Q02_mission_05.pde.

Archive

No companion assets were found in this sketch folder.