-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tile.java
38 lines (33 loc) · 1.09 KB
/
Tile.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
package Game2048.Tile;
import java.awt.Color;
public class Tile {
public int value;
public Tile() {
this(0);
}
public Tile(int num) {
value = num;
}
public boolean isEmpty() {
return value == 0;
}
public Color getForeground() {
return value < 16 ? new Color(0x776e65) : new Color(0xf9f6f2);
}
public Color getBackground() {
switch (value) {
case 2: return new Color(0xeee4da);
case 4: return new Color(0xede0c8);
case 8: return new Color(0xf2b179);
case 16: return new Color(0xf59563);
case 32: return new Color(0xf67c5f);
case 64: return new Color(0xf65e3b);
case 128: return new Color(0xedcf72);
case 256: return new Color(0xedcc61);
case 512: return new Color(0xedc850);
case 1024: return new Color(0xedc53f);
case 2048: return new Color(0xedc22e);
}
return new Color(0xcdc1b4);
}
}