Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 7. Vectors for Games and Simulat... > Creating a JavaScript Vector Object

7.2. Creating a JavaScript Vector Object

To make the most of vectors in JavaScript, we can encapsulate some of the functionality described earlier in a reusable object, thus making the vectors easier to use in applications. We can then easily attach any additional vector-related functionality to this object as needed.

The x and y components of the vector are actually called vx and vy in the vector object; this makes it more obvious in the later code examples that we are dealing with vector properties and not some other x and y values:


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial