import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class SpikedPlattform here. * * @author (your name) * @version (a version number or a date) */ public class SpikedPlattform extends Plattform { int SpikeCountdown; boolean spikesActivated=false; boolean isSpiked=false; Spike[] hasSpikes= new Spike[5]; public SpikedPlattform(int pSpikeCountdown) { SpikeCountdown=pSpikeCountdown; } /** * Act - do whatever the SpikedPlattform wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { // Add your action code here. if(this.PlayerOnPlattform() && spikesActivated== false) { this.activateSpikes(); } if(spikesActivated) { SpikeCountdown--; } if(SpikeCountdown==0) { this.spikeTheSurface(); } if(isSpiked && this.PlayerOnPlattform()) { MyWorld world = (MyWorld) getWorld(); Greenfoot.setWorld(new GameOverWorld(world.score)); } super.act(); } public void activateSpikes() { spikesActivated=true; MyWorld theWorld= (MyWorld) this.getWorld(); for(int i=-6; i<7; i++) { theWorld.addObject(new UnactiveSpike(2,SpikeCountdown, this ), this.getX()+i* (this.getImage().getWidth()/13), this.getY()-(this.getImage().getHeight()/2)); } //Sound //setImage } public void spikeTheSurface() { isSpiked=true; //Soun) //setImage } }