We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am currently trying to program a game but have encountered a large problem. I have scoured the forums to try and find a previous discussion about how to code collision with shapes, but I have not found any guides on how to code collision for a shape that uses curveVertex. I have included only relevant code to show what I am doing.
void setup(){
size(500,500);
}
void draw(){
background(51);
fill(245,30,30);
stroke(255);
beginShape();
for (int x=-10;x<width+11;x+=10){
float n = noise(x*0.004);
float y = map(n,0,1,150,height-150);
curveVertex(x,y);
}
curveVertex(width+11,height+11);
curveVertex(-10,height+11);
curveVertex(-10,height+11);
endShape();
}
If anyone can show me what to do for collision, I can figure out the rest.
Answers
You'll have to use the
curvePoint()
function to get the points along the curve, then use those points to create a polygon, then use that polygon for collision detection.