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>(); }
public void scrollSpikes() { for (Spikes i : spikeList) { i.setY(i.getY() + (int) (player1.getVelocity() * 0.3)); } }
public void drawSpike(Graphics g) { for (Spikes i : spikeList) { g.drawImage(i.getImage(), i.getX(), i.getY(), i.getWidth(), i.getHeight(), null); } }