-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java
More file actions
40 lines (33 loc) · 923 Bytes
/
Game.java
File metadata and controls
40 lines (33 loc) · 923 Bytes
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
import greenfoot.*;
/**
* This class contains variables and controls the game
*
* @author Manuel Kienlein
*/
public class Game
{
public static final int MAX_SCORE = 100;
public static int score;
public static int worldWidth;
public static int worldHeight;
public static boolean gameStopped = false;
public static void gameOver(){
Greenfoot.playSound("fanfare.wav");
int centerX = worldWidth/2;
int centerY = worldHeight/2;
Toast.setText("GAME OVER");
Thread thread = new Thread(){
public void run(){
try{Thread.sleep(4000);}catch(Exception e){}
Greenfoot.stop();
}
};
gameStopped = true;
thread.start();
}
public static void reset()
{
Game.gameStopped = false;
Game.score = 0;
}
}