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

2012/1/1

Scoreboard

1
2
programmer22 programmer22

2012/1/1

#
OK ive asked this question about 3 times how can i make my scoreboard appear at the end of my game?
danpost danpost

2012/1/1

#
Create it at the beginning of the program, giving it a small transparent image (invisible). Then, when game over, change the image! Or, create the object at the beginning, but do not add it to the world, until Game Over! (Of course, if you are showing a score also, you still will have to adjust the image). You can create it in the variable declaration segment of the world, as follows:
public Scoreboard scoreboard = new Scoreboard();
danpost danpost

2012/1/1

#
Of course, you could wait till Game Over to create it also, as follows:
GameWorld gw = (GameWorld) getWorld();
Scoreboard scoreboard = new Scoreboard();
gw.addObject(scoreboard, xLocation, yLocation);
Greenfoot.stop();
programmer22 programmer22

2012/1/2

#
would i add that in world or in the score board actor?
danpost danpost

2012/1/2

#
I wrote it for any actor but the scoreboard, since you would not be in the scoreboard when you determine game over. If you determine game over in the world class, just eliminate the first line and the first 3 characters in the third line.
programmer22 programmer22

2012/1/3

#
i know im asking alot but how would i declare game over ?
danpost danpost

2012/1/3

#
That would depend on your game! Ask yourself, what conditions need to be met to declare 'GAME OVER'. Then put that in code
if (conditionsAreMet == true)
{
    // game over code here
}
If there are several conditions that have to be met, create a method
public boolean isGameOver()
{
    if (condition1 != true) return false;
    if (condition2 != true) return false;
    //  etc.
    if (conditionN != true) return false;
    return true;
}
and call it with
if (isGameOver())
programmer22 programmer22

2012/1/3

#
well my games about eating worms and if your eaten by a lobster u lose, so i would put something like if crab is eaten in those condition spots?
danpost danpost

2012/1/3

#
if (getOneIntersectingObject(Lobster.class) != null)
in your crab class
programmer22 programmer22

2012/1/3

#
ok thanks if i have any problems ill post
danpost danpost

2012/1/3

#
you could say
if (seeLobster())
and make the method
public boolean seeLobster()
{
    return (getOneIntersectingObject(Lobster.class) != null);
}
programmer22 programmer22

2012/1/3

#
so how could i declare what the condition is? or would that ^ be the condition?
danpost danpost

2012/1/3

#
The condition is if the lobster and the crab come together (or intersect) then the lobster will eat the crab and the game is over. So...yeah, if one intersecting object of lobster class is true for your crab class object...!
programmer22 programmer22

2012/1/3

#
ok thanks =D
programmer22 programmer22

2012/1/3

#
the first section of code you put with the conditon i put that in world and the third section with the see lobster i would put that in the same spot or diffrent ?
There are more replies on the next page.
1
2