Lektion 2 Logische Operatoren

This commit is contained in:
Makussu 2023-09-28 11:20:54 +02:00
parent 4c00f4785c
commit 7e705bc6cc
3 changed files with 53 additions and 0 deletions

View File

@ -14,6 +14,7 @@ void draw() {
} else if (d > 50 && touched == true) { } else if (d > 50 && touched == true) {
d--; d--;
} }
// switch between increasing and decreasing // switch between increasing and decreasing
if (touched == true && d == 50) { if (touched == true && d == 50) {
touched = false; touched = false;

View File

@ -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;
}
}

View 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);
}
}