-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter.java
More file actions
26 lines (23 loc) · 772 Bytes
/
Counter.java
File metadata and controls
26 lines (23 loc) · 772 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
import java.awt.*;
public class Counter implements Constants {
// x and y are the coordinates of the top left corner of the block
private final int x;
private final int y;
private final int width;
private final int height;
public int count = COUNTDOWN;
public Counter(int x, int y) { // Constructor
this.x = x;
this.y = y;
this.width = SIZE;
this.height = this.width * 8;
}
// Draw the block
public void draw(Graphics g) {
g.setColor(red);
g.fillRect(this.x, this.y, width, height);
g.setColor(green);
g.fillRect(this.x, this.y + height - (int) (height * ((double) count / COUNTDOWN)),
width, (int) (height * ((double) count / COUNTDOWN)));
}
}