94100a3c3dae44b2529baebc7554180b53ba8b2e
1 package code
.kalter
.longflight
.space
;
3 import code
.kalter
.longflight
.Color
;
4 import java
.util
.Random
;
5 import javax
.microedition
.lcdui
.Graphics
;
14 private final int screenH
;
15 private final int COUNT
;
16 private final int[] positionX
;
17 private final int[] positionY
;
18 private final int[] color
;
20 public Star(int screenW
, int screenH
) {
21 this.screenH
= screenH
;
22 Random random
= new Random();
23 COUNT
= (screenH
+ screenW
) / 3;
24 positionX
= new int[COUNT
];
25 positionY
= new int[COUNT
];
26 color
= new int[COUNT
];
27 for (int i
= 0; i
< COUNT
; i
++) {
28 positionX
[i
] = random
.nextInt(screenH
);
29 positionY
[i
] = random
.nextInt(screenW
);
30 int a
= random
.nextInt(256);
31 color
[i
] = Color
.maskRGB(a
, a
, a
);
35 public void paint(Graphics graphics
) {
36 for (int i
= 0; i
< COUNT
; i
++) {
37 graphics
.setColor(color
[i
]);
38 graphics
.fillRect(positionX
[i
], positionY
[i
], 1, 1);
43 for (int i
= 0; i
< COUNT
; i
++) {
44 if ((positionY
[i
] += ((color
[i
] & 0x0000FF) / 50)) > screenH
) {