IA_PathFinder/Obstacle.pde
2022-05-07 15:08:13 +03:00

26 lines
527 B
Plaintext

class Obstacle{
PVector c1;
PVector c2;
//constructor
Obstacle(int x1, int y1, int x2, int y2){
c1=new PVector(x1, y1);
c2=new PVector(x2, y2);
}
//check intersection with a dot
boolean isIntersecting(Dot dot){
if(dot.pos.x >= c1.x && dot.pos.x <= c2.x && dot.pos.y >= c1.y && dot.pos.y <= c2.y){
return true;
}
else{
return false;
}
}
//display it
void display(){
fill(255, 255, 0);
rect(c1.x, c1.y, c2.x-c1.x, c2.y-c1.y);
}
}