-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextRenderer.java
More file actions
30 lines (25 loc) · 868 Bytes
/
TextRenderer.java
File metadata and controls
30 lines (25 loc) · 868 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
import mayflower.*;
import java.util.HashMap;
/**
* Helper class to dynamically change the color of the text and remember it based on the current world
*/
public class TextRenderer {
private final World w;
private final Color color;
public TextRenderer(World wo) {
w = wo;
HashMap<Class<? extends World>, Color> mappings = new HashMap<>();
mappings.put(LevelOne.class, Color.BLACK);
mappings.put(LevelTwo.class, Color.WHITE);
mappings.put(LevelThree.class, Color.CYAN);
mappings.put(GameOverLose.class, Color.RED);
mappings.put(GameOverWin.class, Color.GREEN);
color = (Color) mappings.get(w.getClass());
}
public void showText(String t, int x, int y) {
w.showText(t, x, y, color);
}
public void removeText(int x, int y) {
w.removeText(x, y);
}
}