blob: d50e494c5b0053999fce11bb88862b803006688b (
plain)
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
|
/* Schlange2.inc */
public void run()
{
//Schlange konstruieren
ColorRectangle cr;
int x = 100;
int y = 100;
for (int i=0; i < NUMELEMENTS; ++i) {
cr = new ColorRectangle();
cr.x = x;
cr.y = y;
cr.width = SIZERECT;
cr.height = SIZERECT;
x += SIZERECT;
cr.color = new Color(
i*(256/NUMELEMENTS),
0,
240-i*(256/NUMELEMENTS)
);
snake.addElement(cr);
}
//L�schelement anh�ngen
cr = new ColorRectangle();
cr.x = x;
cr.y = y;
cr.width = SIZERECT;
cr.height = SIZERECT;
cr.color = BGCOLOR;
snake.addElement(cr);
//Vorzugsrichtung festlegen
dx = -1;
dy = -1;
//Schlange laufen lassen
while (true) {
repaint();
try {
Thread.sleep(SLEEP);
} catch (InterruptedException e){
//nichts
}
moveSnake();
}
}
|