Example #1
0
  @Override
  public void render(Camera camera, GameContainer gameContainer) {
    Graphics graphics = gameContainer.getGraphics();
    graphics.pushTransform();
    graphics.translate(0, 40f);
    super.render(camera, gameContainer);
    graphics.popTransform();

    if (BattleToads.ALLOW_DEBUGGING) graphics.setColor(Color.magenta);
    if (BattleToads.ALLOW_DEBUGGING) graphics.draw(getCollisionHitbox(position));
  }
Example #2
0
  @Override
  public void render(Graphics g) {
    g.pushTransform();
    if (flip) {
      // Be sure to flip around the center
      g.translate(centerX, 0);
      g.scale(-1, 1);
      g.translate(-centerX, 0);
      // Alternatively, translate by width after flip
    }
    g.rotate(centerX, centerY, angle);

    g.drawImage(img, 0, 0);
    g.popTransform();
  }
  /**
   * Implementation of the core rendering function that just renders the map to the assigned graphic
   * context.
   *
   * @param g the graphics context used for the render operation
   */
  private void renderImpl(final Graphics g) {
    final Camera camera = Camera.getInstance();

    g.pushTransform();

    g.translate(-camera.getViewportOffsetX(), -camera.getViewportOffsetY());
    Camera.getInstance().clearDirtyAreas(g);

    synchronized (display) {
      synchronized (GameMap.LIGHT_LOCK) {
        // draw all items
        for (int i = 0, displaySize = display.size(); i < displaySize; i++) {
          display.get(i).draw(g);
        }
      }
    }

    g.popTransform();
  }
Example #4
0
  protected void preRender(final Graphics graphicContext) {
    graphicContext.pushTransform();

    graphicContext.translate(
        this.getData()[Entity.X], this.getData()[Entity.Y]); // move to pos // position

    graphicContext.translate(
        this.getData()[Entity.CENTER_X], this.getData()[Entity.CENTER_Y]); // translate back

    graphicContext.rotate(0, 0, this.getData()[Entity.ROTATION]); // rotate

    graphicContext.scale(this.getData()[Entity.SCALE_X], this.getData()[Entity.SCALE_Y]); // zoom
    // from
    // point

    graphicContext.translate(
        -this.getData()[Entity.CENTER_X],
        -this.getData()[Entity.CENTER_Y]); // set center of rotation
  }