Beispiel #1
0
 public void render(GameContainer gc, Graphics g) {
   g.setColor(Color.white);
   if (lastInput == null) { // before any input, just draw the ani
     super.getEntityAniLeft().draw(super.getEntityX(), super.getEntityY());
   }
   if (lastInput == "left") { // if last input was left, draw left ani
     super.getEntityAniLeft().draw(super.getEntityX(), super.getEntityY());
   }
   if (lastInput == "right") { // if last input was right, draw right ani
     super.getEntityAniRight().draw(super.getEntityX(), super.getEntityY());
   }
   g.drawString(super.getEntityName(), super.getEntityX() + 20, super.getEntityY() + 95);
 }
Beispiel #2
0
  /**
   * Draws everything onto the main panel.
   *
   * @param page Graphics component to draw on
   */
  public void paintComponent(Graphics page) {
    super.paintComponent(page);
    setForeground(Color.cyan);

    renderer.draw(page, this, offX, offY);

    //        hero.draw(this, page, offX, offY);

    for (Entity effect : effects) {
      effect.draw(this, page, offX, offY);
      /*if (effect instanceof Burst) {
          Burst pop = (Burst) effect;
          pop.draw(this, page, offX, offY);
      }*/
    }

    // Draw hero position information
    Rectangle r = hero.getBounds();
    page.drawString("Position: x = " + (r.x + (r.width >> 1)), SCORE_PLACE_X, SCORE_PLACE_Y);
    final int tab = 100;
    final int lineHeight = 20;
    page.drawString("y = " + (r.y + (r.height >> 1)), SCORE_PLACE_X + tab, SCORE_PLACE_Y);
    page.drawString("Frame: " + frame, SCORE_PLACE_X, SCORE_PLACE_Y + lineHeight);

    if (!running) {
      page.drawString("Game over :(", WIDTH / 2, HEIGHT / 2);
    }
  }
Beispiel #3
0
  private void draw() {

    // Clear the screen and depth buffer
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    // set up GameContext.getCamera()
    GL11.glPushMatrix();

    GL11.glScalef(scale, scale, scale);
    GL11.glTranslatef(
        -GameContext.getCamera().getPosition().getx(),
        -GameContext.getCamera().getPosition().gety(),
        0);
    GL11.glTranslatef(4f, 3f, 0);

    map.draw();

    if (editorMode) {
      Quad q = new Quad(editorTag.getPosition(), map.getLookupTile(currentEditorTile).getTexture());
      GameContext.getPipe().addDrawable(q);
    }

    for (Entity ae : entities) {
      ae.draw();
    }

    GameContext.getPipe().renderContent();

    GL11.glPopMatrix();

    // overlay console text

    GL11.glPushMatrix();
    GL11.glScalef(2f, 2f, 2f);

    if (console.isEnabled()) {
      gtest.drawing.util.drawString(new Coord(0, 0), "> " + console.getText());
    }

    if (GameContext.isDebugMode()) {
      gtest.drawing.util.drawString(
          new Coord(0, 285), "tiles drawn " + GameContext.getFromLog("tilesLastDrawn"));
      gtest.drawing.util.drawString(
          new Coord(0, 275), "textures bound " + GameContext.getFromLog("textureBinds"));
      gtest.drawing.util.drawString(new Coord(0, 265), "FPS " + GameContext.getFromLog("fps"));
    }

    GL11.glPopMatrix();

    Display.update();

    // clean up

    GameContext.getPipe().clear();
    GameContext.addToLog("tilesLastDrawn", "0");
    GameContext.addToLog("textureBinds", "0");
  }
Beispiel #4
0
  @Override
  public void draw(Graphics2D oG) {
    // TODO Auto-generated method stub
    Entity oBlock = (Entity) oBlockHead.getNext();

    while (oBlock != null) {
      oBlock = (Entity) oBlock.getNext();
      oBlock.draw(oG);
    }
  }
Beispiel #5
0
 public void draw() {
   if (isVideo) {
     if (newBuffer) {
       sprite.draw(x, y, WIDTH, HEIGHT, videoBuffer);
       newBuffer = false;
     } else {
       sprite.draw(x, y);
     }
   } else if (sprite != null) {
     super.draw();
   }
 }
Beispiel #6
0
 @Override
 public void draw(Canvas c) {
   if (!destoryed) {
     super.draw(c);
     if (w.hasBlock((int) position.x, (int) position.y)) {
       w.placeBlock((int) position.x, (int) position.y, 0);
       destoryed = true;
     }
   } else {
     body = null;
     velocity = null;
     position = null;
   }
 }
Beispiel #7
0
 /** @param canvas */
 public void draw(Canvas canvas) {
   for (Entity e : entities) {
     e.draw(canvas);
   }
 }
Beispiel #8
0
 @Override
 public void draw(Graphics2D g) {
   super.draw(g);
   g.drawImage(animation.getImage(), getX(), getY(), null);
 }
Beispiel #9
0
 // Draw Player.
 public void draw(Graphics2D g) {
   super.draw(g);
 }