import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Flagchoose here. * * @author (your name) * @version (a version number or a date) */ public class Flagchoose extends Actor { /** * Act - do whatever the Flagchoose wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ int level=0; int coins=100; public void act() { level++; if (level==1) level1(); } public void level1() { setImage("romania.png"); if (pressed3()==true) {getWorld().removeObject(this); Greenfoot.setWorld(new SnakeWorld());} if (pressed2()==true) coins-=30; if (pressed1()==true) coins-=30; } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------- public boolean pressed1() { boolean pressed; pressed=false; if (Greenfoot.isKeyDown("1")) pressed=true; return pressed; } public boolean pressed2() { boolean pressed; pressed=false; if (Greenfoot.isKeyDown("2")) pressed=true; return pressed; } public boolean pressed3() { boolean pressed; pressed=false; if (Greenfoot.isKeyDown("3")) pressed=true; return pressed; } }