Index / 2016 / Q02 Mission 04
400×400 · p5.js instance mode
Q02_mission_04.pde 35 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);
}

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/ICS2O_Nguyen,Vincent_Q-07 Processing 02/Q02_mission_04/Q02_mission_04.pde

Description

This page is generated from the Processing project folder at /2016/QUIZZES/Q-07 Processing 2/ICS2O_Nguyen,Vincent_Q-07 Processing 02/Q02_mission_04/Q02_mission_04.pde.

Archive

No companion assets were found in this sketch folder.