top of page
Search

Assignment 10: p5 interactivity

  • Writer: junfeng shao
    junfeng shao
  • Apr 11, 2019
  • 1 min read

var x, y, d;

var r, g, b;


function setup() {

createCanvas(600, 600);

x = 300;

y = 50;

d = 50;

r = 0;

g = 255;

b = 0;

}


function draw() {

noStroke();

fill(r, g, b);

ellipse(mouseX, mouseY, d, d);

}


function keyPressed(){

if(keyCode === UP_ARROW){

d += 25;

}

else if (keyCode === DOWN_ARROW){

if (d >= 50){

d -= 25;

}

}

else if (key === 'q'){

r = 255;

g = 165;

b = 0;

}

else if (key === 'w'){

r = 0;

g = 255;

b = 0;

}

else if (key === 'e'){

r = 255;

g = 0;

b = 0;

}

}


function mousePressed(){

background(255);

}


 
 
 

Recent Posts

See All
Final Project

My final project is a ball game. In the game, there are two ball on the screen. One ball is stationary, the other ball is moving. You can...

 
 
 

Comments


©2019 by jshao. Proudly created with Wix.com

bottom of page