top of page
Search

Assignment 9: p5 animation

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

var x = 500;

var y = 300;

var sqwl = 100;

var xSpeed = 10;

var ySpeed = 5;

var r, g, b;

var triX = 500;

var triY = 50;


function setup() {

createCanvas(1000, 600);

r = 255;

g = 0;

b = 0;

}


function draw() {

background(127);

noStroke();

fill(r, g, b);

ellipse(x, y, sqwl, sqwl);

a

x = x + xSpeed;

y = y + ySpeed;

if (x > (1000 - sqwl/2)){

xSpeed = -xSpeed;

b = 0;

}

else if (x < 0 + sqwl/2){

xSpeed = -xSpeed;

b = 255;

}

if (y > (600 - sqwl/2)){

ySpeed = -ySpeed;

g = 0;

}

else if (y < sqwl/2){

ySpeed = -ySpeed;

g = 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...

 
 
 

Commentaires


©2019 by jshao. Proudly created with Wix.com

bottom of page