if(getX() >= 3 && getX() <=5 && getY() ==3) { //whatever code you choose Greenfoot.stop(); }
if(getX() >= 3 && getX() <=5 && getY() ==3) { //whatever code you choose Greenfoot.stop(); }
if (getX() == winX1 && getY() == winY1 || getX() == winX2 && getX() == winY2) { // insert code to execute when game is over here }
if(getX() == 17 && getY()==15) { getWorld()).board(); Greenfoot.stop(); } else if(getX() == 18 && getY()==15) { getWorld()).board(); Greenfoot.stop(); }
import java.awt.Color; import java.awt.Font; public static final float FONT_SIZE = 48.0f; public void board() { Font font = getBackground().getFont(); font = font.deriveFont(FONT_SIZE); getBackground().setFont(font); getBackground().setColor(Color.red); getBackground().drawText("You win!",getWidth()/2,getHeight()/2); }
public static final float FONT_SIZE = 48.0f;
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; import java.awt.Font; public static final float FONT_SIZE = 48.0f; public void board() { Font font = getBackground().getFont(); font = font.deriveFont(FONT_SIZE); getBackground().setFont(font); getBackground().setColor(Color.red); getBackground().drawText("You win!",getWidth()/2,getHeight()/2); } /** * A Background. * * @author () * @version (02/05/2012) */ public class background extends World { public background() { super(20, 16, 30);// setBackground("background2.jpg"); populate();//add objects to background } void populate()//add objects to the background area { addObject(new Wall(),0,0); addObject(new Wall(),0,1); addObject(new Wall(),0,2); addObject(new Wall(),0,3); addObject(new Wall(),0,4); addObject(new Wall(),0,5); addObject(new Wall(),0,6); addObject(new Wall(),0,7); addObject(new Wall(),0,8); addObject(new Wall(),0,9); addObject(new Wall(),0,10); addObject(new Wall(),0,11); addObject(new Wall(),0,12); addObject(new Wall(),0,13); addObject(new Wall(),0,14); addObject(new Wall(),0,15); addObject(new Wall(),0,16); addObject(new Wall(),0,17); addObject(new Wall(),0,18); addObject(new Wall(),0,19); addObject(new Wall(),1,0); addObject(new Wall(),2,0); addObject(new Wall(),3,0); addObject(new Wall(),4,0); addObject(new Wall(),5,0); addObject(new Wall(),6,0); addObject(new Wall(),7,0); addObject(new Wall(),8,0); addObject(new Wall(),9,0); addObject(new Wall(),10,0); addObject(new Wall(),11,0); addObject(new Wall(),12,0); addObject(new Wall(),13,0); addObject(new Wall(),14,0); addObject(new Wall(),15,0); addObject(new Wall(),16,0); addObject(new Wall(),17,0); addObject(new Wall(),18,0); addObject(new Wall(),19,0); addObject(new Wall(),19,1); addObject(new Wall(),19,2); addObject(new Wall(),19,3); addObject(new Wall(),19,4); addObject(new Wall(),19,5); addObject(new Wall(),19,6); addObject(new Wall(),19,7); addObject(new Wall(),19,8); addObject(new Wall(),19,9); addObject(new Wall(),19,10); addObject(new Wall(),19,11); addObject(new Wall(),19,12); addObject(new Wall(),19,13); addObject(new Wall(),19,14); addObject(new Wall(),19,15); addObject(new Wall(),19,16); addObject(new Wall(),19,17); addObject(new Wall(),19,18); addObject(new Wall(),19,19); addObject(new Wall(),1,19); addObject(new Wall(),2,19); addObject(new Wall(),3,19); addObject(new Wall(),4,19); addObject(new Wall(),5,19); addObject(new Wall(),6,19); addObject(new Wall(),7,19); addObject(new Wall(),8,19); addObject(new Wall(),9,19); addObject(new Wall(),10,19); addObject(new Wall(),11,19); addObject(new Wall(),12,19); addObject(new Wall(),13,19); addObject(new Wall(),14,19); addObject(new Wall(),15,19); addObject(new Wall(),16,19); addObject(new Character(),1,1); addObject(new Key(),18,10); addObject(new Door(),17,17); addObject(new Door(),18,17); addObject(new InsideWallR(),18,11); addObject(new InsideWallR(),18,9); addObject(new InsideWall(),8,7); addObject(new Key(),9,7); addObject(new InsideWall(),10,7); addObject(new Mummie2(9,8),9,8); addObject(new Mummie2(9,6),9,6); addObject(new InsideWall(),5,1); addObject(new Key(),6,1); addObject(new InsideWall(),7,1); addObject(new Mummie2(6,2),6,2); addObject(new InsideWall(),10,1); addObject(new Key(),11,1); addObject(new InsideWall(),12,1); addObject(new Mummie2(11,2),11,2); addObject(new InsideWallRRR(),2,14); addObject(new Key(),3,14); addObject(new InsideWallRRR(),4,14); addObject(new Mummie2(3,13),3,13); addObject(new InsideWall(),15,1); addObject(new Key(),16,1); addObject(new InsideWall(),17,1); addObject(new Mummie2(16,2),16,2); addObject(new InsideWallR(),18,4); addObject(new Key(),18,5); addObject(new InsideWallR(),18,6); addObject(new Mummie1(),17,5); addObject(new InsideWallRR(),1,4); addObject(new Key(),1,5); addObject(new InsideWallRR(),1,6); addObject(new InsideWallRR(),1,9); addObject(new Key(),1,10); addObject(new InsideWallRR(),1,11); addObject(new Mummie1(),2,5); addObject(new Mummie1(),2,10); addObject(new InsideWallRRR(),7,14); addObject(new Key(),8,14); addObject(new InsideWallRRR(),9,14); addObject(new InsideWallRRR(),12,14); addObject(new Key(),13,14); addObject(new InsideWallRRR(),14,14); addObject(new Mummie2(8,13),8,13); addObject(new Mummie2(13,13),13,13); addObject(new Mummie1(),17,10); } }
import greenfoot.*; import java.awt.Color; import java.awt.Font; /** * A Background. * * @author () * @version (02/05/2012) */ public class background extends World { public static final float FONT_SIZE = 48.0f; public void board() { Font font = getBackground().getFont(); font = font.deriveFont(FONT_SIZE); getBackground().setFont(font); getBackground().setColor(Color.red); getBackground().drawText("You win!",getWidth()/2,getHeight()/2); } public background() { super(20, 16, 30);// setBackground("background2.jpg"); populate();//add objects to background } void populate()//add objects to the background area { addObject(new Wall(),0,0); addObject(new Wall(),0,1); addObject(new Wall(),0,2); addObject(new Wall(),0,3); addObject(new Wall(),0,4); addObject(new Wall(),0,5); addObject(new Wall(),0,6); addObject(new Wall(),0,7); addObject(new Wall(),0,8); addObject(new Wall(),0,9); addObject(new Wall(),0,10); addObject(new Wall(),0,11); addObject(new Wall(),0,12); addObject(new Wall(),0,13); addObject(new Wall(),0,14); addObject(new Wall(),0,15); addObject(new Wall(),0,16); addObject(new Wall(),0,17); addObject(new Wall(),0,18); addObject(new Wall(),0,19); addObject(new Wall(),1,0); addObject(new Wall(),2,0); addObject(new Wall(),3,0); addObject(new Wall(),4,0); addObject(new Wall(),5,0); addObject(new Wall(),6,0); addObject(new Wall(),7,0); addObject(new Wall(),8,0); addObject(new Wall(),9,0); addObject(new Wall(),10,0); addObject(new Wall(),11,0); addObject(new Wall(),12,0); addObject(new Wall(),13,0); addObject(new Wall(),14,0); addObject(new Wall(),15,0); addObject(new Wall(),16,0); addObject(new Wall(),17,0); addObject(new Wall(),18,0); addObject(new Wall(),19,0); addObject(new Wall(),19,1); addObject(new Wall(),19,2); addObject(new Wall(),19,3); addObject(new Wall(),19,4); addObject(new Wall(),19,5); addObject(new Wall(),19,6); addObject(new Wall(),19,7); addObject(new Wall(),19,8); addObject(new Wall(),19,9); addObject(new Wall(),19,10); addObject(new Wall(),19,11); addObject(new Wall(),19,12); addObject(new Wall(),19,13); addObject(new Wall(),19,14); addObject(new Wall(),19,15); addObject(new Wall(),19,16); addObject(new Wall(),19,17); addObject(new Wall(),19,18); addObject(new Wall(),19,19); addObject(new Wall(),1,19); addObject(new Wall(),2,19); addObject(new Wall(),3,19); addObject(new Wall(),4,19); addObject(new Wall(),5,19); addObject(new Wall(),6,19); addObject(new Wall(),7,19); addObject(new Wall(),8,19); addObject(new Wall(),9,19); addObject(new Wall(),10,19); addObject(new Wall(),11,19); addObject(new Wall(),12,19); addObject(new Wall(),13,19); addObject(new Wall(),14,19); addObject(new Wall(),15,19); addObject(new Wall(),16,19); addObject(new Character(),1,1); addObject(new Key(),18,10); addObject(new Door(),17,17); addObject(new Door(),18,17); addObject(new InsideWallR(),18,11); addObject(new InsideWallR(),18,9); addObject(new InsideWall(),8,7); addObject(new Key(),9,7); addObject(new InsideWall(),10,7); addObject(new Mummie2(9,8),9,8); addObject(new Mummie2(9,6),9,6); addObject(new InsideWall(),5,1); addObject(new Key(),6,1); addObject(new InsideWall(),7,1); addObject(new Mummie2(6,2),6,2); addObject(new InsideWall(),10,1); addObject(new Key(),11,1); addObject(new InsideWall(),12,1); addObject(new Mummie2(11,2),11,2); addObject(new InsideWallRRR(),2,14); addObject(new Key(),3,14); addObject(new InsideWallRRR(),4,14); addObject(new Mummie2(3,13),3,13); addObject(new InsideWall(),15,1); addObject(new Key(),16,1); addObject(new InsideWall(),17,1); addObject(new Mummie2(16,2),16,2); addObject(new InsideWallR(),18,4); addObject(new Key(),18,5); addObject(new InsideWallR(),18,6); addObject(new Mummie1(),17,5); addObject(new InsideWallRR(),1,4); addObject(new Key(),1,5); addObject(new InsideWallRR(),1,6); addObject(new InsideWallRR(),1,9); addObject(new Key(),1,10); addObject(new InsideWallRR(),1,11); addObject(new Mummie1(),2,5); addObject(new Mummie1(),2,10); addObject(new InsideWallRRR(),7,14); addObject(new Key(),8,14); addObject(new InsideWallRRR(),9,14); addObject(new InsideWallRRR(),12,14); addObject(new Key(),13,14); addObject(new InsideWallRRR(),14,14); addObject(new Mummie2(8,13),8,13); addObject(new Mummie2(13,13),13,13); addObject(new Mummie1(),17,10); } }
if(getX() == 17 && getY()==15) { getWorld()).board(); Greenfoot.stop(); } else if(getX() == 18 && getY()==15) { getWorld()).board(); Greenfoot.stop(); }
if(getX() == 17 && getY()==15) { ((background)getWorld()).board(); Greenfoot.stop(); } else if(getX() == 18 && getY()==15) { ((background)getWorld()).board(); Greenfoot.stop(); }
if(getX() == 17 && getY()==15) { getWorld()).board(); Greenfoot.stop(); } else if(getX() == 18 && getY()==15) { getWorld()).board(); Greenfoot.stop(); }