What i want to achieve is: if my bomb is at the edge of the screen, AND if my player is already dead, the lose screen will appear. I'm just not sure how to put in the specific location (x,y) for the bomb. Can someone please help?
Here's the code to better understand:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Bomb here. * * @author (your name) * @version (a version number or a date) */ public class Bomb extends Obstacles { GreenfootSound deathsfx = new GreenfootSound("smb_mariodie.wav"); /** * Act - do whatever the Bomb wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move(-6); // check hit player Start player = (Start) getOneIntersectingObject(Start.class); if (player != null) { getWorld().removeObject(player); deathsfx.play(); return; } int gapX = 1; Bomb bomb = (Bomb) getOneIntersectingObject(Bomb.class); if (getX() >= getWorld().getWidth()-gapX || getX() <= gapX) { getWorld().removeObject(this); } else if (bomb(??) && (player == null)) { Level.bgMusic.pause(); Greenfoot.setWorld(new Loser()); } } }