Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
It's important to get to grips with each of the core concepts of physics in JavaScript before you move on to creating amazing games with them. In this section, you're going to create a simple space scene, which has a dynamic asteroid field lurking in the deep. I';m not going to lie; it's going to be pretty darn cool.
If you haven't been doing so already, you're now going to split the JavaScript code away from the HTML page and store it in a separate JavaScript file. It was in Chapter 2 that I talked about how storing your JavaScript in a separate file can help keep things organized, and how it's generally good practice. The initial JavaScript for this section is nothing new; in fact, it's practically the same as what you used in the previous chapter. The main difference is that where you referred to shapes in the last chapter, you're now referring to asteroids.