I am a noob at Processing and looking to make it so that if you press an arrow, t hebackground goes from ‘day’ color to either ‘sunset’ or ‘night’, while hiding the trails left by the moving cloud when it follows your mouse. Any suggestions?
PImage img1;
PImage img2;
PImage img3;
float offset = .3;
float easing = .02;
color day = color(122, 199, 254);
color sunset = color(190, 88, 120);
color night = color(100, 80, 120);
// DESERT LANDSCAPE
void setup() {
size(1000, 1000);
img1 = loadImage("sun.png");
img2 = loadImage("moon.png");
img3 = loadImage("clouds.png");
}
void draw () {
// MOVABLE CLOUDS
float dx = (mouseX - img3.width/4) - offset;
offset += dx * easing;
fill(day);
DrawBackground (0, 0);
image(img3, offset, 0);
DrawDunes (0, 0);
}
// SAND DUNES
void DrawDunes(int x, int y) {
fill(202, 127, 85);
noStroke();
quad( 0, 500, 1000, 500, 1000, 1000, 0, 1000);
bezier( 0, 500, 400, 400, 200, 300, 1700, 578);
fill(230, 160, 100);
noStroke();
bezier(290, 410, 400, 400, 200, 300, 1800, 578);
quad(290, 410, 470, 1000, 1000, 1000, 1000, 480);
}
// BACKGROUND
void DrawBackground(int x, int y) {
fill(day);
quad(0, 0, 0, 1000, 1000, 1000, 1000, 0);
if ( keyPressed == true) {
if (key == CODED) { //activate sunset
if (keyCode == LEFT) {
fill(sunset);
image(img1, 570, 120);
} else if (keyCode == RIGHT) { //activate night
fill(night);
stroke(255);
strokeWeight(10);
point(500, 100);
point(900, 250);
point(50, 300);
image(img2, 150, 20);
}
}
}
}