Пример #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
  }
Пример #2
0
  /** Draws status bar for Invincibility */
  private void drawStun() {

    myImage.setColor(Color.YELLOW);
    myImage.drawString("Invincibility", 10, 30);
    bar.setColor(Color.YELLOW);
    bar.fill();
  }
Пример #3
0
  /** Draws status bar for Black Hole */
  private void drawPoison() {

    myImage.setColor(Color.BLACK);
    myImage.drawString("Black Hole", 10, 30);
    bar.setColor(Color.BLACK);
    bar.fill();
  }
Пример #4
0
  /** Draws status bar for Flight */
  private void drawFire() {

    myImage.setColor(Color.BLUE); // Set the color of myImage red
    myImage.drawString("Flight", 10, 30); // display text "Flight" at a location on myImage
    bar.setColor(Color.BLUE); // set the color of the image bar as red
    bar.fill(); // fill the image bar with red
  }
Пример #5
0
  /** Draws status bar for Fire Power */
  private void drawIce() {

    myImage.setColor(Color.RED); // Set the color of myImage blue
    myImage.drawString("Fire Power", 10, 30); // display text "Fire Power" at a location on myImage
    bar.setColor(Color.RED); // set the color of the image bar as blue
    bar.fill(); // fill the image bar with blue
  }
Пример #6
0
 public void act() {
   GreenfootImage img = new GreenfootImage(50, 50);
   getScore();
   String i = Integer.toString(score);
   img.drawString(i, 20, 20);
   this.setImage(img);
 }
Пример #7
0
  /** Make the score board image. */
  private void makeImage(String title, String text, String prefix, int score) {
    GreenfootImage image = new GreenfootImage(WIDTH, HEIGHT);

    image.setColor(new Color(0, 0, 0, 128));
    image.fillRect(0, 0, WIDTH, HEIGHT);
    image.setColor(new Color(0, 0, 0, 128));
    image.fillRect(5, 5, WIDTH - 10, HEIGHT - 10);
    Font font = image.getFont();
    font = font.deriveFont(FONT_SIZE);
    image.setFont(font);
    image.setColor(Color.WHITE);
    image.drawString(title, 60, 100);
    image.drawString(text, 60, 220);
    image.drawString(prefix + score, 60, 320);
    setImage(image);
  }
Пример #8
0
 private void printText() {
   laranjaEscuro = new Color(214, 95, 0);
   imgHelp.setColor(laranjaEscuro);
   Font play = new Font("sanserif", Font.BOLD, 30);
   imgHelp.setFont(play);
   int x = imgHelp.getWidth() - 130;
   int y = imgHelp.getHeight() - 16;
   imgHelp.drawString("Help", x, y);
 }
Пример #9
0
 /**
  * Add the scores for the individual maps to the score board. 'scores' is an array with all
  * scores, 'mapNo' is the number of the current map (array entries past this value have no valid
  * value).
  */
 private void addMapScores(int mapNo, int[] scores) {
   GreenfootImage image = getImage();
   Font font = image.getFont();
   font = font.deriveFont(20.0f);
   image.setFont(font);
   image.setColor(Color.WHITE);
   for (int i = 0; i <= mapNo; i++) {
     image.drawString("Map " + (i + 1) + ": " + scores[i], 460, 80 + (i * 28));
   }
 }
Пример #10
0
  public AnswerMedium(String txt) {

    ansmed = txt;

    // First we create an image that will hold our largest answer, so that we can
    // align all the text to the left.
    GreenfootImage imgTxt = new GreenfootImage(300, 30);
    // if we include "java.awt." in the next line, we don't have to import the class
    // See http://www.greenfoot.org/topics/187
    imgTxt.setColor(java.awt.Color.black);

    imgTxt.setFont(new java.awt.Font("Helvetica", java.awt.Font.PLAIN, 14));
    imgTxt.drawString(ansmed, 1, 15);

    // TextImage t=new TextImage(ans);
    setImage(imgTxt);
  }