-
Notifications
You must be signed in to change notification settings - Fork 1
/
messageBoard.java
71 lines (62 loc) · 1.86 KB
/
messageBoard.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class messageBoard here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class messageBoard extends Actor
{
String lastDraw = "hello, world";
long h = 0;
int i = 0;
int time = 0;
public void messageBoard(){
setImage("images/msgboard.png");
//test
}
/**
* Act - do whatever the messageBoard wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
//printOut("*insert Megalovania at this point");
}
public void printOut(String toDraw){
setImage("msgboard.png");
lastDraw = toDraw;
reload();
this.getImage().setColor(Color.WHITE);
this.getImage().setFont(new Font("Verdana",false,false,20));
getImage().drawString(toDraw,40,60);
}
public void displayCounter(int duration){
printOut(lastDraw);
this.getImage().setColor(Color.WHITE);
this.getImage().setFont(new Font("Verdana",false,false,20));
long g = System.currentTimeMillis();
while (h != g + 1000){
h = System.currentTimeMillis();
}
i++;
reload();
if(i < duration){
time = duration - i;
}
String cTime = Integer.toString(time);
getImage().drawString(cTime,50,90);
if(i != duration){
displayCounter(time -1);
}
}
protected void addedToWorld(World world)
{
setImage("images/msgboard.png");
world = getWorld();
}
public void reload(){
this.getImage().clear();
this.setImage("images/msgboard.png");
}
}