If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

3. Putting shapes together

Learn how to create a snowman model using an array of shape objects, like circles for the head and body. We can add a hat using vertices, which are just points with coordinates, then store these vertices in an array of arrays to represent any shape! Click here to review objects.

Want to join the conversation?

Video transcript

- [Narrator] Okay, so far you've made a single shape object which contains information to draw a circle, but we'll need more shapes to build our snowman, and we'll want to store all of these shapes inside one data structure, which represents our snowman model. One way we can do this is with an array, where each position in the array holds one shape object. In the next exercise, you'll define an array called shapes array to do this. Think of this shapes array as our entire model. It has everything the computer needs to draw all the pieces of the model. But what about a hat for Nick? We can't draw that with circles... That would be crazy! The short film, Nick Nack, was made with simple geometric shapes. One easy way to draw any shape is to define a series of points called vertices. For example, the hat would need eight vertices like this. Each of these points is represented by a pair of coordinates. And then, the entire list of these vertices can be stored in a larger array. So we'll have an array of arrays to store any shape we want. And we'll let another part of the program actually connect these dots for us. First up, we have two exercises for you. In the first exercise, you'll be creating a shapes array to hold each of your shape objects. This will allow you to add your head and your body. After that, you'll have a chance to create any shape, starting with a classic, black hat. Have fun! (laughs) Yay! Go for it!