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

Start here!

Introduction to this lesson

Ready to dive into some code?

In this lesson you will build a simple snowman model and rig it using javascript. Then you can extend the model to create your own character in the final project.
You will be filling in some important pieces of a much larger program in this lesson—similar to how people work with software at Pixar.

Overview of lesson

First, you'll build some circles using objects.
Then you'll combine your various shapes in an array of objects.
Finally you'll write deformer functions so that you can move your model around.
By the end, you'll be ready for the final project!

What do you need to know before starting?

  • If you've never programmed anything before, we recommend going through our Intro to JS course to learn the concepts of variables, arrays, functions, and objects. And, of course, come back here when you're ready!
  • If you've programmed before but not on Khan Academy, we recommend getting comfortable with our environment first by creating a new program here.
  • If you've learned programming here on Khan Academy, perfect! Just review the concepts below and refresh yourself on any skills you're rusty on.
  • This lesson touches on math concepts—equations for geometric transformations—appropriate for grade eight and above. You can review this concept in our sets and staging lesson.

Quick review of programming concepts you'll use

Variables

start text, v, a, r, end text, start color #6495ed, start text, space, s, u, l, l, e, y, s, A, g, e, end text, end color #6495ed, equals, start color #28ae7b, 15, end color #28ae7b, ;
  • This creates a variable called start color #6495ed, start text, s, u, l, l, e, y, s, A, g, e, end text, end color #6495ed which stores the value start color #28ae7b, 15, end color #28ae7b.

Arrays

start text, v, a, r, end text, start color #6495ed, start text, space, a, g, e, s, end text, end color #6495ed, equals, open bracket, start color #28ae7b, 2, end color #28ae7b, comma, start color #ff00af, 4, end color #ff00af, comma, start color #9d38bd, 8, end color #9d38bd, close bracket, ;
  • This creates an array called start color #6495ed, start text, a, g, e, s, end text, end color #6495ed which stores three values start color #28ae7b, 2, end color #28ae7b, comma, start color #ff00af, 4, end color #ff00af, comma, start color #9d38bd, 8, end color #9d38bd.
  • start color #6495ed, start text, a, g, e, s, end text, end color #6495ed, open bracket, 1, close bracket holds the value start color #ff00af, 4, end color #ff00af.

Functions

start text, v, a, r, end text, start color #6495ed, start text, space, s, a, y, H, e, l, l, o, end text, end color #6495ed, equals, start text, f, u, n, c, t, i, o, n, end text, left parenthesis, right parenthesis, space, left brace
start text, t, e, x, t, end text, left parenthesis, start text, start color #28ae7b, ", H, e, l, l, o, space, w, o, r, l, d, !, ", end color #28ae7b, end text, comma, start color #ff00af, 100, end color #ff00af, comma, start color #ff00af, 200, end color #ff00af, right parenthesis, ;
right brace
  • This creates a function called start color #6495ed, start text, s, a, y, H, e, l, l, o, end text, end color #6495ed that will output the text start text, start color #28ae7b, ", H, e, l, l, o, space, w, o, r, l, d, !, ", end color #28ae7b, end text at the screen coordinates left parenthesis, start color #ff00af, 100, comma, 200, end color #ff00af, right parenthesis when it's called.
start text, v, a, r, end text, start color #6495ed, start text, space, s, a, y, H, e, l, l, o, end text, end color #6495ed, equals, start text, f, u, n, c, t, i, o, n, end text, left parenthesis, start color #ff00af, x, end color #ff00af, comma, space, start color #ff00af, y, end color #ff00af, right parenthesis, space, left brace
start text, t, e, x, t, end text, left parenthesis, start text, start color #28ae7b, ", H, e, l, l, o, space, w, o, r, l, d, !, ", end color #28ae7b, end text, comma, space, start color #ff00af, x, end color #ff00af, comma, space, start color #ff00af, y, end color #ff00af, right parenthesis, ;
right brace
  • This start color #6495ed, start text, s, a, y, H, e, l, l, o, end text, end color #6495ed function now has two input parameters, start color #ff00af, x, end color #ff00af and start color #ff00af, y, end color #ff00af, to define the coordinates of the text.

Objects

start text, v, a, r, end text, start color #6495ed, start text, space, s, n, o, w, m, a, n, end text, end color #6495ed, equals, left brace, right brace, ;
  • This creates an empty object called start color #6495ed, start text, s, n, o, w, m, a, n, end text, end color #6495ed.
start text, v, a, r, end text, start color #6495ed, start text, space, s, n, o, w, m, a, n, end text, end color #6495ed, equals, left brace
start color #28ae7b, start text, a, g, e, end text, end color #28ae7b, colon, start color #ff00af, 2, end color #ff00af, comma
start color #28ae7b, start text, c, o, l, o, r, end text, end color #28ae7b, colon, start color #ff00af, start text, ", w, h, i, t, e, ", end text, end color #ff00af, comma
start color #28ae7b, start text, l, i, k, e, s, end text, end color #28ae7b, colon, open bracket, start color #ff00af, start text, ", m, i, l, k, ", end text, end color #ff00af, comma, space, start color #ff00af, start text, ", c, o, l, d, space, d, a, y, s, ", end text, end color #ff00af, close bracket
right brace
  • The object start color #6495ed, start text, s, n, o, w, m, a, n, end text, end color #6495ed now contains three properties: start text, start color #6495ed, s, n, o, w, m, a, n, end color #6495ed, point, start color #28ae7b, a, g, e, end color #28ae7b, end text, equals, start color #ff00af, 2, end color #ff00af and start text, start color #6495ed, s, n, o, w, m, a, n, end color #6495ed, point, start color #28ae7b, c, o, l, o, r, end color #28ae7b, end text, equals, start color #ff00af, start text, ", w, h, i, t, e, ", end text, end color #ff00af. The third property of start text, start color #6495ed, s, n, o, w, m, a, n, end color #6495ed, end text is an array called start text, start color #28ae7b, l, i, k, e, s, end color #28ae7b, end text.

Have fun!

Want to join the conversation?