Monday, 9 May 2011

If/Else Examples 3

Another example of if/else statements I found on openprocessing.org is called A Strange Symmetry. This sketch is a bit more complicated than the other two sketches in that it uses a few different if/else statements to run the program. Because of this I will not recreate the code here when I discuss it, but it can be seen on openprocessing.org at the link above.

The first time an if/else statement is used in this sketch is to designate when the original menu should be displayed, when a different menu should be displayed, or when the drawing function should be displayed.

The second time the if/else statement is used in this sketch is based on the drawing function of the sketch. In this case, the if designates what is drawn on the screen based on where the mouse is and which functions are set. Since there are many different controls for this program this statement is repeated in many different ways so that the program knows what to do when the spacebar is pressed or when arrows are pressed.

No comments:

Post a Comment