How do I create a loop in Processing that switches between three or more scenarios (summer, winter and fall) when my object (car) reaches the edge of the window?
How do I create a loop in Processing that switches between three or more scenarios (summer, winter and fall) when my object (car) reaches the edge of the window?
A way of doing, not very beautiful but that works:
In variable declarations include:
int season = 0; // 0=summer, 1=fall, 2=winter
Create this new method:
void changeSeason() {
// Gira o índice da estação atual
if(++season > 2) season = 0;
// Desenha o cenário correspondente
if(season === 0) {
scenarioSummer();
} else if(season === 1) {
scenarioFall();
} else if(season === 2) {
scenarioWinter();
}
}
And the draw
method would look like this:
void draw() {
timeFrame = frameCount % width;
// Se chegou no fim da tela
if(timeFrame === 0) {
changeSeason();
}
}