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

2016/12/3

How to put "You Win!!" and "Game Over!" in my game

1
2
Tryxe Tryxe

2016/12/3

#
In line 25 it says "cannot find symbol - variable level" In line 31 it says "cannot find symbol - method levelUp()" Any help?
danpost danpost

2016/12/3

#
Tryxe wrote...
I made some changes, I removed the 'YouWin' and 'GameOver' actors, now they are World subclasses and here's the code: < Code Omitted >
Remove lines 21 through 34 of the YouWin class. The only thing you may want to add to the class is a line to stop the scenario (which is not essential since this is a separate world):
1
2
3
4
5
public YouWin()
{
    super(600, 400, 1);
    Greenfoot.stop();
}
Tryxe Tryxe

2016/12/3

#
Disregard the codes in level one, I removed the added ones which was these: (which means level 1 is back to its original codes) public void act() { getObjects(); } public void getObjects() { if (getObjects(Hero.class).isEmpty()) { showGameOver(); } if (getObjects(Zombie.class).isEmpty()) { if (level == 3) { showYouWin(); } else { levelUp(); } } }
Tryxe Tryxe

2016/12/3

#
So what codes do I put in 'YouWin' and 'GameOver' (They are World subclasses)?
danpost danpost

2016/12/3

#
Tryxe wrote...
So what codes do I put in 'YouWin' and 'GameOver' (They are World subclasses)?
See my last post. Do you have images for those classes? If so, do they already show the text needed for those classes?
Tryxe Tryxe

2016/12/3

#
Yes, I do have images for those classes. I don't know what you mean by show text.
danpost danpost

2016/12/3

#
Tryxe wrote...
Yes, I do have images for those classes. I don't know what you mean by show text.
Do the images already have text like 'Game Over' and 'You Win' in them? If so, then nothing more needs done in those classes.
Tryxe Tryxe

2016/12/3

#
They do, but how will they appear if my Hero is dead or if the game is accomplished?
danpost danpost

2016/12/3

#
Tryxe wrote...
They do, but how will they appear if my Hero is dead or if the game is accomplished?
That is what the code given for your world class does. It tests to see if conditions are right to end the game (or change levels). The methods that are called from there (the 'showGameOver' and 'showYouWin' methods) will have the code to set the new 'YouWin' and 'GameOver' worlds active (which ends the game) -- after you add it, of course.
Tryxe Tryxe

2016/12/3

#
Hahahaha took me a while to get your point but anyways thanks! It works properly now, thank you for being cooperative :)
You need to login to post a reply.
1
2