public void paintComponent(Graphics g) {
   super.paintComponent(g);
   if (scene == OVERWORLD) g.drawImage(background, 0, 0, this);
   if (scene == BATTLE) {
     if (battleBG == 1) g.drawImage(background, 0, -130, this);
     else g.drawImage(background, 0, 0, this);
   }
   int loop;
   for (loop = 0; loop < enemies.size(); loop++) {
     if (scene == OVERWORLD) {
       enemies.get(loop).drawEnemy(g);
     }
     if (scene == BATTLE) {
       if (enemies.get(loop).getActivity()) {
         enemies.get(loop).drawEnemy(g);
       }
     }
   }
   for (loop = 0; loop < spellsThrown.size(); loop++) {
     spellsThrown.get(loop).drawSpell(g);
   }
   player.drawPlayer(g);
   for (loop = 0; loop < enemies.size(); loop++) {
     enemies.get(loop).drawSpells(g);
   }
   if (scene == BATTLE) {
     drawMenu(g);
     if (battleWon) drawVictory(g);
     else if (battleLost) drawDefeat(g);
   }
 }
Esempio n. 2
0
  /** Overrides <code>Graphics.drawImage</code>. */
  public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
    DebugGraphicsInfo info = info();

    if (debugLog()) {
      info.log(toShortString() + " Drawing image: " + img + " at: " + new Point(x, y));
    }

    if (isDrawingBuffer()) {
      if (debugBuffered()) {
        Graphics debugGraphics = debugGraphics();

        debugGraphics.drawImage(img, x, y, observer);
        debugGraphics.dispose();
      }
    } else if (debugFlash()) {
      int i, count = (info.flashCount * 2) - 1;
      ImageProducer oldProducer = img.getSource();
      ImageProducer newProducer =
          new FilteredImageSource(oldProducer, new DebugGraphicsFilter(info.flashColor));
      Image newImage = Toolkit.getDefaultToolkit().createImage(newProducer);
      DebugGraphicsObserver imageObserver = new DebugGraphicsObserver();

      Image imageToDraw;
      for (i = 0; i < count; i++) {
        imageToDraw = (i % 2) == 0 ? newImage : img;
        loadImage(imageToDraw);
        graphics.drawImage(imageToDraw, x, y, imageObserver);
        Toolkit.getDefaultToolkit().sync();
        sleep(info.flashTime);
      }
    }
    return graphics.drawImage(img, x, y, observer);
  }
Esempio n. 3
0
  public void draw(Graphics g) {
    // draw background
    g.drawImage(bgImage, 0, 0, null);

    // draw image
    g.drawImage(anim.getImage(), 0, 0, null);
  }
Esempio n. 4
0
  // draws the button, based on the type of button (ImageIcon, Image, or String)
  public void draw(Graphics g) {
    if (visible) {
      // if its image/imageicon, draw it
      g.setColor(new Color(50, 200, 50));
      g.fillRect(x - 1, y - 1, width + 2, height + 2);
      if (mode.equals("Image") || mode.equals("ImageIcon")) {
        if (enabled) {
          g.drawImage(image, x, y, null);
        } else {
          g.drawImage(BWimage, x, y, null);
        }
        // if its string, draw the string
      } else {

        g.setFont(new Font("Arial", Font.PLAIN, 20));
        if (enabled) {
          g.setColor(Color.black);
          g.drawString(message, x + 20, y + 20);
        } else {
          g.setColor(new Color(255, 255, 255));
          g.fillRect(x - 1, y - 1, width + 2, height + 2);
          g.setColor(Color.black);
          g.drawString(message, x + 20, y + 20);
        }
      }
    }
  }
Esempio n. 5
0
 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);
     }
   }
 }
Esempio n. 6
0
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   setBackground(Color.black);
   add(l);
   add(s);
   drawSpecialLines(g);
   g.setColor(Color.white);
   g.fillOval(30, 100, 75, 75);
   g.setColor(Color.blue);
   g.fillRect(getWidth() / 2, getHeight() / 2, (int) bl, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 40, (int) gl, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 80, (int) ll, 10);
   g.fillRect(getWidth() / 2, getHeight() / 2 + 120, (int) sl, 10);
   g.drawImage(bullet.getImage(), 30, getHeight() / 2 - 10, 20, 20, null);
   g.drawImage(grenade.getImage(), 30, getHeight() / 2 + 40 - 10, 20, 20, null);
   g.drawImage(laser.getImage(), 30, getHeight() / 2 + 80 - 10, 20, 20, null);
   g.drawImage(shotgun.getImage(), 30, getHeight() / 2 + 120 - 10, 20, 20, null);
   g.setColor(Color.yellow);
   if (gunTrack == 0) {
     g.drawRect(30, getHeight() / 2 - 10, 20, 20);
   } else if (gunTrack == 1) {
     g.drawRect(30, getHeight() / 2 + 40 - 10, 20, 20);
   } else if (gunTrack == 2) {
     g.drawRect(30, getHeight() / 2 + 80 - 10, 20, 20);
   } else {
     g.drawRect(30, getHeight() / 2 + 120 - 10, 20, 20);
   }
 }
Esempio n. 7
0
  private void gameRender() {
    if (dbImage == null) {
      dbImage = createImage(PWIDTH, PHEIGHT);
      if (dbImage == null) {
        System.out.println("dbImage is null");
        return;
      } else dbg = dbImage.getGraphics();
    }

    // draw a white background
    dbg.setColor(Color.white);
    dbg.fillRect(0, 0, PWIDTH, PHEIGHT);

    // draw the game elements: order is important
    ribsMan.display(dbg); // the background ribbons
    bricksMan.display(dbg); // the bricks
    jack.drawSprite(dbg); // the sprites
    fireball.drawSprite(dbg);

    if (showExplosion) // draw the explosion (in front of jack)
    dbg.drawImage(explosionPlayer.getCurrentImage(), xExpl, yExpl, null);

    reportStats(dbg);

    if (gameOver) gameOverMessage(dbg);

    if (showHelp) // draw the help at the very front (if switched on)
    dbg.drawImage(
          helpIm, (PWIDTH - helpIm.getWidth()) / 2, (PHEIGHT - helpIm.getHeight()) / 2, null);
  } // end of gameRender()
    public void paintIcon(Graphics g) {
      final BufferedImage image =
          new BufferedImage(
              myIcon.getIconWidth(), myIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
      final Graphics2D gg = image.createGraphics();
      myIcon.paintIcon(this, gg, 0, 0);

      final Rectangle bounds = g.getClipBounds();
      int y = myIcon.getIconHeight() - 1;
      while (y < bounds.y + bounds.height) {
        g.drawImage(
            image,
            bounds.x,
            y,
            bounds.x + bounds.width,
            y + 1,
            0,
            myIcon.getIconHeight() - 1,
            bounds.width,
            myIcon.getIconHeight(),
            this);

        y++;
      }

      g.drawImage(image, 0, 0, this);
    }
  public static void main(String[] args) throws IOException {

    File path =
        new File("Java\\Emulator\\src\\main\\com\\nikonhacker\\gui\\images\\viewfinder_lcd");

    // load source images
    BufferedImage image = ImageIO.read(new File(path, "off.png"));

    // create the new image, canvas size is the max. of both image sizes
    int w = image.getWidth();
    int h = image.getHeight();
    BufferedImage result = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);

    // paint both images, preserving the alpha channels
    Graphics g = result.getGraphics();
    g.drawImage(image, 0, 0, null);

    String input = "0x00 0x00 0x06 0x3D 0x0B 0xDF 0xD0 0x02 0x7A 0xFF 0x07 0xD3 0xD3 0xD4 0x00";
    String[] values = input.trim().split("[\\s,]+");
    int byteNumber = 0;
    for (String value : values) {
      if (byteNumber > 0 && byteNumber < 14) { // Ignore byte 0 and 14
        try {
          int bValue = Format.parseUnsigned(value);
          for (int bitNumber = 0; bitNumber < 8; bitNumber++) {
            if (Format.isBitSet(bValue, bitNumber)) {
              File overlayFile = new File(path, byteNumber + "_" + bitNumber + ".png");
              if (!overlayFile.exists()) {
                System.err.println("Missing file: " + overlayFile.getName());
              } else {
                BufferedImage overlay = ImageIO.read(overlayFile);
                if (overlay.getWidth() != w || overlay.getHeight() != h) {
                  System.err.println(
                      "Wrong file size for "
                          + overlayFile.getName()
                          + ": "
                          + overlay.getWidth()
                          + "x"
                          + overlay.getHeight()
                          + " instead of "
                          + w
                          + "x"
                          + h);
                } else {
                  g.drawImage(overlay, 0, 0, null);
                }
              }
            }
          }
        } catch (ParsingException e) {
          System.err.println("Cannot parse value: " + value);
        }
      }
      byteNumber += 1;
    }

    // Save as new image
    ImageIO.write(result, "PNG", new File(path, "result1.png"));
  }
 @Override
 public void render(GameContainer container, Graphics g) throws SlickException {
   g.drawImage(background, 0, 0);
   g.setBackground(Color.white);
   g.setColor(new Color(100, 100, 100, 0.5f));
   g.drawImage(balls, 0, 0, new Color(255, 255, 255, 0.5f));
   // g.fillOval( 0, 0, 0, 90);
 }
Esempio n. 11
0
  public void paint(Graphics g) {
    if (!gameComplete) {
      if (!initialPaintComplete) {
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, MaxX, MaxY);
        initialPaintComplete = true;
      }

      Graphics blockGraphics = blockBuffer.getGraphics();
      Graphics padGraphics = padBuffer.getGraphics();
      Graphics ballGraphics = ballBuffer.getGraphics();
      Graphics ballPreviousGraphics = ballBufferPrevious.getGraphics();

      ballPreviousGraphics.setColor(Color.WHITE);
      ballPreviousGraphics.fillRect(0, 0, ballDiameter, ballDiameter);
      g.drawImage(ballBufferPrevious, ballPreviousX, ballPreviousY, null);

      ballGraphics.setColor(Color.BLUE);
      ballGraphics.fillOval(0, 0, ballDiameter, ballDiameter); // whole line white
      g.drawImage(ballBuffer, ballX, ballY, null);

      ballGraphics.setColor(Color.RED);
      ballGraphics.fillOval(4, 4, ballDiameter - 8, ballDiameter - 8); // whole line white
      g.drawImage(ballBuffer, ballX, ballY, null);

      padGraphics.setColor(Color.WHITE);
      padGraphics.fillRect(0, 0, MaxX, blockHeight); // whole line white
      padGraphics.setColor(Color.BLACK);
      padLeft = padx - padLength / 2;

      if (padLeft >= 0 && padx + padLength / 2 < MaxX) {
        padGraphics.fillRoundRect(padLeft, 0, padLength, padHeight, padHeight, padHeight);
      }
      if (padLeft < 0) {
        padGraphics.fillRoundRect(0, 0, padLength, padHeight, padHeight, padHeight);
      } else if (padx + padLength / 2 >= MaxX) {
        padGraphics.fillRoundRect(MaxX - padLength, 0, padLength, padHeight, padHeight, padHeight);
      }
      g.drawImage(padBuffer, 0, padTop, null);
      // g.drawString(msg, 50, 50);
      // Drawing Blocks

      Iterator<Entry<String, Color>> it = blockMap.entrySet().iterator();
      blockGraphics.setColor(Color.WHITE);
      blockGraphics.fillRect(0, 0, blockSetWidth, blockSetHeight); // whole line white
      while (it.hasNext()) {
        Map.Entry<String, Color> pairs = (Map.Entry<String, Color>) it.next();
        String coordinate = pairs.getKey();
        blockGraphics.setColor(pairs.getValue());
        blockGraphics.fillRect(
            new Pair(coordinate).first, new Pair(coordinate).second, blockLength, blockHeight);
      }
      if (repaintBlocks) {
        g.drawImage(blockBuffer, blockStartX, blockStartY, null);
        if (--count < 0) repaintBlocks = false;
      }
    }
  }
Esempio n. 12
0
  /** PaintComponent to draw everything. */
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    setBackground(Color.WHITE);
    // If using images, use cool dragon background
    if (useImages) g.drawImage(background, 0, 0, 310, 300, null);

    // Use light gray to not overpower the background image
    g.setColor(Color.LIGHT_GRAY);
    for (int y = 1; y < ROWS; ++y)
      g.fillRoundRect(0, cellSize * y - 4, (cellSize * COLS) - 1, 8, 8, 8);
    for (int x = 1; x < COLS; ++x)
      g.fillRoundRect(cellSize * x - 4, 0, 8, (cellSize * ROWS) - 1, 8, 8);

    // Use graphics2d for when not using the images
    Graphics2D g2d = (Graphics2D) g;
    g2d.setStroke(new BasicStroke(4, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    for (int y = 0; y < ROWS; ++y) {
      for (int x = 0; x < COLS; ++x) {
        int x1 = x * cellSize + 16;
        int y1 = y * cellSize + 16;
        if (board[y][x] == Symbol.X) {
          // use image if set to true, otherwise use g2d
          // for thicker, better looking X's and O's
          if (useImages) g.drawImage(imageX, x1, y1, 75, 75, null);
          else {
            g2d.setColor(PURPLE);
            int x2 = (x + 1) * cellSize - 16;
            int y2 = (y + 1) * cellSize - 16;
            g2d.drawLine(x1, y1, x2, y2);
            g2d.drawLine(x2, y1, x1, y2);
          }
        } else if (board[y][x] == Symbol.O) {
          if (useImages) g.drawImage(imageO, x1, y1, 75, 75, null);
          else {
            g2d.setColor(Color.BLUE);
            g2d.drawOval(x1, y1, 70, 70);
          }
        }
      } // end for
    }

    // Set status bar based on gamestate.  If CONTINUE, show whose turn it is
    if (gameStatus == GameStatus.CONTINUE) {
      statusBar.setForeground(Color.BLACK);
      if (currentPlayer == Symbol.X) statusBar.setText("X's Turn");
      else statusBar.setText("O's Turn");
    } else if (gameStatus == GameStatus.DRAW) {
      statusBar.setForeground(Color.RED);
      statusBar.setText("Draw! Click to play again!");
    } else if (gameStatus == GameStatus.X_WIN) {
      statusBar.setForeground(Color.RED);
      statusBar.setText("X has won! Click to play again!");
    } else if (gameStatus == GameStatus.O_WIN) {
      statusBar.setForeground(Color.RED);
      statusBar.setText("O has won! Click to play again!");
    }
  }
Esempio n. 13
0
  public void paint(Graphics gOld) {
    if (image == null || xsize != getSize().width || ysize != getSize().height) {
      xsize = getSize().width;
      ysize = getSize().height;
      image = createImage(xsize, ysize);
      g = (Graphics2D) image.getGraphics();
      g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }
    // fill background
    g.setColor(Color.cyan);
    g.fillRect(0, 0, xsize, ysize);

    int x[] = {getX(0), getX(getWidth2()), getX(getWidth2()), getX(0), getX(0)};
    int y[] = {getY(0), getY(0), getY(getHeight2()), getY(getHeight2()), getY(0)};
    // fill border
    g.setColor(Color.black);
    g.fillPolygon(x, y, 4);
    // draw border
    g.setColor(Color.red);
    g.drawPolyline(x, y, 5);
    if (animateFirstTime) {
      gOld.drawImage(image, 0, 0, null);
      return;
    }
    if (gameOver) return;
    g.drawImage(outerSpaceImage, getX(0), getY(0), getWidth2(), getHeight2(), this);
    for (int index = 0; index < missile.length; index++) {
      if (missile[index].active) {
        g.setColor(Color.red);
        drawCircle(getX(missile[index].xPos), getYNormal(missile[index].yPos), 90, .3, 1.5);
      }
    }
    if (rocketRight) {
      drawRocket(rocketImage, getX(rocketXPos), getYNormal(rocketYPos), 0.0, 2.0, 2.0);
    } else {
      drawRocket(rocketImage, getX(rocketXPos), getYNormal(rocketYPos), 0.0, -2.0, 2.0);
    }
    for (int index = 0; index < numStars; index++) {
      g.setColor(Color.yellow);
      if (starActive[index])
        drawCircle(getX(starXPos[index]), getYNormal(starYPos[index]), 0, 1.5, 1.5);
    }
    g.setColor(Color.magenta);
    g.setFont(new Font("Impact", Font.BOLD, 15));
    g.drawString("Score: " + score, 10, 45);
    g.setColor(Color.magenta);
    g.setFont(new Font("Impact", Font.BOLD, 15));
    g.drawString("HighScore: " + highScore, 300, 45);
    g.setColor(Color.magenta);
    g.setFont(new Font("Impact", Font.BOLD, 15));
    g.drawString("Lives: " + rocketLife, 150, 45);
    if (rocketLife == 0) {
      g.setColor(Color.red);
      g.setFont(new Font("Impact", Font.BOLD, 60));
      g.drawString("GAME OVER", getX(getWidth2() / 6), getYNormal(getHeight2() / 2));
    }
    gOld.drawImage(image, 0, 0, null);
  }
 public void drawInto(Graphics g) {
   if ((g == null) || (!visible)) return;
   Rectangle r = getBounds();
   if (selected) {
     g.drawImage(activeImage, r.x, r.y, null);
   } else {
     g.drawImage(idleImage, r.x, r.y, null);
   }
 }
Esempio n. 15
0
 /**
  * @param icol
  * @param iRow
  */
 public void DrawMelon(int icol, int iRow) {
   if (iMaze[iRow][icol] == MELON)
     if (Global.affectiveState == 1
         || Global.affectiveState == 3
         || Global.affectiveState == 6
         || Global.affectiveState == 7)
       graphics.drawImage(imageMelon, icol * 16, iRow * 16, applet);
     else graphics.drawImage(imageBlank, icol * 16, iRow * 16, applet);
 }
Esempio n. 16
0
 /**
  * @param icol
  * @param iRow
  */
 public void DrawOrange(int icol, int iRow) {
   if (iMaze[iRow][icol] == ORANGE)
     if (Global.affectiveState == 1
         || Global.affectiveState == 3
         || Global.affectiveState == 6
         || Global.affectiveState == 7)
       graphics.drawImage(imageOrange, icol * 16, iRow * 16, applet);
     else graphics.drawImage(imageBlank, icol * 16, iRow * 16, applet);
 }
Esempio n. 17
0
  public void paint(Graphics g) {
    super.paint(g);
    g.setFont(fotn);
    Random generator1 = new Random();
    height = bird.getBirdy();

    g.drawImage(Backgroundtop, 0, 0, 450, 644, null);
    g.drawImage(Bird, 100, height, 40, 30, null);

    if (firstrun == true) { // intiate threads
      pipethread[currentthreads].start();
      birdthread.start();
      firstrun = false;
    }

    for (int index = 0; index <= currentthreads; index++) {
      g.drawImage(Pipes, pipeob[index].getpipex(), pipeob[index].getpipey(), null);
    }

    g.drawImage(Backgroundbottom, 0, 644, 450, 156, null);

    g.setColor(Color.black);

    if (pipeob[currentthreads].getpipex() <= 550) {
      currentthreads++;
      pipethread[currentthreads].start();
      score++;
    }
    g.drawString("Score: " + score + "", 50, 50);

    for (int index = 0; index < currentthreads; index++) {
      if (((height < pipeob[index].getpipey() + 730) || (height > pipeob[index].getpipey() + 870))
              && ((pipeob[index].getpipex() < 100) && (pipeob[index].getpipex() + 72 > 100))
          || ((height < pipeob[index].getpipey() + 730)
                  || (height > pipeob[index].getpipey() + 870))
              && ((pipeob[index].getpipex() < 140) && (pipeob[index].getpipex() + 72 > 140))
          || ((height + 30 < pipeob[index].getpipey() + 730)
                  || (height + 30 > pipeob[index].getpipey() + 870))
              && ((pipeob[index].getpipex() < 100) && (pipeob[index].getpipex() + 72 > 100))
          || ((height + 30 < pipeob[index].getpipey() + 730)
                  || (height + 30 > pipeob[index].getpipey() + 870))
              && ((pipeob[index].getpipex() < 140) && (pipeob[index].getpipex() + 72 > 140))
          || ((height + 30 >= 644))) {
        g.drawImage(gameover, 125, 200, null);
        JOptionPane.showMessageDialog(
            null, "You Dead. \n you scored " + score, "Oh no!", JOptionPane.INFORMATION_MESSAGE);
      }
    }
    for (int counter = 0; counter <= 50000000; counter++) {
      counter++;
      counter--;
    }
    do {
      repaint();
    } while (replay = true);
  }
Esempio n. 18
0
 /**
  * @param icol
  * @param iRow
  */
 public void DrawOneUp(int icol, int iRow) // <----------------------------One-up
     {
   if (iMaze[iRow][icol] == ONE_UP)
     if (Global.affectiveState == 1
         || Global.affectiveState == 3
         || Global.affectiveState == 6
         || Global.affectiveState == 7)
       graphics.drawImage(imageOneUp, icol * 16, iRow * 16, applet);
     else graphics.drawImage(imageBlank, icol * 16, iRow * 16, applet);
 }
Esempio n. 19
0
 public void paint(Graphics g) {
   if (isAlive) {
     framesDrawn++;
     if (framesDrawn % 100 < 50) {
       g.drawImage(myImage, (int) (x), (int) (y), 50, 50, null);
     } else {
       g.drawImage(myImage2, (int) (x), (int) (y), 50, 50, null);
     }
   }
 }
Esempio n. 20
0
 void circle(Graphics g, double x, double y, int st) {
   switch (st) {
     case Block.BLANK:
       return;
     case Block.RED_BEAD:
       switch (gst.theme) {
         case 0:
           g.setColor(Color.RED);
           break;
         case 1:
           g.setColor(Color.BLACK);
           break;
         case 2:
           g.drawImage(
               gold,
               (int) (x - bst.scale * r3 / 2 * 0.75),
               (int) (y - bst.scale * r3 / 2 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               Color.WHITE,
               null);
           return;
       }
       break;
     case Block.BLUE_BEAD:
       switch (gst.theme) {
         case 0:
           g.setColor(Color.BLUE);
           break;
         case 1:
           g.setColor(new Color(1, 175, 1));
           break;
         case 2:
           g.drawImage(
               silver,
               (int) (x - bst.scale * r3 / 2 * 0.75),
               (int) (y - bst.scale * r3 / 2 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               (int) (bst.scale * r3 * 0.75),
               Color.WHITE,
               null);
           return;
       }
       break;
     case Block.RED_PATH:
     case Block.BLUE_PATH:
       g.setColor(Color.GREEN);
       break;
   }
   g.fillOval(
       (int) (x - bst.scale * r3 / 2 * 0.75),
       (int) (y - bst.scale * r3 / 2 * 0.75),
       (int) (bst.scale * r3 * 0.75),
       (int) (bst.scale * r3 * 0.75));
 }
Esempio n. 21
0
  /** Overrides <code>Graphics.drawImage</code>. */
  public boolean drawImage(
      Image img,
      int dx1,
      int dy1,
      int dx2,
      int dy2,
      int sx1,
      int sy1,
      int sx2,
      int sy2,
      Color bgcolor,
      ImageObserver observer) {
    DebugGraphicsInfo info = info();

    if (debugLog()) {
      info.log(
          toShortString()
              + " Drawing image: "
              + img
              + " destination: "
              + new Rectangle(dx1, dy1, dx2, dy2)
              + " source: "
              + new Rectangle(sx1, sy1, sx2, sy2)
              + ", bgcolor: "
              + bgcolor);
    }

    if (isDrawingBuffer()) {
      if (debugBuffered()) {
        Graphics debugGraphics = debugGraphics();

        debugGraphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
        debugGraphics.dispose();
      }
    } else if (debugFlash()) {
      int i, count = (info.flashCount * 2) - 1;
      ImageProducer oldProducer = img.getSource();
      ImageProducer newProducer =
          new FilteredImageSource(oldProducer, new DebugGraphicsFilter(info.flashColor));
      Image newImage = Toolkit.getDefaultToolkit().createImage(newProducer);
      DebugGraphicsObserver imageObserver = new DebugGraphicsObserver();

      Image imageToDraw;
      for (i = 0; i < count; i++) {
        imageToDraw = (i % 2) == 0 ? newImage : img;
        loadImage(imageToDraw);
        graphics.drawImage(
            imageToDraw, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, imageObserver);
        Toolkit.getDefaultToolkit().sync();
        sleep(info.flashTime);
      }
    }
    return graphics.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer);
  }
Esempio n. 22
0
 /** The field view component needs to be redisplayed. Copy the internal image to screen. */
 public void paintComponent(Graphics g) {
   if (fieldImage != null) {
     Dimension currentSize = getSize();
     if (size.equals(currentSize)) {
       g.drawImage(fieldImage, 0, 0, null);
     } else {
       // Rescale the previous image.
       g.drawImage(fieldImage, 0, 0, currentSize.width, currentSize.height, null);
     }
   }
 }
Esempio n. 23
0
  public void drawHeroEffects(
      Graphics g, int scrollX, int scrollY, Cell selectedCell, Cell rangeCell) {
    for (Iterator it = team2.iterator(); it.hasNext(); ) {
      Player player = (Player) it.next();
      Hero tempHero = player.getHero();
      if (tempHero.getIsChosen() && tempHero.getStatus().equals(HeroStatus.standing)) {
        tempHero.drawRange(g, scrollX, scrollY);

      } else if (tempHero.getIsChosen() && tempHero.getStatus().equals(HeroStatus.attacking)) {
        tempHero
            .getCurrentSkill()
            .drawSkill(g, selectedCell, scrollX, scrollY, tempHero.getPanel());
        tempHero
            .getSkill(tempHero.getCurrentSkillIndex())
            .drawPath(g, rangeCell, scrollX, scrollY, tempHero.getPanel());
        tempHero
            .getSkill(tempHero.getCurrentSkillIndex())
            .drawPathOnHero(g, tempHero, rangeCell, scrollX, scrollY, tempHero.getPanel());
      }
      if (tempHero.getIsChosen()) {
        g.drawImage(
            tempHero.getCurrentSprite(),
            tempHero.getX() - scrollX,
            tempHero.getY() - scrollY,
            tempHero.getPanel());
      }
    }
    for (Iterator it = team1.iterator(); it.hasNext(); ) {
      Player player = (Player) it.next();
      Hero tempHero = player.getHero();
      if (tempHero.getIsChosen() && tempHero.getStatus().equals(HeroStatus.standing)) {
        tempHero.drawRange(g, scrollX, scrollY);

      } else if (tempHero.getIsChosen() && tempHero.getStatus().equals(HeroStatus.attacking)) {
        tempHero
            .getCurrentSkill()
            .drawSkill(g, selectedCell, scrollX, scrollY, tempHero.getPanel());
        tempHero
            .getSkill(tempHero.getCurrentSkillIndex())
            .drawPath(g, rangeCell, scrollX, scrollY, tempHero.getPanel());
        tempHero
            .getSkill(tempHero.getCurrentSkillIndex())
            .drawPathOnHero(g, tempHero, rangeCell, scrollX, scrollY, tempHero.getPanel());
      }
      if (tempHero.getIsChosen()) {
        g.drawImage(
            tempHero.getCurrentSprite(),
            tempHero.getX() - scrollX,
            tempHero.getY() - scrollY,
            tempHero.getPanel());
      }
    }
  }
Esempio n. 24
0
 void drawGrape() {
   int i, j;
   for (i = 0; i < HEIGHT; i++)
     for (j = 0; j < WIDTH; j++) {
       if (iMaze[i][j] == GRAPE)
         if (Global.affectiveState == 1
             || Global.affectiveState == 3
             || Global.affectiveState == 6
             || Global.affectiveState == 7) graphics.drawImage(imageGrape, j * 16, i * 16, applet);
         else graphics.drawImage(imageBlank, j * 16, i * 16, applet);
     }
 }
Esempio n. 25
0
 public void gameOverMenu(
     Graphics g) { // CHANGE THIS TO INCLUDE HIGHSCORES AND STUFF AFTER TEXTFILES ARE MADE
   // Menu that shows up when user gets Game Over
   if (pause == true && die == true) {
     g.drawImage(
         new ImageIcon("InGameMenu/pauseBckgrnd.png").getImage(), 0, 0, this); // Graphics stuff
     g.setFont(scoreFont);
     g.setColor(Color.BLACK);
     g.drawImage(new ImageIcon("InGameMenu/GameOver.png").getImage(), 10, 200, this);
     displayScore2(g, 115, 350, 185, 385, 110, 440, 110, 490); // Shows stats
     g.drawImage(menuB.getPic(mx, my), menuB.getX(), menuB.getY(), this); // Draws menu button
   }
 }
Esempio n. 26
0
 public void lvlClearMenu(Graphics g) {
   // Menu that shows up after a level has been cleared
   if (pause == true && lvlClear == true) {
     g.drawImage(
         new ImageIcon("InGameMenu/pauseBckgrnd.png").getImage(), 0, 0, this); // <Graphics stuff
     g.drawImage(new ImageIcon("InGameMenu/stageClearPic.png").getImage(), 100, 0, this);
     displayScore2(g, 115, 350, 185, 380, 110, 440, 110, 490); // Displays stats
     g.drawImage(
         resumeB.getPic(mx, my), resumeB.getX(), resumeB.getY(), this); // Draws resume button
     g.drawImage(
         menuB.getPic(mx, my), menuB.getX(), menuB.getY(), this); // Draws the back to menu button
   }
 }
Esempio n. 27
0
 void drawOneUp() // <--------------------------One-up
     {
   int i, j;
   for (i = 0; i < HEIGHT; i++)
     for (j = 0; j < WIDTH; j++) {
       if (iMaze[i][j] == ONE_UP)
         if (Global.affectiveState == 1
             || Global.affectiveState == 3
             || Global.affectiveState == 6
             || Global.affectiveState == 7) graphics.drawImage(imageOneUp, j * 16, i * 16, applet);
         else graphics.drawImage(imageBlank, j * 16, i * 16, applet);
     }
 }
Esempio n. 28
0
 public void paintComponent(Graphics g) {
   g.drawImage(background, 0, 0, this);
   g.drawImage(start[0], 570, 320, this);
   // Buttons
   if (570 < mx && mx < 750 && 320 < my && my < 370) {
     g.drawImage(start[1], 570, 320, this);
   }
   g.drawImage(load[0], 570, 380, this);
   if (570 < mx && mx < 750 && 380 < my && my < 430) {
     g.drawImage(load[1], 570, 380, this);
   }
   // Instructions Screen
   if (drawn) {
     g.drawImage(intro, -5, -14, this);
   }
   g.drawImage(instr[0], 570, 440, this);
   if (570 < mx && mx < 750 && 440 < my && my < 490) {
     g.drawImage(instr[1], 570, 440, this);
   }
   if (getWords.getPressed() && !getWords.getCurrent().equals("")) {
     loadPlayer(getWords.getCurrent());
     getWords.setVisible(false);
     getWords = new inputBox("Load Game");
     newGame = true;
   }
 }
Esempio n. 29
0
  public void setOpen(boolean open) {
    isOpen = open;
    BufferedImage bufferedImage = new BufferedImage(64, 64, BufferedImage.TYPE_INT_RGB);
    Graphics g = bufferedImage.getGraphics();
    g.drawImage(this.getImage(), 0, 0, null);

    if (open) {
      g.drawImage(Maps.getImage("config/icons/unlock1.png"), 30, 24, null);
    } else {
      g.drawImage(Maps.getImage("config/icons/lock1.png"), 30, 24, null);
    }
    this.setImage(bufferedImage);
    g.dispose();
  }
Esempio n. 30
0
 /**
  * Draws the image and the grid.
  *
  * @param panel
  * @param g
  */
 public void draw(DrawingPanel panel, Graphics g) {
   if (scaleFactor < 1) {
     g.drawImage(
         image.getScaledInstance(
             (int) (scaleFactor * image.getWidth()),
             (int) (scaleFactor * image.getHeight()),
             java.awt.Image.SCALE_REPLICATE),
         panel.getLeftGutter(),
         panel.getTopGutter(),
         panel);
   } else {
     // g.drawImage(image, 1+panel.xToPix(xmin), 1+panel.yToPix(ymax), panel);
     g.drawImage(image, panel.getLeftGutter(), panel.getTopGutter(), panel);
   }
 }