Examples of AlienShot


Examples of oop13.space.model.AlienShot

   * and adds a new alien shot.
   */
  private void alienShot() {
    Alien a = model.getAliens().getShooter();
    if (a != null) {
      AlienShot shot = a.fire();
      model.addAlienShot(shot);
            shot.moveIndividual(a.getPositionX() + SHOT_STEP, a.getPositionY());
    }
  }
View Full Code Here

Examples of oop13.space.model.AlienShot

  public void run() {
    while (!this.spaceShip.isDead()) {
      if (System.currentTimeMillis() - time >= TIME_AFTER_SHOT) {
        time = System.currentTimeMillis();
        int x = ((int) (Math.random() * MAX_RANDOM_NUMBER)) * MULTIPLE;
        AlienShot alShot = new AlienShot((int) x, 0);
        this.listIndividuals.add(alShot);
      }
      for (Individual ind : this.listIndividuals) {
        ind.moveIndividual(ind.getPositionX(), ind.getPositionY());
        ind.collideWith(this.listIndividuals);
View Full Code Here

Examples of oop13.space.model.AlienShot

    this.alien3 = new Alien(new AlienType(3), startPositionX, POSITION_Y);
    startPositionX += DELTA_X;
    this.alien4 = new AlienMotherShip();
    this.alien4.moveTo(startPositionX, POSITION_Y);
    startPositionX += DELTA_X;
    this.alienShot = new AlienShot(startPositionX, POSITION_Y);
    startPositionX += DELTA_X;
    this.wall = new Wall(startPositionX);
    this.wall.moveTo(startPositionX, POSITION_Y);

    this.listIndividuals.add(spaceShip);
View Full Code Here

Examples of oop13.space.model.AlienShot

    }
    Assert.assertEquals(model.getList().size(), 75);
    AlienMotherShip motherShip = model.addMotherShip();
    Assert.assertEquals(model.getList().size(), 76);
    for (int i = 0; i < 5; i++) {
      AlienShot alienShot = model.addAlienShot(new AlienShot(10, i));
      Assert.assertTrue(model.getList().contains(alienShot));
    }
    Assert.assertEquals(model.getList().size(), 81);
    Assert.assertTrue(model.getList().contains(motherShip));
  }
View Full Code Here

Examples of oop13.space.model.AlienShot

    spaceShip.increaseLives();
    Assert.assertTrue(spaceShip.getLives() == 2);
    spaceShip.decreaseLives();
   
    //Testing collisions AlienShot -> Ship and Shot -> Alien
    model.getList().add(new AlienShot(spaceShip.getPositionX(), spaceShip.getPositionY()));
    ShipShot shot = new ShipShot(10, 50);
    model.getList().add(shot);
    shot.collideWith(model.getList());
    spaceShip.collideWith(model.getList());
    Assert.assertTrue(spaceShip.isDead());
    Assert.assertTrue(shot.isDead());
    int individualsKilled = 0;
    for (Individual ind : model.getList()) {
      if (ind.isDead()) {
        individualsKilled++;
      }
    }
    Assert.assertTrue(individualsKilled == 4); //Individuals dead: alienShot, shot, ship and an alien
    for (Individual ind : model.getList()) {
      if (ind.getPositionX() == 10 && ind.getPositionY() == 50) {
        Assert.assertTrue(ind.isDead());
      }
    }
   
    //Testing collisions Shot -> Wall and Alien shot -> Wall
    ShipShot shipShot = new ShipShot(40, 450);
    Wall wallKicked = null;
    model.getList().add(shipShot);
    for (Wall wall : model.getWalls().getList()) {
      wall.collideWith(model.getList());
    }
    for (Wall wall : model.getWalls().getList()) {
      if (wall.getPositionX() == 40 && wall.getPositionY() == 450) {
        wallKicked = wall;
      }
    }
    Assert.assertTrue(wallKicked.getLives() == 1);
    model.getList().remove(shipShot);
    AlienShot alienShot = new AlienShot(35, 450);
    model.getList().add(alienShot);
    wallKicked.collideWith(model.getList());
    Assert.assertTrue(wallKicked.getLives() == 0);
    Assert.assertTrue(wallKicked.isDead());
   
    //Testing collisions Shot -> Alien Shot
    model.getList().add(shipShot);
    alienShot.collideWith(model.getList());
    Assert.assertTrue(shipShot.isDead());
    Assert.assertTrue(alienShot.isDead());
   
    //Testing score when aliens die
    model.resetStatistics();
    Alien alien1 = new Alien(new AlienType(1), 50, 30);
    Alien alien2 = new Alien(new AlienType(2), 80, 30);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.