Exemple #1
0
  private void ammoChange(AmmoData ad) {

    ammoICO.setImage(ad.image);
    GreenfootImage i = ammoICO.getImage();
    i.scale((int) (ad.width * 1.75), (int) (ad.height * 1.75));
    playerAmmo = ad;
    ammoUI.setPoints(ammo[playerAmmunition.indexOf(ad)]);
  }
Exemple #2
0
  public void act() {

    if (HP < 0) {
      die(Effects[6], 0);
      return;
    }

    movement();
    equipment();
    Shot();
    Special();
    // trail();
    if (HP != hpUI.value && hpUI.targValue == 0) hpUI.addPoints(HP - hpUI.value);
  }
Exemple #3
0
  private void Special() {

    if (Greenfoot.isKeyDown("r") && specialShotInt > 120 && Spammo > 0) {

      addObjectAtOffset(new ChargeBeam(this), getX(), getY(), 80, getRotation());
      w.addObject(new CoolDown(ACT2SEC(120)), 845, 640);
      Greenfoot.playSound("Laser_Cannon.mp3");
      // !--------------!\\
      specialShotInt = 0;
      shotInterval = -78;
      Spammo--;
      SpammoUI.addPoints(-1);
    }

    specialShotInt++;
  }
Exemple #4
0
  private void Shot() {

    int index = playerAmmunition.indexOf(playerAmmo);

    if (Greenfoot.isKeyDown("space") && shotInterval > playerAmmo.interval && ammo[index] > 0) {

      int f = getRotation();
      Shot p = Shot.create(playerAmmo, Inimigo.class);
      addObjectAtOffset(p, getX(), getY(), 70, f);
      p.setRotation(f);
      // !--------------!\\
      shotInterval = 0;
      ammo[index]--;
      ammoUI.addPoints(-1);
    }

    shotInterval++;
  }
Exemple #5
0
  protected void addedToWorld(World world) {

    int tmpX = w.getWidth() - 35;
    getImage().scale(120, 100);
    HP = 200;
    ammoUI = new Value(0);
    ammoICO = new Icon("Projectil.png", 45, 45);
    hpUI = new Value(HP);
    hpUI.value = HP;
    hpICO = new Icon("Life.png", 50, 52);
    SpammoUI = new Value(Spammo);
    SpammoICO = new Icon("charge.png", 50, 52);
    world.addObject(ammoUI, tmpX, 600);
    world.addObject(ammoICO, tmpX, 525);
    world.addObject(hpUI, tmpX, 485);
    world.addObject(hpICO, tmpX, 410);
    world.addObject(SpammoUI, tmpX, 715);
    world.addObject(SpammoICO, tmpX, 640);

    ammoAdd(Ammos[0], 1500);
    ammoAdd(Ammos[1], 100);
    ammoAdd(Ammos[2], 50);
    ammoChange(playerAmmunition.get(0));
  }