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

2011/6/14

Battling by score?

19c3 19c3

2011/6/14

#
HI! I recently uploaded a game with my computer science class and i have a idea for the game, but i'm confused on how to do it. My goal would be to have a sort of "face off" at the game of the game where the person with the highest score would be able to kill the other player to win the game. If it helps, i have a "counter" class where my scoreboard guts are in and then scoreboard is called invidiously by both players in there respected subclass of Actor. Thanks in advance! -Riley
DonaldDuck DonaldDuck

2011/6/15

#
Your player should keep score of it's own points respectively as it does whatever to gain points. Just have a variable for the players points in the player class, and the world class, and in the act method, send the variable across.
public void act()
{
     ((myWorld) getWorld()).player_1_score = score;
}
Use a simple if statement to find which score is bigger, and allow that player to win.
You need to login to post a reply.