351
edits
No edit summary |
No edit summary |
||
Line 105: | Line 105: | ||
--------- | --------- | ||
Ein Kreis springt in dem Fenster herum. Horizontale und vertikale Geschwindigkeit wird zufällig festgelegt. | |||
[[File:springenderkreis.jpg|300px]] | |||
<source lang="java"> | |||
//Position Horizontal des Kreises | |||
float x= random(0,600); | |||
//Position Vertikal des Kreises | |||
float y= random(0,600); | |||
//horizontale Geschwindigkeit | |||
float vx = random(5,15); | |||
//vertikale Geschwindigkeit | |||
float vy = random(5,15); | |||
//Größe des Kreises | |||
float s = random(40,100); | |||
void setup() { | |||
size(600,600); | |||
smooth(); | |||
background(255); | |||
frameRate(3000); | |||
} | |||
void draw() { | |||
background(255); | |||
fill(29,7,48); | |||
ellipse(x,y,s,s); | |||
x = x + vx; | |||
y = y + vy; | |||
if(y >= height || y <=0){ | |||
vy = -vy; | |||
} | |||
if(x >= width || x <=0) { | |||
vx = -vx; | |||
} | |||
} | |||
</source> |
edits