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

2013/6/6

How can I make a winning code for the end of the level?

derp2000 derp2000

2013/6/6

#
I can't find a code that stops the game when you reach the last part of the field. Just like in the frogger game.
GreenGoo GreenGoo

2013/6/6

#
Please can you specify what it is you are trying to do.
MrCohen MrCohen

2013/6/6

#
If you really want to end the game, try this: Within the World:
if (myMainActor.getY() <= 1)
{
    Greenfoot.stop();
}
If you want to do something other than end the game, you should put the code you want to run in the output of the if statement instead of Greenfoot.stop(). Hope that helps
derp2000 derp2000

2013/6/9

#
Like in the frogger game, when you reached the end the game says you have won, how do i make that?
MrCohen MrCohen

2013/6/9

#
First you need to set up the condition, as I did in my code above. Then you need something to do when the game ends. I suggest the easiest way is to draw a picture in Paint that you want to display. Create an Actor with no code in it set to your painted image. Finally, when you detect that the player has achieved your goal, display that new Actor on the Screen and call Greenfoot.stop(). That's the easiest way. There are many better and more interesting ways to end a game but try this as a starting point.
You need to login to post a reply.