public void explosion() { if(Greenfoot.mouseClicked(this)) { getWorld().removeObject(this); } else { if(itimeTillDetonation > 40) { soundc.play(); getWorld().removeObject(this); Greenfoot.stop(); } } }
public void explosion() { if(Greenfoot.mouseClicked(this)) { getWorld().removeObject(this); } else { if(itimeTillDetonation > 40) { soundc.play(); getWorld().removeObject(this); Greenfoot.stop(); } } }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Bombe here. * * @author (your name) * @version (a version number or a date) */ public class Bombe extends Actor { public int iGameOver = 0; public int iTime = 0; public int itimeTillDetonation = 0; GreenfootSound soundb = new GreenfootSound("BackgroundMusic.wav"); GreenfootSound soundc = new GreenfootSound("Explosion.wav"); /** * Act - do whatever the Bombe wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { explosion(); itimeTillDetonation++; iTime++; gameOver(); iGameOver++; } public void explosion() { soundb.play(); if(iTime > 1200) { soundb.stop(); } if(Greenfoot.mouseClicked(this)) { getWorld().removeObject(this); } else { if(itimeTillDetonation > 100) { soundb.stop(); soundc.play(); getWorld().removeObject(this); Greenfoot.stop(); } } } //Beende Spiel nach ca. 1min public void gameOver() { if(iGameOver > 1200) { Greenfoot.stop(); } } }