예제 #1
0
  /**
   * Draw the correct gallow image. Calculate the best hangman image, and then search the ID from
   * the resource
   */
  private void drawGallow() {
    double steps =
        (((double) config.DRAW_GALLOW_STEPS) / Hangman.settings.get_tries())
            * (Hangman.settings.get_tries() - Hangman.getLives());
    int nr;
    if (steps < 12) nr = (int) Math.round(steps);
    else if (steps >= 13) nr = 13;
    else nr = 12;

    String HANGMAN = "hangman" + nr;

    int resID = this.getResources().getIdentifier(HANGMAN, "drawable", "com.mprog.hangman");
    gallow = (Bitmap) BitmapFactory.decodeResource(getResources(), resID);
    canvas.drawBitmap(gallow, 0, (45 * scrMlt), null);
  }
예제 #2
0
 /** Draw the remaining lives */
 private void drawLives() {
   paint.setTextSize(18 * scrMlt);
   int startX = (int) gallow.getWidth() / 5 + (140 * scrMlt);
   int startY = gallow.getHeight() + (30 * scrMlt);
   canvas.drawText("Lives: " + Hangman.getLives(), startX, startY, paint);
 }