-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScore.java
More file actions
87 lines (82 loc) · 2.89 KB
/
Copy pathScore.java
File metadata and controls
87 lines (82 loc) · 2.89 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.awt.Graphics;
import java.awt.Font;
import java.awt.Color;
import java.awt.GraphicsEnvironment;
import java.awt.FontFormatException;
import java.io.File;
import java.io.IOException;
public class Score extends Thing {
GamePanel gp;
int pScore;
int interval;
boolean isListening;
Font font;
public Score( GamePanel g, int xPos, int yPos ) {
isListening = false;
pScore = 0;
this.gp = g;
this.x = xPos;
this.y = yPos * g.tileSize;
try {
font = Font.createFont(Font.TRUETYPE_FONT,new File("munro.ttf")).deriveFont(40f);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT,new File("munro.ttf")));
}
catch ( FontFormatException e ) {
e.printStackTrace();
}
catch ( IOException e ) {
e.printStackTrace();
}
}
public Score( GamePanel g, int xPos, int yPos, int s ) {
this.pScore = s;
this.gp = g;
this.x = xPos * g.tileSize;
this.y = yPos * g.tileSize;
try {
font = Font.createFont(Font.TRUETYPE_FONT,new File("munro.ttf")).deriveFont(40f);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT,new File("munro.ttf")));
}
catch ( FontFormatException e ) {
e.printStackTrace();
}
catch ( IOException e ) {
e.printStackTrace();
}
}
public void checkScore(Timer t, Kid k) {
if( k.stat == Kid.Status.APPROVED && t.labelText > 0 && isListening ) {
pScore += t.labelText + k.orderSize;
isListening = false;
}
else if ( t.labelText == 0 && isListening ) {
pScore -= k.orderSize;
isListening = false;
}
}
public void draw(Graphics g) {
g.setFont(font);
g.setColor(Color.BLACK);
g.drawString(String.valueOf(pScore), this.x, this.y);
}
public void drawEndScore(Graphics g) {
g.setFont(font);
g.setColor(Color.BLACK);
g.drawString("SCORE: ", this.x - 22, this.y - gp.tileSize );
g.drawString(String.valueOf(pScore), this.x + 15, this.y);
}
public void drawHighScore(Graphics g, String stringScore) {
g.setFont(font);
g.setColor(Color.BLACK);
g.drawString("HIGH SCORE: ", this.x - 53, this.y - gp.tileSize );
g.drawString("HIGH SCORE: ", this.x - 57, this.y - gp.tileSize );
g.drawString("HIGH SCORE: ", this.x - 54, (this.y - gp.tileSize) + 2 );
g.drawString("HIGH SCORE: ", this.x - 54, (this.y - gp.tileSize) - 2 );
g.setColor(new Color(255,233,0));
g.drawString("HIGH SCORE: ", this.x - 55, this.y - gp.tileSize );
g.setColor(Color.BLACK);
g.drawString(stringScore, this.x + 15, this.y);
}
}