Exemplo n.º 1
0
 public void checkSpikeCollision() { // checks the spike collision
   for (Spikes s : spikeList) {
     if (s.getOnScreen()) { // if the spike is on the screen
       if (s.checkCollision(s.getImage(), player1)) { // if the user collides with the spike
         if (player1.getInvi() == false) { // if player is not invisiblity
           player1.setSpikeVelo(); // set the spike velocity
           loseCoins();
           player1.setDown(true);
         }
         spRemove.add(s);
       }
     } else {
       spRemove.add(s); // remove the spike
     }
   }
   for (Spikes s : spRemove) {
     spikeList.remove(s);
   }
   spRemove = new ArrayList<Spikes>();
 }
Exemplo n.º 2
0
 public void drawSpike(Graphics g) {
   for (Spikes i : spikeList) {
     g.drawImage(i.getImage(), i.getX(), i.getY(), i.getWidth(), i.getHeight(), null);
   }
 }