Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int rectX = 100;
- int rectY = 300;
- int rectSize = 200;
- void setup(){
- size(800,800);
- }
- void draw() {
- if (collisionRect()){
- fill(255);
- println("Estou no quadrado");
- }else{
- fill(0);
- }
- smooth();
- strokeWeight(12);
- strokeJoin(ROUND);
- rect(rectX,rectY,rectSize,rectSize);
- }
- boolean collisionRect(){
- if(((mouseX >= rectX) && (mouseX <= rectX + rectSize) && ((mouseY >= rectY) && (mouseY <= rectY + rectSize)))){
- return true;
- }
- return false;
- }
- int dist2D(int p1X,int p1Y,int p2X,int p2Y){
- return round(sqrt( pow( abs(p1X - p2X) , 2 ) + pow( abs(p1Y - p2Y) , 2 ) ) );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement