Exemplo n.º 1
0
 // constructor Virus
 public Virus(Score score) {
   counter = score;
   virus = getImage();
   virus.mirrorHorizontally();
   int level = counter.level;
   speed = level + 2;
 }
Exemplo n.º 2
0
  private void animatePlayer(boolean moveDir) {
    if (moveDir == true && Greenfoot.isKeyDown("d")) {
      if (frame < 1 * delay) {
        setImage(base);
      } else if (frame < 2 * delay) {
        setImage(run2r);
      } else if (frame < 3 * delay) {
        setImage(run3r);
      } else if (frame < 4 * delay) {
        setImage(run4r);
        frame = 1;
        return;
      }
      frame++;
    }

    if (moveDir == false && Greenfoot.isKeyDown("a")) {
      if (frame < 1 * delay) {
        setImage(base);
      } else if (frame < 2 * delay) {
        GreenfootImage run2l = new GreenfootImage(run2r);
        run2l.mirrorHorizontally();
        setImage(run2l);
      } else if (frame < 3 * delay) {
        GreenfootImage run3l = new GreenfootImage(run3r);
        run3l.mirrorHorizontally();
        setImage(run3l);
      } else if (frame < 4 * delay) {
        GreenfootImage run4l = new GreenfootImage(run4r);
        run4l.mirrorHorizontally();
        setImage(run4l);
        frame = 1;
        return;
      }
      frame++;
    }
  }