Results 1 to 2 of 2
  1. #1
    Gwindow is offline Member
    Join Date
    Apr 2008
    Posts
    2
    Rep Power
    0

    Default Rectangle Intersection

    I am trying to make the program output that the Rectangles intersect. This is my code, when I run it, I get a list of exceptions. Can someone help me out?

    public Rectangle playerRec(){ ///playerRec() makes new rect
    Rectangle playerRec=new Rectangle(playerX,playerY,playerW,playerH); //x,y,w,h
    System.out.println("Player "+playerRec.getBounds());
    return null;
    }
    public Rectangle enemyRec(){ ///enemyRec() makes new rect
    Rectangle enemyRec=new Rectangle(enemyX, enemyY, enemyW, enemyH); //x,y,w,h
    System.out.println("Enemy "+enemyRec.getBounds());
    return null;
    }

    public void collision() {
    enemyRec();
    playerRec();
    if(playerRec().intersects(enemyRec())) {
    System.out.println("INTERSECTS");
    }
    }
    The

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    list of exceptions
    These will tell what the trouble is. If you post them we might be able to help.

Similar Threads

  1. help with rectangle class
    By darkgt in forum New To Java
    Replies: 7
    Last Post: 11-14-2007, 07:19 PM
  2. Rectangle expands with applet frame
    By Godzilla in forum New To Java
    Replies: 1
    Last Post: 07-10-2007, 08:14 PM
  3. Rectangle with rounded edges??
    By orchid in forum Java 2D
    Replies: 1
    Last Post: 05-10-2007, 03:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •