public void checkEnemyCollision() {
   for (Enemy e : enemyList) {
     if (e.getOnScreen()) { // can be removed later on
       // goes through all the enemies and checks if they collide
       if (e.checkCollision(e.getPics().get(e.getCounter()), player1)) {
         if (player1.getInvi() == false) {
           // If the player is not invisble then you get spiked.
           if (player1.getVelocity() > 0) { // if the player hits it from the bottom
             player1.setSpikeVelo();
             loseCoins();
           } else {
             player1.setVelo(
                 50); // if the player is on top instead the player bounces off the enemy
             if (musicOn) {
               bounce.play();
             }
           }
         }
         eRemove.add(e); // once we hit, we remove the enemy
       }
     } else {
       eRemove.add(e); // if the enemy goes of the screen, we remove
     }
   }
   for (Enemy e : eRemove) {
     poofList.add(new Poof(e.getX(), e.getY(), 1)); // removes all the enemies
     enemyList.remove(e);
   }
   eRemove = new ArrayList<Enemy>();
 }
 public void scrollEnemies() {
   for (Enemy i : enemyList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
     i.setYPos(i.getYPos() + (int) (player1.getVelocity() * 0.3));
     i.setYMax(i.getYMax() + (int) (player1.getVelocity() * 0.3));
   }
 }
 public void checkStarCollision() {
   for (Star s : starList) {
     if (s.getOnScreen()) { // if the star is on the screen we need to check if player collides
       if (s.checkCollision(
           s.getPics().get(s.getCounter()),
           player1)) { // if the player collides with the star we remove it then change the
         // velosity to the distance that the star provides
         sRemove.add(s); // remove star once you collide with it
         player1.setVelo(s.getDist()); // changes the velocity
         player1.setInvi(true); // sets the player invisble for a few seconds
         score += s.getPoints(); // points increase by the star type
         if (musicOn) {
           starSound.play(); // playthe star sound
         }
       }
     } else {
       sRemove.add(s); // remove the star if its not on the screen
     }
   }
   for (Star s : sRemove) {
     poofList.add(new Poof(s.getX(), s.getY(), s.getNum() + 3)); // make the poof effect
     starList.remove(s);
   }
   sRemove = new ArrayList<Star>();
 }
 public void scrollCoins() {
   for (Coin i : coinList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
     i.setYPos(i.getYPos() + (int) (player1.getVelocity() * 0.3));
     i.setYMax(i.getYMax() + (int) (player1.getVelocity() * 0.3));
   }
 }
 public void keyReleased(KeyEvent evt) {
   keys[evt.getKeyCode()] = false;
   // reset the counters for for the sprite s
   player1.resetCounter();
   if (!player1.getPower().equals("Balloon")) {
     player1.resetPicCounter();
   }
 }
 public void loseCoins() {
   int x = player1.getX();
   int y = player1.getY();
   double losePercentage = 0.1;
   for (int i = 0;
       i < (int) coins * losePercentage;
       i++) { // makes the user lose 10 percent of the coin and draws them in a circle
     // System.out.println(i);
     int xPos = x + (int) (100 * Math.cos(Math.toRadians((360 / (coins * losePercentage)) * i)));
     int yPos = y - (int) (100 * Math.sin(Math.toRadians((360 / (coins * losePercentage)) * i)));
     coinList.add(new Coin(xPos, yPos, 3));
   }
   coins -= (int) (coins * losePercentage);
 }
 // -------------------------------------------------------------------------------------------------------------------------------------------------------
 public String getPowerUp() {
   if (!player1.getPower().equals("")) {
     return ("P1");
   } else {
     return "none";
   }
 }
  /* applet init event. Should initialize the applet. */
  public void init() {
    backbuffer = new BufferedImage(512, 512, BufferedImage.TYPE_INT_ARGB);
    g2d = backbuffer.createGraphics();

    iconSheet = getImage(this.getClass().getResource("data/icons2.png"));

    wateringCanImage = getImageFromIconSheet(0, 0);
    wateringSplashImage = getImageFromIconSheet(1, 0);
    flowerImage = getImageFromIconSheet(2, 0);
    seedImage = getImageFromIconSheet(3, 0);
    skullImage = getImageFromIconSheet(4, 0);
    tapImage = getImageFromIconSheet(5, 0);
    playerImage = getImageFromIconSheet(0, 1);
    flowerStalkImage = getImageFromIconSheet(2, 1);
    clockImage = getImageFromIconSheet(4, 1);
    tapSplashImage = getImageFromIconSheet(5, 1);
    dirtImage = getImageFromIconSheet(0, 2);
    brickImage = getImageFromIconSheet(0, 3);

    player.image = playerImage;

    pickupAudio = getAudioClip(this.getClass().getResource("data/Pickup.wav"));

    for (int i = 0; i < 14; i++) {
      flowerList[i] = new Flower();
      flowerList[i].height = rand.nextInt(14);
    }

    addKeyListener(this);
  }
 public void keyPressed(KeyEvent k) {
   int keycode = k.getKeyCode();
   switch (keycode) {
     case KeyEvent.VK_LEFT:
       player.moveLeft();
       break;
     case KeyEvent.VK_RIGHT:
       player.moveRight();
     case KeyEvent.VK_SPACE:
       player.water();
       break;
     case KeyEvent.VK_ENTER:
       player.plantSeed();
       pickupAudio.play();
       break;
   }
 }
 public void checkJumperCollision() {
   // same as all the other collsions
   for (Jumper j : jumperList) {
     if (j.getOnScreen()) { //
       if (j.checkCollision(j.getImage(), player1)) {
         player1.setVelo(50);
         player1.setDown(false);
         if (musicOn) {
           bounce.play();
         }
       }
     } else {
       jRemove.add(j);
     }
   }
   for (Jumper j : jRemove) {
     jumperList.remove(j);
   }
   jRemove = new ArrayList<Jumper>();
 }
 public void checkSpikeCollision() { // checks the spike collision
   for (Spikes s : spikeList) {
     if (s.getOnScreen()) { // if the spike is on the screen
       if (s.checkCollision(s.getImage(), player1)) { // if the user collides with the spike
         if (player1.getInvi() == false) { // if player is not invisiblity
           player1.setSpikeVelo(); // set the spike velocity
           loseCoins();
           player1.setDown(true);
         }
         spRemove.add(s);
       }
     } else {
       spRemove.add(s); // remove the spike
     }
   }
   for (Spikes s : spRemove) {
     spikeList.remove(s);
   }
   spRemove = new ArrayList<Spikes>();
 }
  public void checkPupCollision() {
    // pretty much the same thing as before, however it alsoe does the powerup effects
    for (Powerup p : pupList) {
      if (p.getOnScreen()) { // can be removed later on
        if (p.checkCollision(player1)) {
          pupRemove.add(p);
          player1.setPower(p.getType());
          player1.setVelo(50);
        }
      } else {
        pupRemove.add(p);
      }
    }
    if (player1.getPower().equals("Lucky")) { // changes everything to stars
      for (Coin c : coinList) {
        starList.add(new Star(c.getX(), c.getY(), 2));
        cRemove.add(c);
      }
      for (Box b : boxList) {
        starList.add(new Star(b.getX(), b.getY(), 2));
        bRemove.add(b);
      }
      for (Enemy e : enemyList) {
        starList.add(new Star(e.getX(), e.getY(), 2));
        eRemove.add(e);
      }
    } else if (player1.getPower().equals("Magnet")) { // moves the coins towards the player
      for (Coin c : coinList) {
        c.moveTowards(player1);
      }
    } else { // else do nothing

    }
    for (Powerup p : pupRemove) {
      poofList.add(new Poof(p.getX(), p.getY(), 2));
      pupList.remove(p);
    }
    pupRemove = new ArrayList<Powerup>();
  }
 public void DrawEveryThing(Graphics g) {
   moveLayerOne(g); // moves the background makes it parallax scrolling
   moveLayerTwo(g); // the decorations
   drawPowerUpEffect(g); // draws the powerup effect
   moveLayerThree(g); // moves all the other stuff
   newPattern(); // makes a new PAttern
   newDecos(); // makes new decorations
   atLevel();
   levelUp(); // changes the level
   checkAllCollisions();
   removePoof(); // remove the poofs
   moveEverything(); // moves everything
   player1.changeVelocity();
 }
 public void checkBoxCollision() { // pretty much the same thing as all the other collisions
   for (Box b : boxList) {
     if (b.getOnScreen()) { // checks if its on the screen
       if (b.checkCollision(b.getImage(), player1)) {
         player1.setVelo(50);
         player1.setDown(false);
         b.setPcount(
             b.getPcount() - 1); // sets the type to one less so then you can  bounce on it twice
         if (b.getPcount() == 0) {
           bRemove.add(b); // removes the box
         }
         if (musicOn) {
           bounce.play();
         }
       }
     } else {
       bRemove.add(b);
     }
   }
   for (Box b : bRemove) {
     boxList.remove(b);
   }
   bRemove = new ArrayList<Box>();
 }
 public void checkCoinCollision() {
   for (Coin c : coinList) {
     if (c.getOnScreen()) { // check if the coin is on the screen
       if (c.checkCollision(
           c.getPics().get(c.getCounter()), player1)) { // if the player collides with the coin
         cRemove.add(c); // remove the coin
         player1.setVelo(50); // set the velocity so the player moves up
         player1.setDown(false); // set the down false (players moving up)
         coins += c.getValue(); // check the coins collected
         score += c.getPoints(); // get the score
         if (musicOn) {
           coinSound.play(); // play the sound
         }
       }
     } else {
       cRemove.add(c); // remove the coin
     }
   }
   for (Coin c : cRemove) {
     poofList.add(new Poof(c.getX(), c.getY(), 0));
     coinList.remove(c);
   }
   cRemove = new ArrayList<Coin>();
 }
 public void drawPowerUpIcon(Graphics g) {
   // draws the powerup the player has on the top
   if (player1.getPower().equals("Umbrella")) {
     g.drawImage(
         new ImageIcon("gamelayerstuff/powerups/UmbrellaSymbol.png").getImage(), 200, 10, this);
   } else if (player1.getPower().equals("Ball")) {
     g.drawImage(
         new ImageIcon("gamelayerstuff/powerups/BallSymbol.png").getImage(), 200, 10, this);
   } else if (player1.getPower().equals("Boost")) {
     g.drawImage(
         new ImageIcon("gamelayerstuff/powerups/BoostSymbol.png").getImage(), 200, 10, this);
   } else if (player1.getPower().equals("Balloon")) {
     g.drawImage(
         new ImageIcon("gamelayerstuff/powerups/BalloonSymbol.png").getImage(), 200, 10, this);
   } else if (player1.getPower().equals("Sheild")) {
     g.drawImage(
         new ImageIcon("gamelayerstuff/powerups/SheildSymbol.png").getImage(), 200, 10, this);
   } else if (player1.getPower().equals("Magnet")) {
     g.drawImage(
         new ImageIcon("gamelayerstuff/powerups/MagnetSymbol.png").getImage(), 200, 10, this);
   } else {
     g.drawImage(new ImageIcon("gamelayerstuff/powerupbox.png").getImage(), 200, 10, this);
   }
 }
 public void scrollBoxes() {
   for (Box i : boxList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
   }
 }
 public void updateObjects() {
   player.tick();
 }
 public void moveLayerThree(Graphics g) {
   backy += (int) (player1.getVelocity() * 0.1);
   midy += (int) (player1.getVelocity() * 0.5);
   drawEnemy(g);
   drawCoin(g);
   drawBox(g);
   drawPoof(g);
   drawStar(g);
   drawJumper(g);
   drawSpike(g);
   drawPup(g);
   if (backy <= dieHeight) {
     // System.out.println(die);
     g.drawImage(player1.move(2), player1.getX(), player1.getY(), this);
     if (player1.animationComplete()) {
       die = true;
     }
   } else {
     if (backy <= dieHeight) {
       player1.resetCounter();
     }
     if (keys[KeyEvent.VK_RIGHT]) {
       g.drawImage(player1.move(1), player1.getX(), player1.getY(), this);
     } else if (keys[KeyEvent.VK_LEFT]) {
       g.drawImage(player1.move(-1), player1.getX(), player1.getY(), this);
     } else {
       g.drawImage(player1.move(0), player1.getX(), player1.getY(), this);
     }
   }
 }
 public void scrollRects() {
   for (Rectangle i : rectList) {
     i.setLocation((int) (i.getX()), (int) (i.getY() + (int) (player1.getVelocity() * 0.3)));
   }
 }
 public void scrollPoofs() {
   for (Poof i : poofList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
   }
 }
 public void scrollPowerUps() {
   for (Powerup i : pupList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
   }
 }
 public void scrollDecorations() {
   for (Decorations i : decoList) {
     i.setY(i.getYTop() + (int) (player1.getVelocity() * 0.45));
   }
 }
 public void scrollSpikes() {
   for (Spikes i : spikeList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
   }
 }
 public void scrollJumpers() {
   for (Jumper i : jumperList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
   }
 }
 public void drawPowerUpEffect(Graphics g) {
   if (player1.getPower().equals("Magnet")) {
     Image magpic = magnetList.get((int) count % 6);
     g.drawImage(
         magpic,
         player1.getX() - ((magpic.getWidth(null) - player1.getWidth()) / 2),
         player1.getY() - ((magpic.getHeight(null) - player1.getHeight()) / 2),
         magpic.getWidth(null),
         magpic.getHeight(null),
         this);
     count += 0.1;
   } else if (player1.getPower().equals("Ball")) {
     g.drawImage(
         ballPower,
         player1.getX() - ballPower.getWidth(null) / 2 + 17,
         player1.getY() + player1.getHeight() - 20,
         ballPower.getWidth(null),
         ballPower.getHeight(null),
         this);
   } else if (player1.getPower().equals("Sheild")) {
     g.drawImage(
         sheildPower,
         player1.getX() - ((sheildPower.getWidth(null) - player1.getWidth()) / 2),
         player1.getY() - ((sheildPower.getHeight(null) - player1.getHeight()) / 2),
         sheildPower.getWidth(null),
         sheildPower.getHeight(null),
         this);
   } else if (player1.getPower().equals("Umbrella")) {
     g.drawImage(
         umbrellaPower,
         player1.getX() - (umbrellaPower.getWidth(null) / 2) + 20,
         player1.getY() - umbrellaPower.getHeight(null) + 40,
         umbrellaPower.getWidth(null),
         umbrellaPower.getHeight(null),
         this);
   } else if (player1.getPower().equals("")) {
   }
 }
 public void loadPics() {
   ghostImage = new ImageIcon(getClass().getResource("Ghosting.png")).getImage();
   // Image button2Icon = new ImageIcon(getClass().getResource("ani1.png")).getImage();
   Image aniIdleS = new ImageIcon(getClass().getResource("TimS3.png")).getImage();
   Image aniIdleN = new ImageIcon(getClass().getResource("TimN5.png")).getImage();
   Image aniIdleE = new ImageIcon(getClass().getResource("TimE4.png")).getImage();
   Image aniIdleW = new ImageIcon(getClass().getResource("TimW3.png")).getImage();
   idleArray[1] = aniIdleE;
   idleArray[2] = aniIdleS;
   idleArray[3] = aniIdleW;
   idleArray[4] = aniIdleN;
   Image anie1 = new ImageIcon(getClass().getResource("TimE1.png")).getImage();
   Image anie2 = new ImageIcon(getClass().getResource("TimE2.png")).getImage();
   Image anie3 = new ImageIcon(getClass().getResource("TimE3.png")).getImage();
   Image anie4 = new ImageIcon(getClass().getResource("TimE4.png")).getImage();
   Image anie5 = new ImageIcon(getClass().getResource("TimE5.png")).getImage();
   Image anie6 = new ImageIcon(getClass().getResource("TimE6.png")).getImage();
   aniObject = new myAnimation();
   aniObject.addScene(anie1, 250); // 250 millisecond play time
   aniObject.addScene(anie2, 250); // 250 millisecond play time
   aniObject.addScene(anie3, 250); // 250 millisecond play time
   aniObject.addScene(anie4, 250); // 250 millisecond play time
   aniObject.addScene(anie5, 250); // 250 millisecond play time
   aniObject.addScene(anie6, 250); // 250 millisecond play time
   aniArray[1] = aniObject;
   Image anis1 = new ImageIcon(getClass().getResource("TimS1.png")).getImage();
   Image anis2 = new ImageIcon(getClass().getResource("TimS2.png")).getImage();
   Image anis3 = new ImageIcon(getClass().getResource("TimS3.png")).getImage();
   Image anis4 = new ImageIcon(getClass().getResource("TimS4.png")).getImage();
   Image anis5 = new ImageIcon(getClass().getResource("TimS5.png")).getImage();
   Image anis6 = new ImageIcon(getClass().getResource("TimS6.png")).getImage();
   Image anis7 = new ImageIcon(getClass().getResource("TimS7.png")).getImage();
   Image anis8 = new ImageIcon(getClass().getResource("TimS8.png")).getImage();
   aniObjectS = new myAnimation();
   aniObjectS.addScene(anis1, 250); // 250 millisecond play time
   aniObjectS.addScene(anis2, 250); // 250 millisecond play time
   aniObjectS.addScene(anis3, 250); // 250 millisecond play time
   aniObjectS.addScene(anis4, 250); // 250 millisecond play time
   aniObjectS.addScene(anis5, 250); // 250 millisecond play time
   aniObjectS.addScene(anis6, 250); // 250 millisecond play time
   aniObjectS.addScene(anis7, 250); // 250 millisecond play time
   aniObjectS.addScene(anis8, 250);
   aniArray[2] = aniObjectS;
   Image aniw1 = new ImageIcon(getClass().getResource("TimW1.png")).getImage();
   Image aniw2 = new ImageIcon(getClass().getResource("TimW2.png")).getImage();
   Image aniw3 = new ImageIcon(getClass().getResource("TimW3.png")).getImage();
   Image aniw4 = new ImageIcon(getClass().getResource("TimW4.png")).getImage();
   Image aniw5 = new ImageIcon(getClass().getResource("TimW5.png")).getImage();
   Image aniw6 = new ImageIcon(getClass().getResource("TimW6.png")).getImage();
   aniObjectW = new myAnimation();
   aniObjectW.addScene(aniw1, 250); // 250 millisecond play time
   aniObjectW.addScene(aniw2, 250); // 250 millisecond play time
   aniObjectW.addScene(aniw3, 250); // 250 millisecond play time
   aniObjectW.addScene(aniw4, 250); // 250 millisecond play time
   aniObjectW.addScene(aniw5, 250); // 250 millisecond play time
   aniObjectW.addScene(aniw6, 250); // 250 millisecond play time
   aniArray[3] = aniObjectW;
   Image anin1 = new ImageIcon(getClass().getResource("TimN1.png")).getImage();
   Image anin2 = new ImageIcon(getClass().getResource("TimN2.png")).getImage();
   Image anin3 = new ImageIcon(getClass().getResource("TimN3.png")).getImage();
   Image anin4 = new ImageIcon(getClass().getResource("TimN4.png")).getImage();
   Image anin5 = new ImageIcon(getClass().getResource("TimN5.png")).getImage();
   Image anin6 = new ImageIcon(getClass().getResource("TimN6.png")).getImage();
   Image anin7 = new ImageIcon(getClass().getResource("TimN7.png")).getImage();
   Image anin8 = new ImageIcon(getClass().getResource("TimN8.png")).getImage();
   aniObjectN = new myAnimation();
   aniObjectN.addScene(anin1, 250); // 250 millisecond play time
   aniObjectN.addScene(anin2, 250); // 250 millisecond play time
   aniObjectN.addScene(anin3, 250); // 250 millisecond play time
   aniObjectN.addScene(anin4, 250); // 250 millisecond play time
   aniObjectN.addScene(anin5, 250); // 250 millisecond play time
   aniObjectN.addScene(anin6, 250); // 250 millisecond play time
   aniObjectN.addScene(anin7, 250); // 250 millisecond play time
   aniObjectN.addScene(anin8, 250); // 250 millisecond play time
   aniArray[4] = aniObjectN;
   penguinAnimation[0] = new ImageIcon(getClass().getResource("PenguinS.png")).getImage();
   penguinAnimation[1] = new ImageIcon(getClass().getResource("PenguinS2.png")).getImage();
   penguinAnimation[2] = new ImageIcon(getClass().getResource("PenguinS.png")).getImage();
   penguinAnimation[3] = new ImageIcon(getClass().getResource("PenguinS3.png")).getImage();
   player.addAnimation(aniArray);
   player.addIdle(idleArray);
 }
  public GamePanel(String name, int l) {
    setFocusable(true);
    grabFocus();
    addMouseListener(this);
    addMouseMotionListener(this);
    addKeyListener(this);
    keys = new boolean[10000];

    try {
      scoreFont =
          Font.createFont(Font.TRUETYPE_FONT, new FileInputStream(new File("BRLNSB.ttf")))
              .deriveFont(0, 32);
    } catch (IOException ioe) {
      System.out.println("error loading BRLNSB.tff");
    } catch (FontFormatException ffe) {
      System.out.println("Something went wrong with the font.");
    }

    gameBckgrnd = new ImageIcon("Backgroundimage.png").getImage();
    for (int i = 1; i < 7; i++) {
      magnetList.add(new ImageIcon("gamelayerstuff/powerups/magnet" + i + ".png").getImage());
    }

    coinPic = new ImageIcon("gamelayerstuff/coins/byellowcoin1.png").getImage();
    player1 = new Player(200, 300, 100, "sheldon");

    click = false;
    ground = true;
    pause = false;
    lvlClear = false;
    die = false;
    musicOn = true;

    player1.setVelo(150);
    player1.setInvi(true);
    // ------------------------------------------------------------------------------------------------------------------------------------
    // Sound
    coinSound = Applet.newAudioClip(getClass().getResource("coin_pickup_2.wav"));
    clicked = Applet.newAudioClip(getClass().getResource("menu_deselect.wav"));
    starSound = Applet.newAudioClip(getClass().getResource("star.wav"));
    bounce = Applet.newAudioClip(getClass().getResource("grav_step_4.wav"));
    bckGrndMusic = Applet.newAudioClip(getClass().getResource("bgmusic00.wav"));
    bckGrndMusic.loop();
    // ------------------------------------------------------------------------------------------------------------------------------------

    // distance=0;
    score = 0;
    coins = 0;
    level = 1;
    prevLvl = level;
    backy = 0;
    height = backy;
    dieHeight = 0;
    dieMenuHeight = 0;

    pauseB = new SButton(400, 670, "pause", "");
    resumeB = new SButton(100, 500, "resume", "");
    menuB = new SButton(100, 620, "back", "");
    muteB = new SButton(400, 600, "mute", "");
    unmuteB = new SButton(400, 600, "unmute", "");
    // System.out.println("characters/"+name+"/"+name+"35.png");
  }
  public void paint(Graphics g) {
    // int numDoors=0;
    int rX = player.getRelativeX();
    int rY = player.getRelativeY();
    boolean notInBuilding = true;
    bufferGraphics.clearRect(0, 0, dim.width, dim.width);
    bufferGraphics.setColor(Color.WHITE);
    r2.setLocation(20 + rX, 20 + rY);

    // Iterator<Objects>  iterator1 = entities.iterator();//size is the last index, therefore it
    // starts at the end
    // while(iterator1.hasNext()){
    // iterator1.next().update(rX, rY);
    // bufferGraphics.drawImage(iterator1.next().image, iterator1.next().blockX+rX,
    // iterator1.next().blockX+rY, null);
    // }
    for (int x = 0; x < buildings.size(); x++) {
      buildings.get(x).update(rX, rY);
      player.onDoor(player.r, buildings.get(x).door);
      player.collideOn(player.r, buildings.get(x));
      if (player.inHouse(player.r, buildings.get(x).inside)) {
        notInBuilding = false;
      }
      // if(notInBuilding){
      // bufferGraphics.drawImage(buildings.get(x).image,
      // buildings.get(x).blockX+rX,buildings.get(x).blockY+rY, null);
      // }else{
      // bufferGraphics.drawImage(buildings.get(x).innerImage,
      // buildings.get(x).blockX+rX,buildings.get(x).blockY+rY, null);
      // }

      // bufferGraphics.fillRect(entities.get(x).bounds.x, entities.get(x).bounds.y,
      // entities.get(x).bounds.width, entities.get(x).bounds.height);
    }

    bufferGraphics.setFont(new Font("Arial", Font.PLAIN, 20));
    // String m1 = new Boolean(player.canMove('w')).toString();
    bufferGraphics.drawString(message, 0, 170);
    // bufferGraphics.fillRect(r2.x, r2.y, r2.width, r2.height);
    // player.collideOn(player.r, r2);
    // ***Image log1 = new ImageIcon(getClass().getResource("logTest.png")).getImage();
    // ***bufferGraphics.drawImage(log1, (int)r2.getX(), (int)r2.getY(), null);
    // bufferGraphics.drawLine((int)player.N.getX1(), (int)player.N.getY1(), (int)player.N.getX2(),
    // (int)player.N.getY2());
    // bufferGraphics.drawLine((int)player.E.getX1(), (int)player.E.getY1(), (int)player.E.getX2(),
    // (int)player.E.getY2());
    // bufferGraphics.drawLine((int)player.S.getX1(), (int)player.S.getY1(), (int)player.S.getX2(),
    // (int)player.S.getY2());
    // bufferGraphics.drawLine((int)player.W.getX1(), (int)player.W.getY1(), (int)player.W.getX2(),
    // (int)player.W.getY2());
    // bufferGraphics.setColor(Color.RED);
    // bufferGraphics.drawLine((int)player.NI.getX1(), (int)player.NI.getY1(),
    // (int)player.NI.getX2(), (int)player.NI.getY2());
    // bufferGraphics.drawLine((int)player.EI.getX1(), (int)player.EI.getY1(),
    // (int)player.EI.getX2(), (int)player.EI.getY2());
    // bufferGraphics.drawLine((int)player.SI.getX1(), (int)player.SI.getY1(),
    // (int)player.SI.getX2(), (int)player.SI.getY2());
    // bufferGraphics.drawLine((int)player.WI.getX1(), (int)player.WI.getY1(),
    // (int)player.WI.getX2(), (int)player.WI.getY2());
    if (notInBuilding) {
      Image thebg = new ImageIcon(getClass().getResource("grassbackingdev.png")).getImage();
      bufferGraphics.drawImage(thebg, 0 + rX, 0 + rY, null);
    }

    player.update();
    int setX = Math.abs(player.relativeX);
    int setY = Math.abs(player.relativeY);
    if (player.relativeX > 0) {
      setX = -setX;
    }
    if (player.relativeY > 0) {
      setY = -setY;
    }

    if (notInBuilding) {
      for (int x = 0; x < entities.size(); x++) {
        entities.get(x).update(rX, rY);
        bufferGraphics.drawImage(
            entities.get(x).image, entities.get(x).blockX + rX, entities.get(x).blockY + rY, null);
        player.collideOn(player.r, entities.get(x));
        if (entities.get(x).health <= 0) {
          if (entities.get(x).material == "Wood") wood += entities.get(x).matsReturn;
          if (entities.get(x).material == "Stone") stone += entities.get(x).matsReturn;
          entities.remove(x);
        }
        // bufferGraphics.fillRect(entities.get(x).bounds.x, entities.get(x).bounds.y,
        // entities.get(x).bounds.width, entities.get(x).bounds.height);
      }
    }
    for (int x = 0; x < buildings.size(); x++) {
      if (notInBuilding) {
        bufferGraphics.drawImage(
            buildings.get(x).image,
            buildings.get(x).blockX + rX,
            buildings.get(x).blockY + rY,
            null);
      } else {
        bufferGraphics.drawImage(
            buildings.get(x).innerImage,
            buildings.get(x).blockX + rX,
            buildings.get(x).blockY + rY,
            null);
      }
    }
    if (notInBuilding) {
      for (int x = 0; x < npcArray.size(); x++) {

        for (int e = 0; e < entities.size(); e++) {
          npcArray.get(x).detectEntities(entities.get(e));
          if (entities.get(e).health <= 0) {
            entities.remove(e);
          }
        }
        npcArray.get(x).update(rX, rY, setX + 92, setY + 82);
        bufferGraphics.drawImage(
            npcArray.get(x).graphic, npcArray.get(x).npcX + rX, npcArray.get(x).npcY + rY, null);
        if (npcArray.get(x).isDead()) {
          npcArray.remove(x);
        } else if (npcArray.get(x).hitBox.intersects(player.r)) {
          player.health -= 25;
          npcArray.remove(x);
        }
      }
    }
    for (int x = 0; x < playerAttack.size(); x++) {
      playerAttack.get(x).update(rX, rY);
      bufferGraphics.drawImage(
          playerAttack.get(x).graphic,
          playerAttack.get(x).currentX + rX,
          playerAttack.get(x).currentY + rY,
          null);
      for (int y = 0; y < npcArray.size(); y++) {
        if (playerAttack.get(x).hitBox.intersects(npcArray.get(y).hitBox)) {
          npcArray.get(y).health -= 25;
          playerAttack.get(x).hasHit = true;
        }
      }
      if (playerAttack.get(x).isDead()) {
        playerAttack.remove(x);
      }
    }

    player.notOnDoor = true;
    if (player.moving) {
      bufferGraphics.drawImage(
          player.getImage().getImage(), player.getCharx(), player.getChary(), null); // TODO
    } else {
      bufferGraphics.drawImage(player.getIdle(), player.getCharx(), player.getChary(), null);
    }
    if (Ghosting) {
      if (player.face == 1) {
        bufferGraphics.drawImage(player.getResource(resource), 104, 87, null); // EAST
      }
      if (player.face == 2) {
        bufferGraphics.drawImage(player.getResource(resource), 94, 106, null); // SOUTH*94,106
      }
      if (player.face == 3) {
        bufferGraphics.drawImage(player.getResource(resource), 84, 87, null); // WEST84,87
      }
      if (player.face == 4) {
        bufferGraphics.drawImage(player.getResource(resource), 94, 75, null); // NORTH94,75
      }
    }
    if (player.health <= 0) {
      bufferGraphics.drawString("You are dead", 10, 90);
      stop();
    }
    bufferGraphics.setFont(new Font("Arial", Font.PLAIN, 9));
    bufferGraphics.setColor(new Color(160, 82, 45));
    bufferGraphics.fillRect(0, 2, 8, 8);
    bufferGraphics.setColor(new Color(105, 105, 105));
    bufferGraphics.fillRect(0, 12, 8, 8);
    bufferGraphics.drawImage(statusBar, 0, 22, null);
    bufferGraphics.setColor(Color.WHITE);
    bufferGraphics.drawString(String.format("%d", wood), 18, 10);
    bufferGraphics.drawString(String.format("%d", stone), 18, 20);
    bufferGraphics.drawString(String.format("%d", player.health), 18, 30);
    // bufferGraphics.fillRect((int)player.r.getX(), (int)player.r.getY(),
    // (int)player.r.getWidth(),(int)player.r.getHeight());
    // bufferGraphics.fillRect(player.r.x, player.r.x, player.r.width, player.r.height);
    g.drawImage(offScreen, 0, 0, this);
    // if(drawConsole){
    // message = String.format("wood: %d", wood);
    // }

  }
 public void scrollStars() {
   for (Star i : starList) {
     i.setY(i.getY() + (int) (player1.getVelocity() * 0.3));
   }
 }