Ejemplo n.º 1
0
  /**
   * Decreases the count down value of status duration, bar width and displays the percentate of
   * status duration left If there is a target, When status duration reaches zero, the status
   * disappears.
   *
   * @param change The Change in status duration value each Act
   */
  public void update(int change) {

    if (currCountDown > 0) {
      currCountDown -= change; // decreases the current countdown by the change value
      percentCountdown =
          (double) currCountDown
              / maxCountDown; // set a double value of percent countdown by dividing current
                              // countdown by maximum countdown
      currBarWidth =
          (int)
              (percentCountdown
                  * barWidth); // set a interger value of current bar width by multiplying percent
                               // countdown and bar width and casting them into a interger value
      percentDisplay =
          (int)
              (percentCountdown
                  * 100); // set a interget value of percentDisplay by multiplying percentCountdown
                          // by 100.
      percentCounter =
          Integer.toString(
              percentDisplay); // cast the interger percentDisplay into a string and store it in
                               // percentCouner
      myImage.clear(); // clears the image
      myImage.drawString(percentCounter + "%", 70, 30); // draws the percentCounter on myImage
      if (currBarWidth > 1) bar.scale(currBarWidth, BAR_HEIGHT); // rescale the bar size
      if (selection == true) if (currCountDown == 1) currCountDown += 1;
      update(); // redraw the image
    }
    if (selection == false)
      if (currCountDown == 0) // if current countdown is 0
      removeStatus(); // remove status
  }
Ejemplo n.º 2
0
 public void fade(int f) {
   if (f > 255) {
     f = 255;
   } else if (f < 0) {
     f = 0;
   }
   fadeColor = new Color(0, 0, 0, f);
   fade.clear();
   fade.setColor(fadeColor);
   fade.fillRect(0, 0, 1280, 720);
   setImage(fade);
 }
Ejemplo n.º 3
0
 private void drawImage() {
   GreenfootImage image = getImage();
   image.clear();
   image.drawImage(new GreenfootImage("images/Ticker.png"), 0, 0);
   image.drawString(Integer.toString(seconds), 52, 75);
 }