Exemple #1
0
  private void verifyCrashes() {
    borderCrash(ball);

    // CRASHES TO THE SHIPBALL FALLING DOWN
    if ((ball.getYC() + ball.getRadio()) >= ship.sideY1 && ball.getDY() >= 0) {
      ship.shipCrash(ball);
    }
    // CRASHES TO THE WALL  WITH BALL
    boolean cmpSideY2 = (ball.getYC() - ball.getRadio()) <= wall.sideY2 && ball.getDY() <= 0;
    boolean cmpSideY1 = (ball.getYC() + ball.getRadio()) >= wall.sideY1 && ball.getDY() >= 0;
    if (cmpSideY1 || cmpSideY2) {
      wall.blockListCrashes(ball);
    }
  }
Exemple #2
0
  private void shipCrash(Ball ball) {

    ArrayList<Integer> lr = getPointListUp(ball.getRadio(), ball.getXC(), ball.getYC());
    int r2 = (int) Math.pow(ball.getRadio(), 2);

    if (lr.contains(r2) && ball.getDY() >= 0) {
      ball.setDY(ball.getDY() * -1);
      ball.setAllFirst();
    }
  }
Exemple #3
0
  public void run() {
    try {
      ball = new Ball(10, 500, 660, -1, -1, Color.white);
      ship = new Ship(500, 685, 120, 30, Color.cyan);

      wall.fillBockList();
      wall.blockListUpdatepoints();
      // sound.soundtrack();

      margin();
      while (true) {
        System.out.println(min);
        // playMusic();
        try {
          // System.out.println("\n");
          // graphDB.fillRect(0,0, width, height);
          graphDB.clearRect(26, 47, getWidth() - 326, getHeight() - 72);

          // CRASHES

          verifyCrashes();
          // borderCrash(ball);
          // ship.shipCrash(ball);
          // wall.blockListCrashes(ball);

          // UPDATE ELEMENTS
          wall.blockListKill(ship);
          ball.wayCalculator();
          wall.boomListUpdate();

          ship.move();
          ship.updateGuns();
          ship.updatePoints(); // save ship points

          // PAINT ELEMENTS
          ship.paintAllGuns(graphDB);
          ship.paintShip(graphDB);
          ball.paintBall(graphDB, ball.getRadio(), ball.getXC(), ball.getYC());
          wall.paintBlockList(graphDB);
          // --wall.painBlockMaze(graphDB);
          // efects
          wall.boomEfect(graphDB);

          repaint();
          sleep(5);
        } catch (InterruptedException ex) {
          System.out.println("there is a error  in the while.....!!!!");
        }
      }
    } catch (Exception e) {
      System.out.println("there is a error!!!!");
    }
  }
Exemple #4
0
 private void borderCrash(Ball ball) {
   if (ball.getYC() <= 57 && ball.getDY() < 0) {
     ball.setDY(ball.getDY() * -1);
     ball.setAllFirst();
     // sound.crash();
   }
   if (ball.getYC() >= (height - 36) && ball.getDY() > 0) {
     ball.setDY(ball.getDY() * -1);
     ball.setAllFirst();
     // sound.crash();
   }
   if (ball.getXC() <= 36 && ball.getDX() < 0) {
     ball.setDX(ball.getDX() * -1);
     ball.setAllFirst();
     // sound.crash();
   }
   if (ball.getXC() >= (width - 11) && ball.getDX() > 0) {
     ball.setDX(ball.getDX() * -1);
     ball.setAllFirst();
     // sound.crash();
   }
 }