示例#1
0
 public void chanceToBackground() {
   if (Greenfoot.getRandomNumber(50) < 1) {
     add(new Background(), Greenfoot.getRandomNumber(150), 0);
   }
   if (Greenfoot.getRandomNumber(50) < 1) {
     add(new Background(), Greenfoot.getRandomNumber(150) + 450, 0);
   }
 }
示例#2
0
 public void fireMissle() {
   if (Greenfoot.getRandomNumber(1000) < 30) {
     getWorld()
         .addObject(
             new Missile(Greenfoot.getRandomNumber(1000), Greenfoot.getRandomNumber(150) + 390),
             getX(),
             getY());
   }
 }
示例#3
0
 public void createPlatforms(int n) {
   int random = Greenfoot.getRandomNumber(100);
   for (int i = 1; i <= n; i++) {
     if (random < 85)
       addObject(
           new SimplePlatform(),
           Greenfoot.getRandomNumber(WORLD_WIDTH),
           Greenfoot.getRandomNumber(40) - 20);
     else if (random < 90)
       addObject(
           new SpringPlatform(),
           Greenfoot.getRandomNumber(WORLD_WIDTH),
           Greenfoot.getRandomNumber(40) - 20);
     else if (random < 95)
       addObject(
           new BrittlePlatform(),
           Greenfoot.getRandomNumber(WORLD_WIDTH),
           Greenfoot.getRandomNumber(40) - 20);
     else
       addObject(
           new MovingPlatform(),
           Greenfoot.getRandomNumber(WORLD_WIDTH),
           Greenfoot.getRandomNumber(40) - 20);
   }
 }
示例#4
0
 public Flame(boolean s, boolean o, boolean z) {
   initialiseImages();
   small = s;
   burnOil = o;
   burnZombie = z;
   lastImage = (60 - Greenfoot.getRandomNumber(10));
 }
示例#5
0
  public void updateScoreForTankKill() {
    score.changeScore(+1);
    if (score.getScore() == 5) {
      for (int b = 0; b < 10; b++) {
        int x = 100;
        addObject(new Enemy(), x, y);
        y = y + 50;
      }
    } else if (score.getScore() == 15) {
      addObject(new Plane(), getWidth() / 8, getHeight() / 2);
    } else if (score.getScore() == 16) {
      for (int h = 0; h < 2; h++) {
        int x = Greenfoot.getRandomNumber(100);
        addObject(new Plane(), x, y);
        y = y + 300;
      }
    } else if (score.getScore() == 18) {
      addObject(new Plane(), getWidth() / 8, getHeight() / 2 - 100);
      addObject(new Plane(), getWidth() / 8, getHeight() / 2 + 200);
      for (int b = 0; b < 5; b++) {
        int x = 100;
        addObject(new Enemy(), x, y);
        y = y + 150;
      }
    } else if (score.getScore() == 25) {

    }
  }
示例#6
0
文件: Mine.java 项目: amirook/PI1Repo
  /**
   * entfernt die Mine und erzeugt 8 Bubbles statt Shrapnels (kein schaden) dient der Teuchung des
   * spielers
   */
  public void finte() {
    int bubblenumber = 0;
    // erstellt 8 Blasen die nach der Detonation in alle Richtungen fliegen;
    while (bubblenumber != 8) {
      // Bubbles mit zufälliger Lebensdauer(bis100) und Größer (bis59+1 diese Schreibweise
      // verhindert den output 0)
      Bubble name = new Bubble(Greenfoot.getRandomNumber(100), Greenfoot.getRandomNumber(59) + 1);

      // zufällige Platzierung der Bubbles um die Mitte der Mine
      int nextX = this.getX() + Greenfoot.getRandomNumber(48) - 24;
      int nextY = this.getY() + Greenfoot.getRandomNumber(48) - 24;
      getWorld().addObject(name, nextX, nextY);

      bubblenumber++;
    }
    getWorld().removeObject(this);
  }
示例#7
0
 public Flame(int r, int d, boolean s, boolean o) {
   initialiseImages();
   small = s;
   burnOil = o;
   setRotation(r);
   addForce(new Vector(r, d));
   lastImage = (60 - Greenfoot.getRandomNumber(10));
 }
示例#8
0
 public Flame(int r, double d, boolean s, boolean o, boolean z, boolean p, int damage) {
   initialiseImages();
   small = s;
   burnOil = o;
   burnZombie = z;
   burnPlayer = p;
   setRotation(r);
   addForce(new Vector(r, d));
   lastImage = (60 - Greenfoot.getRandomNumber(10));
   this.damage = damage;
 }
示例#9
0
 public void act() {
   setLocation(getX() - speed, getY());
   Actor z = getOneIntersectingObject(Enemy.class);
   if (z != null) {
     getWorld().removeObject(z);
     TheWorld tommy = (TheWorld) getWorld();
     tommy.updateScoreForTankKill();
   }
   Actor k = getOneIntersectingObject(Shot2.class);
   if (k != null) {
     getWorld().removeObject(k);
   }
   if (Greenfoot.getRandomNumber(100) < 3) {
     getWorld().removeObject(this);
   }
 }
示例#10
0
 public void omgevingObjecten() {
   int koeien = Greenfoot.getRandomNumber(5);
   int schapen = Greenfoot.getRandomNumber(5);
   for (int i = 0; i < koeien; i++) {
     Actor koe = new Koe();
     addObject(koe, Greenfoot.getRandomNumber(38), buitenDijk2Rows + Greenfoot.getRandomNumber(4));
   }
   for (int i = 0; i < schapen; i++) {
     Actor schaap = new Schaap();
     addObject(
         schaap, Greenfoot.getRandomNumber(38), buitenDijk2Rows + Greenfoot.getRandomNumber(4));
   }
 }
示例#11
0
  /** Create new floating objects at irregular intervals. */
  public void act() {
    if (Greenfoot.getRandomNumber(100) < 3) {
      addObject(new Bacteria(), 779, Greenfoot.getRandomNumber(360));
    }

    if (Greenfoot.getRandomNumber(100) < 1) {
      addObject(new Lining(), 779, 0);
    }

    if (Greenfoot.getRandomNumber(100) < 1) {
      addObject(new Lining(), 779, 359);
    }

    if (Greenfoot.getRandomNumber(100) < 1) {
      addObject(new Virus(), 779, Greenfoot.getRandomNumber(360));
    }
  }
示例#12
0
 public void chanceToVehicle() {
   if (Greenfoot.getRandomNumber(100) < 1) {
     add(new Vehicle(), Greenfoot.getRandomNumber(185) + 215, 0);
   }
 }
示例#13
0
 public Flame(boolean s) {
   initialiseImages();
   small = s;
   burnOil = false;
   lastImage = (60 - Greenfoot.getRandomNumber(10));
 }
示例#14
0
  /** Constructor for objects of class CarWorld. */
  public CarWorld() {
    super(600, 600, 1);
    setPaintOrder(
        Start.class,
        Help.class,
        Pause.class,
        Information.class,
        ScoreBoard.class,
        Dot.class,
        Path.class,
        Car.class,
        Bomb.class,
        Vehicle.class,
        Person.class,
        PedestrianCrossing.class,
        EndLine.class,
        Line.class,
        Counter.class,
        Lives.class,
        Background.class);
    // Greenfoot.playSound("minion_theme_01.mp3");

    // Setting background sound resources
    setBackgroundSounds();

    lives = 100;
    score = 0;
    pause = true;
    // changes by Manthan start
    car = new Car();
    car.attachObserver(new CarController(car));
    // Changes by manthan end
    leafs = new ArrayList<Component>();
    add(car, 305, 550);
    add(new Counter("Score: "), 95, 550);
    /*add(new Lives(),50,50);
    add(new Lives(),100,50);
    add(new Lives(),150,50);
    */
    add(new Dot(), 25, 395);
    add(new Path(), 25, 250);

    // Banana score visualization
    add(new BananaScore("Banana Score: "), 150, 580);
    // Weapon Power visualization
    bar.setShowTextualUnits(false);
    addObject(bar, 500, 50);

    // Life visualization
    lifeBar.setShowTextualUnits(false);
    addObject(lifeBar, 70, 50);
    lifeBar.setValue(100);

    /*add(new Line(),300,0);
    add(new Line(),300,90);
    add(new Line(),300,180);
    add(new Line(),300,270);
    add(new Line(),300,360);
    add(new Line(),300,450);
    add(new Line(),300,540);*/
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    //         add(new Information(),300,300);
    add(new Start(), 480, 550);
    add(new Help(), 550, 550);
  }
示例#15
0
 public void chanceToBanana() {
   if (Greenfoot.getRandomNumber(100) < 1) {
     add(new Banana(), Greenfoot.getRandomNumber(185) + 215, 0);
   }
 }
示例#16
0
 public void chanceToRocket() {
   if (Greenfoot.getRandomNumber(1000) < 1) {
     add(new Rocket(), Greenfoot.getRandomNumber(185) + 215, 0);
   }
 }
示例#17
0
文件: Mine.java 项目: amirook/PI1Repo
 /** Konstruktor speichert die geschwindigkeit der später erzeugten Shrapnel Splitter */
 public Mine(int shrapnelspeed) {
   this.shrapnelspeed = shrapnelspeed;
   blinktimer = Greenfoot.getRandomNumber(80);
 }
  /*
   * agrega al mundo los objetos de cambio de color, muro, hueco,sube vel, enemigo, relen de
   * de forma aleatoria cuando se llega al nivel 3
   */
  public void agregaObjetos() {
    if (nivelActual >= 3) {
      if (bandObjeto == 1) {
        switch (Greenfoot.getRandomNumber(11)) {
          case 1: // cambio Amarillo
            {
              // if(bandBarra==1)
              // {

              cAmari = new cambioAmarillo();
              addObject(cAmari, cAmari.getValorX(), 2);
              bandObjeto = 0;
              contObjeto = 0;

              // }

            }
            break;

          case 2: // cambio Azul
            {
              // if(bandBarra==1)
              // {
              cAzul = new cambioAzul();
              addObject(cAzul, cAzul.getValorX(), 2);
              bandObjeto = 0;
              contObjeto = 0;

              // }

            }
            break;

          case 3: // cambio rjo
            {
              cRojo = new cambioRojo();
              addObject(cRojo, cRojo.getValorX(), 2);
              bandObjeto = 0;
              contObjeto = 0;
            }
            break;

          case 4: // cambio verde
            {
              cVerde = new cambioVerde();
              addObject(cVerde, cVerde.getValorX(), 2);
              bandObjeto = 0;
              contObjeto = 0;
            }
            break;

          case 5: // cambio moorado
            {
              cMorado = new cambioMorado();
              addObject(cMorado, cMorado.getValorX(), 2);
              bandObjeto = 0;
              contObjeto = 0;
            }
            break;

          case 6: // muro
            {
              objMur = new muro();
              addObject(objMur, objMur.getValorX(), 2);
              bandObjeto = 0;
              contObjeto = 0;
            }
            break;

          case 7: // hueco
            {
              objHueco = new hueco();
              addObject(objHueco, objHueco.getValorX(), 2);
              bandObjeto = 0;
              contObjeto = 0;
            }
            break;

          case 8: // enemigo
            {
              objEnemy = new enemigo();
              addObject(objEnemy, objEnemy.getValorX(), 2);
              bandObjeto = 0;
              contObjeto = 0;
            }
            break;

          case 9: // sube velocidad
            {
              objVel = new subeVel();
              addObject(objVel, objVel.getValorX(), 2);
              bandObjeto = 0;
              contObjeto = 0;
            }
            break;

          case 10: // alenta orb
            {
              objLent = new relent();
              addObject(objLent, objLent.getValorX(), 2);
              bandObjeto = 0;
              contObjeto = 0;
            }
            break;
        }
      }

      // contBarra++;

      // System.out.println(nivelActual);
      if (bandObjeto == 0) {
        if (contObjeto > 800) {
          bandObjeto = 1;
          contObjeto = 0;

        } else {
          contObjeto++;
        }
      }
    }
  }
  /*
   * agrega una barra cada cierto tiempo (nivel de dificultad)
   */
  public void agregaBarra() {
    if (bandBarra == 1) {
      switch (Greenfoot.getRandomNumber(15)) {
        case 1:
          {
            // if(bandBarra==1)
            // {

            Bar1 = new BarAmarilla();
            addObject(Bar1, 381, 2);
            bandBarra = 0;
            contBarra = 0;

            // }

          }
          break;

        case 2:
          {
            // if(bandBarra==1)
            // {

            Bar2 = new BarAzul();
            addObject(Bar2, 381, 2);
            bandBarra = 0;
            contBarra = 0;

            // }

          }
          break;

        case 3: // rjo
          {
            Bar3 = new BarRojo();
            addObject(Bar3, 381, 2);
            bandBarra = 0;
            contBarra = 0;
          }
          break;

        case 4: // verde
          {
            Bar4 = new BarVerde();
            addObject(Bar4, 381, 2);
            bandBarra = 0;
            contBarra = 0;
          }
          break;

        case 5: // moorado
          {
            Bar5 = new BarMorada();
            addObject(Bar5, 381, 2);
            bandBarra = 0;
            contBarra = 0;
          }
          break;

        case 6: // media Azul
          {
            Bar6 = new mediaAzul();
            addObject(Bar6, Bar6.getValorX(), 2);
            bandBarra = 0;
            contBarra = 0;
          }
          break;

        case 7: // media morada
          {
            Bar7 = new mediaMora();
            addObject(Bar7, Bar7.getValorX(), 2);
            bandBarra = 0;
            contBarra = 0;
          }
          break;

        case 8: // media roja
          {
            Bar8 = new mediaRoja();
            addObject(Bar8, Bar8.getValorX(), 2);
            bandBarra = 0;
            contBarra = 0;
          }
          break;

        case 9: // media verde
          {
            Bar9 = new mediaVerde();
            addObject(Bar9, Bar9.getValorX(), 2);
            bandBarra = 0;
            contBarra = 0;
          }
          break;

        case 10: // media amarilla
          {
            Bar10 = new mediaAmarilla();
            addObject(Bar10, Bar10.getValorX(), 2);
            bandBarra = 0;
            contBarra = 0;
          }
          break;
      }
    }

    // contBarra++;

    // System.out.println(nivelActual);
    if (bandBarra == 0) {
      if (contBarra > cambioDific()) {
        bandBarra = 1;
        contBarra = 0;

      } else {
        contBarra++;
      }
    }

    /*if(this.getY()==500)
    {
      mund=getWorld();
      mund.removeObject(this.Bar);

    }*/

  }
示例#20
0
 public void act() {
   if (jumper.freezeFlag && (Greenfoot.getRandomNumber(100) < 20))
     createPlatforms(NUMBER_OF_NEW_PLATFORMS);
   createMonster();
 }
示例#21
0
 public void createMonster() {
   if (Greenfoot.getRandomNumber(1000) < 5)
     addObject(new Bat(), Greenfoot.getRandomNumber(WORLD_WIDTH), 0);
 }