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

2021/10/20

Web version different from original

Windeycastle Windeycastle

2021/10/20

#
https://www.greenfoot.org/scenarios/28695 In this little game it does not show up "Draw" or "Crosses wins" or "Noughts wins", instead it immediatly reset. In Greenfoot on the pc it works fine. Does someone know why?
Gbasire Gbasire

2021/10/20

#
I believe you need to press "enter" when the game is done to reset it, I think it does directly reset it because of that. I would put a little timer (an int variable that you can increment, and when it reaches at least 20 it will reset) Example :
//if there is a variable called "finished" and a method called "finished()"
public int timer;

public void act()
{
    if(finished)
        timer++;
}

public void finished()
{
    if(timer > 20 && Greenfoot.isKeyDown("enter"))
        Greenfoot.stop(); 
        //or any other method to restart the game
}
danpost danpost

2021/10/20

#
You probably should not use the same key ("enter") as that which caused the game over actor to be placed into the world as it would trigger immediately to go to new game.
danpost danpost

2021/10/20

#
Also, using wait to cause a delay is not the way to go. Using Greenfoot.delay(int) would be better. However, I think the idea of a while loop in the game over actor is too much. Just make use of the act method:
public void act()
{
    if (Greenfoot.isKeyDown("escape")) Greenfoot.setWorld(new MyWorld());
}
Windeycastle Windeycastle

2021/10/21

#
Ok, thank you both for the suggestions! I'm always open for some feedback!
Windeycastle Windeycastle

2021/10/22

#
Seems like I'll have to redo it for a big part to organise it better.
You need to login to post a reply.