Changes

Jump to: navigation, search

FSOSS 2010/processing.js/vector ex

959 bytes added, 08:22, 28 October 2010
Created page with '<source lang="JavaScript"> FSOSS 2010 Andor Salga Collision Detection - Add the appropriate code wherever you see !!!: // !!! create two PVector references to circle …'
<source lang="JavaScript">
/*
FSOSS 2010
Andor Salga
Collision Detection - Add the appropriate code wherever you see !!!
*/

// !!! create two PVector references to circle positions

int circleSize = 30;

void setup(){
size(200, 200);

// !!! instantiate circle positions across from one another
}

void draw(){
background(200);

// !!! move the positions towards each other

// !!! reset the positions if they go past the screen

// change fill color if they collided
if(collided(circle1, circle2)){
fill(33, 66, 99, 150);
}
else{
fill(99, 33, 66);
}

// !!! draw two circles using the positions and diameter of circleSize
}

boolean collided(PVector p1, PVector p2){

// !!! subtract the vectors

// if the magnitude of the result is less
// than the size of the ball, change color
if( /*!!!*/ ){
return true;
}
else{
return false;
}
}
</source>
[http://studio.sketchpad.cc/u22BTCNJEi Answer]
1
edit

Navigation menu