-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameOverWorld.java
More file actions
54 lines (47 loc) · 1.76 KB
/
GameOverWorld.java
File metadata and controls
54 lines (47 loc) · 1.76 KB
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
44
45
46
47
48
49
50
51
52
53
54
import greenfoot.*;
/**
* Write a description of class GameOverWorld here.
*
* @author Patrik Valentiny (PM), Jakov Klaric, Abdulkader Alomar, Ignas Klimas
* @version 1.2
*/
public class GameOverWorld extends World
{
private static final int WORLD_WIDTH = 500;
private static final int WORLD_HEIGHT = 700;
private int timer = 0;
private GreenfootImage background = getBackground();
private boolean up = true;
/**
* Constructor for objects of class GameOverWorld.
*/
public GameOverWorld(int i)
{
super(WORLD_WIDTH, WORLD_HEIGHT, 1);
}
public void act()
{
background.clear();
String key = Greenfoot.getKey();
if (key != null && key.equals("enter"))
{
Greenfoot.setWorld(new PingWorld(true));
}
if (timer == 255){
up = false;
} else if (timer == 0){
up = true;
}
if (up){
timer++;
} else{
timer--;
}
background.setColor(new Color(255 - timer, 255 - timer, 255 - timer));
background.fill();
//background.drawImage(new GreenfootImage("PONG", 80, new Color(timer, timer, timer), null), 150, 200);
//background.drawImage(new GreenfootImage("It is a murder scene", 20, new Color(timer, timer, timer), null), 140, 300);
background.drawImage(new GreenfootImage("Hit <enter> to restart game", 30, new Color(timer, timer, timer), null), 120, WORLD_HEIGHT / 2);
//background.drawImage(new GreenfootImage("Controls: \n- LEFT and RIGHT arrow keys control the paddle`s direction\n- UP and DOWN arrow keys control the paddle`s speed", 15, new Color(timer, timer, timer), null), 80, WORLD_HEIGHT / 2 + 100);
}
}