703
edits
(→Code C) |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Code C == | == Code C == | ||
Ball[] ball = new Ball[15]; | <source lang="Java">Ball[] ball = new Ball[15]; | ||
int a,b,c; //Abstände der Ebenen | int a,b,c; //Abstände der Ebenen | ||
| Line 21: | Line 20: | ||
ball[i].x = random(ball[i].g1,a-ball[i].g1); | ball[i].x = random(ball[i].g1,a-ball[i].g1); | ||
ball[i].y = random(ball[i].g2,height-ball[i].g2); | ball[i].y = random(ball[i].g2,height-ball[i].g2); | ||
} | } | ||
| Line 30: | Line 27: | ||
ball[i].x = random(a+c+ball[i].g1,a+c+b-ball[i].g1); | ball[i].x = random(a+c+ball[i].g1,a+c+b-ball[i].g1); | ||
ball[i].y = random(ball[i].g2,height-ball[i].g2); | ball[i].y = random(ball[i].g2,height-ball[i].g2); | ||
} | } | ||
| Line 39: | Line 34: | ||
ball[i].x = random(a+c+b+c+ball[i].g1,width-ball[i].g1); | ball[i].x = random(a+c+b+c+ball[i].g1,width-ball[i].g1); | ||
ball[i].y = random(ball[i].g2,height-ball[i].g2); | ball[i].y = random(ball[i].g2,height-ball[i].g2); | ||
} | } | ||
} | } | ||
| Line 240: | Line 233: | ||
} | } | ||
} | } | ||
</source> | |||
== Objekt Ball == | == Objekt Ball == | ||
<source lang="Java">class Ball { | |||
int g1,g2; //Größe | |||
float x,y; //Position | |||
int h,s,b,a; //Farbe | |||
float vx,vy; //Geschwindigkeit | |||
float angle; //Gradzahl | |||
float[] position = new float[4]; // die 4 Ecken des Balls; | |||
Ball() { | |||
g1 = 90; | |||
g2 = g1; | |||
h = (int)random(360); | |||
s = 100; | |||
b = 100-g1; | |||
a = 100; | |||
angle = 90; | |||
} | |||
void maleBall() { | |||
for (int i=0; i<g1; i+=5) { //Abrundungen bzw. Schatten | |||
fill(h,s,b+i,a); | |||
ellipse(x,y,g1-i,g2-i); | |||
} | |||
} | |||
} | |||
</source> | |||
edits