Learn creative coding writing simple programs

111. Drive 100 cars: an array of objects

Second episode about OOP (Object Oriented Programming), in which we create an array of objects.
In the past we have created arrays of simple types, like int or float, and we have also created two instances of Car. Here we are going to combine both things: we are going to create instances of Car, but instead of making one or two we will create 100, and store all those cars inside one array.
Of course these rectangular "cars" don't look very spectacular, but in coming episodes we will create arrays of particles that decide in which direction to go. I hope then you start seeing how you can use arrays of objects.

Tags: oop, array, object

Code editor

You can make changes to the code below. Then

Questions and comments

Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)

To indicate that a word in your comment is code, use the `backtick`. Example
Do `float` and `int` smell similar?
To highlight code blocks, surround it with ``` code-fences ``` like this:
``` void setup() { size(600, 600); } ```