This took me a while and I must admit I’m rather swelling up with pride and sense of accomplishment. Look what I made:
It’s a project from Khan Academy. What’s so great about it? The books aren’t drawn one at a time with a block of code for each book. They’re all drawn using one function using a For loop to draw each book in the array. The X and Y coordinates are determined using variables based on the [i] position of the book in the array.
The drawing of the shelves could definitely be more elegant, but I’m quite happy with getting the books to move to the second shelf (that took me a while). I created a variable called column that resets back to zero if it has a value of four.