Beispiel #1
0
  public void changeWeaponBar() {

    if (_init) {
      _init = false;

      // Give some weapon power initially

      _currPower = 5;
      bar.setValue((int) _currPower);
    } else bar.setValue((int) _currPower);
  }
Beispiel #2
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);
  }
Beispiel #3
0
  public void chanceLifeBar() {

    lifeBar.setValue(lives);
  }