title: How to specify width and height of my object JAVA
body: <p>So i am trying to add collision detection for a little game i am creating and i am specifying the width and height of my defender class however i am unable to do so. My code below gives me an error saying the global variable width and height do not exist</p>
  
  <pre><code>class Defender
  {
    int x,y;
  
    Defender(int x, int y)
    {
     this.x = x;
     this.y = y;
    }
  
    void render()
    {
      //draw a defender
   fill(255,0,0);
   rect(x,y,50,20);
   triangle(x+50,y,x+50,y+20,x+60,y+10);
   fill(0,0,100);
   rect(x,y-10,20,10);
    }
  
  
    boolean collision()
    {
     color detectedColour;
     for (int i=y; i&lt;y+ Defender.height; i++) {
       detectedColour = get(x + Defender.width, i);
       if (detectedColour == Alien1) {
         return true;
       }
    }
    return false;
    }
  }
  </code></pre>