A First Dynamic Sketch

In your sketches up to this point, you’ve made the decisions, and you’ve done the math. But computers are much faster than you are at both of those tasks. It’s time to set up variables, tackle some logic, and get the computer to do the heavy lifting rather than doing it yourself.


In Project 2, I showed you how to use some of Processing’s built-in variables (mouseX and mouseY) to figure out exactly where to put the pieces of your snowman. In this project, you’ll take variables a step further: you’re going to create your own!

Anatomy of a Variable

First, let’s crack open a variable and see what it’s made of. This variable, called x, contains the number 23.

int x = 23;

A variable has three parts, and ...

Get The SparkFun Guide to Processing now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.