Examples of BufferStrategy


Examples of java.awt.image.BufferStrategy

    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

Examples of java.awt.image.BufferStrategy

  /**
   * 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

Examples of java.awt.image.BufferStrategy


    int[] pixels = ((DataBufferInt)img.getRaster().getDataBuffer()).getData();
    boolean running = true;
    while(running){
      BufferStrategy bs = frame.getBufferStrategy();
      if(bs==null){
        frame.createBufferStrategy(4);
        return;
      }
      for (int i = 0; i < width * height; i++)
        pixels[i] = 0;

      Graphics g= bs.getDrawGraphics();
      g.drawImage(img, heightOffset, widthOffset, width, height, null);
      g.dispose();
      bs.show();

    }
  } 
View Full Code Here

Examples of java.awt.image.BufferStrategy


    int[] pixels = ((DataBufferInt)img.getRaster().getDataBuffer()).getData();
    boolean running = true;
    while(running){
      BufferStrategy bs = frame.getBufferStrategy();
      if(bs==null){
        frame.createBufferStrategy(4);
        return;
      }
      for (int i = 0; i < width * height; i++)
        pixels[i] = 0;

      Graphics g= bs.getDrawGraphics();
      g.drawImage(img, heightOffset, widthOffset, width, height, null);
      g.dispose();
      bs.show();

    }
  }
View Full Code Here

Examples of java.awt.image.BufferStrategy

   
  }
 
  // rendering while the component updates
  public void render() {
    BufferStrategy bs = getBufferStrategy();
    if(bs == null) {
      this.createBufferStrategy(3);
      return;
    }
   
    // set the graphics to the buffer strategy image
    Graphics g = bs.getDrawGraphics();
    // draw the canvas image
    g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
    // dispose gfx and draw buffer
    g.dispose();
    bs.show();
  }
View Full Code Here

Examples of java.awt.image.BufferStrategy

        tickCount++;
        level.tick();
    }

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

        int xOffset = player.x - (screen.width / 2);
        int yOffset = player.y - (screen.height / 2);

        level.renderTiles(screen, xOffset, yOffset);
        level.renderEntities(screen);

        for (int y = 0; y < screen.height; y++) {
            for (int x = 0; x < screen.width; x++) {
                int colourCode = screen.pixels[x + y * screen.width];
                if (colourCode < 255)
                    pixels[x + y * WIDTH] = colours[colourCode];
            }
        }

        Graphics g = bs.getDrawGraphics();
        g.drawImage(image, 0, 0, getWidth(), getHeight(), null);
        g.dispose();
        bs.show();
    }
View Full Code Here

Examples of java.awt.image.BufferStrategy

  }
 
  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

Examples of java.awt.image.BufferStrategy

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

Examples of java.awt.image.BufferStrategy

 
 
 
  public void render()
  {
    BufferStrategy bs = this.getBufferStrategy();
    if (bs == null) {
      createBufferStrategy(2);
      return;
    }
    Graphics2D g = (Graphics2D) bs.getDrawGraphics();
    g.setColor(Color.WHITE);
    g.fillRect(0, 0, WIDTH, HEIGHT);
    //////////////////// DRAW GAME SCREEN ////////////////////
    leftPowerUp.draw(g);
    topBound.draw(g);
    bottomBound.draw(g);
    leftBound.draw(g);
    rightBound.draw(g);
    leftPlayer.draw(g);
    rightPlayer.draw(g);
    ballSpawner.draw(g);
    for (int i = 0; i < activeBalls.size(); i++)
    {
      activeBalls.get(i).draw(g);
    }
    drawText(g);
    //////////////////////////////////////////////////////////
    Toolkit.getDefaultToolkit().sync();
    g.dispose();
    bs.show();
  }
View Full Code Here

Examples of java.awt.image.BufferStrategy

        The application must dispose of the graphics object.
    */
    public Graphics2D getGraphics() {
        Window window = device.getFullScreenWindow();
        if (window != null) {
            BufferStrategy strategy = window.getBufferStrategy();
            return (Graphics2D)strategy.getDrawGraphics();
        }
        else {
            return null;
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.