This site requires JavaScript, please enable it in your browser!
Greenfoot back
nojamo66
nojamo66 wrote ...

2018/1/14

Change world level when I reach a certain score

nojamo66 nojamo66

2018/1/14

#
Hello, I just need help for a touch and avoid game. Can someone help me make a script for when I reach a certain value, then it changes to another world, and if in the 2nd world I get a certain score then the game ends. Here's my code in my world,
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Game2 here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Game1 extends World
{
    Counter counter = new Counter();
    /**
     * Constructor for objects of class Game2.
     * 
     */
    public Game1()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(600, 400, 1);
        addObject(new Gazelle(), Greenfoot.getRandomNumber(getWidth()), Greenfoot.getRandomNumber(getHeight()));    
        addObject(new Lion(), Greenfoot.getRandomNumber(getWidth()), Greenfoot.getRandomNumber(getHeight()));
        addObject (counter, 100, 40);
        for (int x= 0; x < 10; x++)
        {
             addObject(new Flower(), Greenfoot.getRandomNumber(getWidth()), Greenfoot.getRandomNumber(getHeight()));
        }
        
    }
    
    public Counter getCounter()
    {
        return counter;
    }
}
xbLank xbLank

2018/1/14

#
I do not really understand the problem to be honest. What are you failing at? You didn't even show us what you have tried so far. Its like you want us to do all the work.
nojamo66 nojamo66

2018/1/14

#
Sorry about that I’m just a newbie at java so I wasn’t sure what to do now I solved it.
일리아스 wrote...
I do not really understand the problem to be honest. What are you failing at? You didn't even show us what you have tried so far. Its like you want us to do all the work.
You need to login to post a reply.