top of page
Search

Ball Hitting Wall and Changing Color

  • gcafaro6
  • Oct 24, 2019
  • 1 min read

var xPos

var yPos

var xSpeed;

var bSize;

var cColor;

var ySpeed;

var sr,sg,sb;


function setup() {

createCanvas(400, 400);


xPos=50;

yPos=50;

xSpeed=8;

ySpeed=11;

bSize=57;

cColor=(sr,sg,sb);

ccolor=color(255,165,9);

}

function draw() {

background(22);

cColor=color(sr,sg,sb);

fill(cColor);

ellipse(xPos,yPos,bSize, bSize);

xPos=xPos+xSpeed;

if((xPos>(400-bSize/2)) || (xPos < bSize/2)){

xSpeed=-xSpeed;

cColor=color(130,4,4)

fill('aqua');

}

yPos=yPos+ySpeed;

if((yPos>(400-bSize/2)) || (yPos < bSize/2)){

ySpeed=-ySpeed;

cColor=color(250,2,2)

fill('white');

}


Hours spent trying to get the circle to turn colors, I gave up, but then I remembered that with coding each text has to go in order. And that's when I discovered to just use the code fill=(the girl I chose) boucle fill = the color. Over the weekend I'm going to expand more on my project but I wanted to get the homework assignment up and ready for you to see. Thank you.


 
 
 

Recent Posts

See All
My Final Project :)

https://editor.p5js.org/gigimarie13579/full/OqHyrhuf3 var x = []; var y = []; var cSize = []; var cSpeed= []; var rColor= []; var score=...

 
 
 
Homework assignment 13

https://www.wired.com/2014/11/algorithms-great-can-also-ruin-lives/ Who is harmed by this algorithm, and how shall we define that harm?...

 
 
 

Комментарии


Follow

©2019 by GC&A. Proudly created with Wix.com

bottom of page