Package java.awt.image

Examples of java.awt.image.BufferStrategy


    mouseSpeed = Math.abs(newX - oldX);
    oldX = newX;
  }

  private void render() {
    BufferStrategy bs = this.getBufferStrategy();
    if (bs == null) {
      createBufferStrategy(3);
      return;
    }

    screen.render(game);

    for (int i = 0; i < width * height; i++) {
      pixels[i] = screen.pixels[i];
    }

    Graphics g = bs.getDrawGraphics();
    g.drawImage(img, 0, 0, width + 10, height + 10, null);
    if (aiming) {
      g.drawImage(ironsight2, (width / 2) - (ironsight2.getWidth() / 2), (height / 2) - (ironsight2.getHeight() / 2), ironsight2.getWidth(), ironsight2.getHeight(), null);
    } else {
      g.drawImage(ironsight1, (width / 2) - (ironsight1.getWidth() / 2), (height / 2) - (ironsight1.getHeight() / 2), ironsight1.getWidth(), ironsight1.getHeight(), null);
    }
    g.setFont(new Font("Verdana", 1, 14));
    g.setColor(Color.RED);
    g.drawString("FPS: " + frames, 5, 15);
    g.dispose();
    bs.show();
  }
View Full Code Here


  //set Graphics = this
  public Graphics2D getGraphics() {
    Window w = vc.getFullScreenWindow();
    if(w != null) {
      BufferStrategy s = w.getBufferStrategy();
      return (Graphics2D) s.getDrawGraphics();
    } else {
      return null;
    }
  }
View Full Code Here

 
  //updates display
  public void update() {
    Window w = vc.getFullScreenWindow();
    if(w != null) {
      BufferStrategy s = w.getBufferStrategy();
      if(!s.contentsLost()) {
        s.show();
      }
    }
  }
View Full Code Here

  }
 
  public Graphics2D getGraphics() {
    Window w = vc.getFullScreenWindow();
    if(w != null) {
      BufferStrategy s = w.getBufferStrategy();
      return (Graphics2D)s.getDrawGraphics();
    }else {
      return null;
    }
  }
View Full Code Here

  }
 
  public void update() {
    Window w = vc.getFullScreenWindow();
    if(w != null) {
      BufferStrategy s = w.getBufferStrategy();
      if(!s.contentsLost()) {
        s.show();
      }
    }
  }
View Full Code Here

    {
    }

    public void render()
    {
        BufferStrategy bufferstrategy = getBufferStrategy();

        if (bufferstrategy == null)
        {
            createBufferStrategy(2);
            return;
        }
        else
        {
            render((Graphics2D)bufferstrategy.getDrawGraphics());
            bufferstrategy.show();
            return;
        }
    }
View Full Code Here

  private void tick() {
    // TODO tick logic
  }

  private void render() {
    BufferStrategy bs = this.getBufferStrategy();
    if (bs == null) {
      createBufferStrategy(3);
      return;
    }
   
    screen.render();
    System.arraycopy(screen.pixels, 0, pixels, 0, WIN_WIDTH * WIN_HEIGHT);
    /*
     * Replaces this block
     * for (int i = 0; i < WIN_WIDTH * WIN_HEIGHT; i++) {
     *   pixels[i] = screen.pixels[i];
     * }
     * it's all black magic to me
     */
   
    Graphics g = bs.getDrawGraphics();
    g.drawImage(img, 0, 0, WIN_WIDTH, WIN_HEIGHT, null);
    g.dispose();
    bs.show();
  }
View Full Code Here

    if (!isDisplayable())
      throw new IllegalStateException("Window.createBufferStrategy: window is"
              + " not displayable");

    BufferStrategy newStrategy = null;

    // try a flipping strategy
    try
      {
  newStrategy = new WindowFlipBufferStrategy(numBuffers);
View Full Code Here

    if (!isDisplayable())
      throw new IllegalStateException("Canvas.createBufferStrategy: canvas is"
              + " not displayable");

    BufferStrategy newStrategy = null;

    // try a flipping strategy
    try
      {
  newStrategy = new CanvasFlipBufferStrategy(numBuffers);
View Full Code Here

  /**
   * Render handles graphic rendering.
   */
  private void render() {
    BufferStrategy strategy = getBufferStrategy();
    Graphics2D g = (Graphics2D) strategy.getDrawGraphics();

    if (Settings.showTitleScreen) {
      title.render(g, getWidth(), getHeight());
    }

    else if(!hero.isGameEnded()) {
      g.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), null);

      // Sets the FatMeter according to FatBoy's FatPoints.
      fm.render(g, hero.getFatLevel());
      // Render objects
      disk.render(g);
      hero.render(g);

      for (FlyingObject fo : flyingObects)
        fo.render(g);
    }
    else
    {
      g.drawImage(gameOverImage, 0, 0, getWidth(), getHeight(), null);
    }
    strategy.show();
  }
View Full Code Here

TOP

Related Classes of java.awt.image.BufferStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.