Learn creative coding writing simple programs

91. Timelines: tell a story

In this episode we discover a way to run several programs one after another. We can decide how long each program runs. This can be used to show different scenes, for example some welcome text, then an animation, and finally some credits showing the date and the author of the program. But it can also be used to tell stories, for example by showing a dialog where different characters speak in turns.
To measure time we use the function millis(), which tells us for how long the program has been running. It returns an integer with the number of milliseconds since the program started. One second is one thousand millisecods.
Using the if() statement we can decide if certain lines in the program should execute or not. When we use if-else we can decide between two different options. That means that we are deciding if to run one line (or group of lines) or a different line (or group of lines).
In this episode we introduce the complete if() statement, that includes if-elseif-elseif-else. This allows us to have not only two options, but many options, one of which will execute depending on the conditions we write.

Tags: elseif, millis, story, timeline

Code editor

You can make changes to the code below. Then
Below you can ask and answer questions related to this video. If your question is unrelated to the video, please post it at the Processing Forum as I'm unable to help with all of your programs and still have enough free time to eat and sleep :)
comments powered by Disqus