-
Notifications
You must be signed in to change notification settings - Fork 1
/
score.java
43 lines (37 loc) · 818 Bytes
/
score.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Score counter class
* Count the current score for the game
*
* @author github.com/fiekzz
* @version 4 June 2022
*/
public class score extends Actor
{
// static score
private static int score = 0;
// score constructor
public score()
{
}
public void act()
{
// display the current score
World myWorld = getWorld();
myWorld.showText(String.valueOf(score), 600, 200);
}
// setter for the score counter
public static void add(int num)
{
score += num;
}
// get the current score
public static int getCurrentScore()
{
return score;
}
public void resetScore()
{
this.score = 0;
}
}