Trying to figure out how to intersect an image with and ellipse
in
Programming Questions
•
10 months ago
Hello guys I'm working on exercise 10-10 and trying to convert its intersection Boolean to work with and image
now the math is checking for the radius between two circles but I'm working with a circle and an image
this is the example they have in the book
now the math is checking for the radius between two circles but I'm working with a circle and an image
this is the example they have in the book
- / A function that returns true or false based if the catcher intersects a raindrop
boolean intersect(Drop d) {
- float distance = dist(x,y,d.x,d.y); // Calculate distance
return true;
} else {
return false;
}
}
- class Catcher{
//Global Variables
//------------------\\
float catcherX; //x postion of player
float catcherY; //y postion of player
float cSpeed; //players speed
PImage Catcher_1; //Glove or Bucket
float catcherW; // catcher width
//------------------\\
Catcher(){
Catcher_1 = loadImage("glove.png");
catcherX = 500;
catcherY = 600;
cSpeed = 5;
catcherW = width;
}
void display(){
image(Catcher_1,catcherX,catcherY,catcherW);
}
//A functiong that returns a true or false based if the catcher intersect
boolean intersect(Drop d){
float distance = dist(x,y,d.x,d.y); //calculate distance
if (distance < r + d.r){
return true;
}
else{
return false;
}
}
void moveRight(){
catcherX = catcherX + cSpeed;
}
void moveLeft(){
catcherX = catcherX - cSpeed;
}
void moveUp(){
catcherY = catcherY - cSpeed;
}
void moveDown(){
catcherY = catcherY + cSpeed;
}
}
1