I'm making my own form of a battleship game where you only have a certain amount of guesses. This may not be the most efficient way but my ships spawn randomly on my background. Anywhere the ships are not placed an actor that displays the word "miss" is placed. On top of that a tile is placed on each space covering the board no matter what is underneath. The tile disappears if you click on it, leaving you with part of a ship or "miss."
I'm attempting to count the number of tiles that are clicked and removed using
I am then attempting to use int M to transfer to the lose screen using
This is all contained inside my main world.
My problem is that I am still able to play once I've clicked 25 squares.
Thanks in advance!
public void count()
{
if(Greenfoot.mouseClicked(Tiles.class))
{
M++;
}
}
public void end()
{
if (M == 25)
{
new Lose();
}
}

