Chapter 10. Arrays
We’ve introduced new programming ideas in each chapter (variables, functions, objects) and now we’ve come to the last step—arrays! An array is a list of variables that share a common name. Arrays are useful because they make it possible to work with more variables without creating a new name for each. This makes the code shorter, easier to read, and more convenient to update.
To see what we mean, refer to Example 7-3: Move a Shape. This code works fine if we’re moving around only one shape, but what if we want to have two? We need to make a new x variable and update it within draw():
float
x1
=
−
20
;
Get Getting Started with Processing now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.