-
Notifications
You must be signed in to change notification settings - Fork 0
/
Estrella.java
95 lines (82 loc) · 2.57 KB
/
Estrella.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import java.awt.Color;
import java.awt.Graphics;
public abstract class Estrella {
int x, y, v, SIZE_PIXEL = 1;
Color LIGHT_GREY = new Color(204, 204, 204);
Color GREY = new Color(153, 153, 153);
Color DARK_GREY = new Color(102, 102, 102);
Color VERY_DARK_GREY = new Color(51, 51, 51);
Color GOLD = new Color(255, 204, 51);
Color TRANSPARENT =new Color(0f, 0f, 0f, 0f);
abstract void moure();
abstract void pinta(Graphics g);
}
class EstrellaTitilante extends Estrella {
EstrellaTitilante(int x, int y, int v) {
this.x = x;
this.y = y;
this.v = v;
}
void moure() {
x -= v;
}
int[][] colMat1 = {
{-1,-1,-1,-1,-1,-1,-1,},
{-1,-1,-1,-1,-1,-1,-1,},
{-1,-1,-1, 0,-1,-1,-1,},
{-1,-1,-1, 0,-1,-1,-1,},
{-1, 0, 0, 0, 0, 0,-1,},
{-1,-1, 0, 0, 0,-1,-1,},
{-1,-1,-1, 0,-1,-1,-1,},
{-1,-1,-1,-1,-1,-1,-1,},
{-1,-1,-1,-1,-1,-1,-1,},
};
int[][] colMat2 = {
{-1,-1,-1, 0,-1,-1,-1},
{-1,-1,-1, 0,-1,-1,-1},
{-1,-1,-1, 0,-1,-1,-1},
{-1,-1, 0, 0, 0,-1,-1},
{ 0, 0, 0, 0, 0, 0, 0},
{-1,-1, 0, 0, 0,-1,-1},
{-1,-1,-1, 0,-1,-1,-1},
{-1,-1,-1, 0,-1,-1,-1},
{-1,-1,-1, 0,-1,-1,-1},
};
void pinta(Graphics g) {
if (System.currentTimeMillis() % 2 == 0) {
for (int i=0; i<9; i++) {
for (int j=0; j<7; j++) {
if (colMat1[i][j] == -1) g.setColor(TRANSPARENT);
if (colMat1[i][j] == 0) g.setColor(LIGHT_GREY);
g.drawRect(x+(SIZE_PIXEL)*j, y+(SIZE_PIXEL)*i, SIZE_PIXEL, SIZE_PIXEL);
g.fillRect(x+(SIZE_PIXEL)*j, y+(SIZE_PIXEL)*i, SIZE_PIXEL, SIZE_PIXEL);
}
}
}
else {
for (int i=0; i<9; i++) {
for (int j=0; j<7; j++) {
if (colMat2[i][j] == -1) g.setColor(TRANSPARENT);
if (colMat2[i][j] == 0) g.setColor(LIGHT_GREY);
g.drawRect(x+(SIZE_PIXEL)*j, y+(SIZE_PIXEL)*i, SIZE_PIXEL, SIZE_PIXEL);
g.fillRect(x+(SIZE_PIXEL)*j, y+(SIZE_PIXEL)*i, SIZE_PIXEL, SIZE_PIXEL);
}
}
}
}
}
class EstrellaBloc extends Estrella {
EstrellaBloc(int x, int y, int v) {
this.x = x;
this.y = y;
this.v = v;
}
void moure() {
x -= v;
}
void pinta(Graphics g) {
g.setColor(LIGHT_GREY);
g.drawRect(x, y, 1, 1);
g.fillRect(x, y, 1, 1);
}
}