-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathGameOver.java
More file actions
executable file
·51 lines (44 loc) · 1.67 KB
/
Copy pathGameOver.java
File metadata and controls
executable file
·51 lines (44 loc) · 1.67 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class GameOver here.
*
* @author (João Paulo S. Abreu (joaoabreu@ufba.br), Mateus C. Moura
* (mateuschaves@ufba.br), Rafael P. Casaes Sampaio
* (rafael.casaes@ufba.br),
* Uanderson S. Celestino (uandersoncelestino@ufba.br), Lílian T. de
* Sousa (lilian.sousa@ufba.br), Jefferson Aimon de B. Silva
* (jefferson.raimon@ufba.br))
* @version (a version number or a date)
*/
public class GameOver extends AllObjects {
/**
* Act - do whatever the GameOver wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
//constantes para formatação da mensagem
public static final float SIZE_FONT = 48.0f;
public static final int WIDTH = 400;
public static final int HEIGHT = 300;
//metodo que chama a mensagem instanciada
public GameOver(String message) {
makeImage(message);
}
//metodo para a criação da mensagem
private void makeImage(String message) {
GreenfootImage image = new GreenfootImage(WIDTH, HEIGHT);
image.setColor(new Color(0, 0, 0, 160));
image.fillRect(5, 5, WIDTH, HEIGHT);
image.setColor(new Color(255, 255, 255, 100));
image.fillRect(5, 5, WIDTH, HEIGHT);
Font font = image.getFont();
font = font.deriveFont(SIZE_FONT);
image.setFont(font);
image.setColor(Color.WHITE);
image.drawString(message, 60, 100);
setImage(image);
}
@Override
public void act() {
// Add your action code here.
}
}