예제 #1
0
 private void paintCrates(Graphics g) {
   for (BlockInterface c : landscape.getCrates()) {
     g.drawImage(imgCrate, c.getX(), c.getY(), c.getWidth(), c.getHeight(), this);
   }
 }
예제 #2
0
 /**
  * Draws the landscape.
  *
  * @param g - Graphics
  */
 private void paintLandscape(Graphics g) {
   for (BlockInterface column[] : objects) {
     for (BlockInterface block : column) {
       if (block != null) {
         switch (block.getType()) {
           case BlockInterface.TYP_GRAS:
             {
               g.drawImage(
                   imgGras, block.getX(), block.getY(), block.getWidth(), block.getHeight(), this);
               break;
             }
           case BlockInterface.TYP_WATER:
             {
               g.drawImage(
                   imgWater,
                   block.getX(),
                   block.getY(),
                   block.getWidth(),
                   block.getHeight(),
                   this);
               break;
             }
           case BlockInterface.TYP_COIN:
             {
               g.drawImage(
                   imgCoin, block.getX(), block.getY(), block.getWidth(), block.getHeight(), this);
               break;
             }
           case BlockInterface.TYP_GOAL:
             {
               g.drawImage(
                   imgGoal, block.getX(), block.getY(), block.getWidth(), block.getHeight(), this);
               break;
             }
           case BlockInterface.TYP_GATE:
             {
               if (((GateInterface) block).isOn()) {
                 g.drawImage(
                     imgGateOpened,
                     block.getX(),
                     block.getY(),
                     block.getWidth(),
                     block.getHeight(),
                     this);
               } else {
                 g.drawImage(
                     imgGateClosed,
                     block.getX(),
                     block.getY(),
                     block.getWidth(),
                     block.getHeight(),
                     this);
               }
               break;
             }
           case BlockInterface.TYP_BUTTON:
             {
               if (((ButtonInterface) block).isPressed()) {
                 g.drawImage(
                     imgButtonPressed,
                     block.getX(),
                     block.getY(),
                     block.getWidth(),
                     block.getHeight(),
                     this);
               } else {
                 g.drawImage(
                     imgButtonReleased,
                     block.getX(),
                     block.getY(),
                     block.getWidth(),
                     block.getHeight(),
                     this);
               }
               break;
             }
         }
       }
     }
   }
 }