Lektion 2 Logische Operatoren
This commit is contained in:
parent
4c00f4785c
commit
7e705bc6cc
@ -14,6 +14,7 @@ void draw() {
|
||||
} else if (d > 50 && touched == true) {
|
||||
d--;
|
||||
}
|
||||
|
||||
// switch between increasing and decreasing
|
||||
if (touched == true && d == 50) {
|
||||
touched = false;
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
int ellipseColor = 0;
|
||||
boolean onceWhite = false;
|
||||
|
||||
void setup() {
|
||||
size(400,400);
|
||||
}
|
||||
void draw() {
|
||||
background(255);
|
||||
fill(ellipseColor);
|
||||
|
||||
ellipse(width/2, height/2, 50, 50);
|
||||
// actually change color
|
||||
if (ellipseColor < 255 && onceWhite == false) {
|
||||
ellipseColor++;
|
||||
} else if (ellipseColor > 0 && onceWhite == true) {
|
||||
ellipseColor--;
|
||||
}
|
||||
|
||||
// switch between white and black
|
||||
if (ellipseColor == 255 && onceWhite == false) {
|
||||
onceWhite = true;
|
||||
}
|
||||
if (ellipseColor == 0 && onceWhite == true) {
|
||||
onceWhite = false;
|
||||
}
|
||||
}
|
||||
26
Lektion 2/Logische_Operatoren/Rote_Zone/Rote_Zone.pde
Normal file
26
Lektion 2/Logische_Operatoren/Rote_Zone/Rote_Zone.pde
Normal file
@ -0,0 +1,26 @@
|
||||
int x = 0;
|
||||
color fillColor;
|
||||
|
||||
void draw() {
|
||||
background(0);
|
||||
|
||||
// Linien zum Markieren der Zone
|
||||
stroke(255);
|
||||
line(25, 0, 25, height);
|
||||
line(75, 0, 75, height);
|
||||
|
||||
// hier wird animiert...
|
||||
fill(fillColor);
|
||||
ellipse(x, 50, 20, 20);
|
||||
x++;
|
||||
if (x > width) {
|
||||
x = 0;
|
||||
}
|
||||
|
||||
// Roter Ball
|
||||
if (x > 25 && x < 75) {
|
||||
fillColor = color(255, 0, 0);
|
||||
} else {
|
||||
fillColor = color(255);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user