703
edits
No edit summary |
(→Code) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
''Die Bildschirmgröße stimmt nicht für das Tischtheater. Sie ist an die Bildschrimgröße meines PCs angepasst, weil sonst nicht alles zu sehen war, eher gesagt, er hat das Bild | ''Die Bildschirmgröße stimmt nicht für das Tischtheater. Sie ist an die Bildschrimgröße meines PCs angepasst, weil sonst nicht alles zu sehen war, eher gesagt, er hat das Bild abgeschnitten (wie in der gallery zu sehen).'' | ||
== Code == | == Code == | ||
<source lang="Java">Ball[] ball = new Ball[15]; | <source lang="Java">Ball[] ball = new Ball[15]; | ||
int a,b,c; | int a,b,c; //Abstände der Ebenen | ||
void setup() { | void setup() { | ||
Line 10: | Line 10: | ||
smooth(); | smooth(); | ||
noStroke(); | noStroke(); | ||
colorMode(HSB,360,100,100,100); | colorMode(HSB,360,100,100,100); | ||
a = 500; | a = 500; //erste Ebene | ||
b = 400; | b = 400; //zweite Ebene | ||
c = 40; | c = 40; //Lücke | ||
for (int i=0; i < 5; i++) { | for (int i=0; i < 5; i++) { | ||
ball[i] = new Ball(); | ball[i] = new Ball(); | ||
ball[i].x = random(ball[i].g,a-ball[i].g); | ball[i].x = random(ball[i].g,a-ball[i].g); | ||
ball[i].y = random(ball[i].g,height-ball[i].g); | ball[i].y = random(ball[i].g,height-ball[i].g); | ||
} | } | ||
for (int i=5; i < 10; i++) { | for (int i=5; i < 10; i++) { | ||
ball[i] = new Ball(); | ball[i] = new Ball(); | ||
ball[i].x = random(a+c+ball[i].g,a+c+b-ball[i].g); | ball[i].x = random(a+c+ball[i].g,a+c+b-ball[i].g); | ||
ball[i].y = random(ball[i].g,height-ball[i].g); | ball[i].y = random(ball[i].g,height-ball[i].g); | ||
} | } | ||
for (int i=10; i < ball.length; i++) { | for (int i=10; i < ball.length; i++) { | ||
ball[i] = new Ball(); | ball[i] = new Ball(); | ||
ball[i].x = random(a+c+b+c+ball[i].g,width-ball[i].g); | ball[i].x = random(a+c+b+c+ball[i].g,width-ball[i].g); | ||
ball[i].y = random(ball[i].g,height-ball[i].g); | ball[i].y = random(ball[i].g,height-ball[i].g); | ||
} | } | ||
} | } | ||
Line 74: | Line 55: | ||
} | } | ||
if (ball[i].y >= height+ball[i].g) { | if (ball[i].y >= height+ball[i].g) { | ||
ball[i].y = 0 | ball[i].y = 0; | ||
} | } | ||
} | } | ||
Line 91: | Line 72: | ||
} | } | ||
if (ball[i].y >= height+ball[i].g) { | if (ball[i].y >= height+ball[i].g) { | ||
ball[i].y = 0 | ball[i].y = 0; | ||
} | } | ||
} | } | ||
Line 108: | Line 89: | ||
} | } | ||
if (ball[i].y >= height+ball[i].g) { | if (ball[i].y >= height+ball[i].g) { | ||
ball[i].y = 0 | ball[i].y = 0; | ||
} | } | ||
} | } | ||
Line 127: | Line 108: | ||
Ball() { | Ball() { | ||
g = 100; | g = 100; | ||
vx = random(1,10); | |||
vy = random(1,10); | |||
h = (int)random(360); | |||
s = 100; | s = 100; | ||
b = 100; | b = 100; |
edits