0
How do I create a loop in Processing that switches between three or more scenarios (summer, winter and autumn) when my object (car) reaches the window edge?
0
How do I create a loop in Processing that switches between three or more scenarios (summer, winter and autumn) when my object (car) reaches the window edge?
4
A way to do it, not very pretty but it 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 method draw
would look like this:
void draw() {
timeFrame = frameCount % width;
// Se chegou no fim da tela
if(timeFrame === 0) {
changeSeason();
}
}
Browser other questions tagged c
You are not signed in. Login or sign up in order to post.
This is from Unity?
– Isac
No, the language is Processing. But an example in Java, would help me a lot.
– find83
You can show the code of one of the functions
scenarioXXXXX
? The ideal solution would be for you to have an array of scenarios, but to propose this we would need to know more about what happens in these functions.– bfavaretto
I put all the code that makes more sense to understand the problem.
– find83