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

2020/10/13

how can I add score to both characters?

sxgdfhcjvk sxgdfhcjvk

2020/10/13

#
so im making my own game now and I have to count score for both of the characters, does anyone know hot to do that?
RcCookie RcCookie

2020/10/13

#
Each Character is an instance of a class, for example named „Player“. Now add a variable to Player that counts the score, for example:
public class Player {
    private int score = 0;

    public void increaseScore(int amount) {
        score += amount;
    }

    public int getScore() {
        return score;
    }
}
danpost danpost

2020/10/13

#
sxgdfhcjvk wrote...
so im making my own game now and I have to count score for both of the characters, does anyone know hot to do that?
This is vague, without any attempted codes. Also, are the scores to be displayed or not?
You need to login to post a reply.