advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the code for this article
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 3.9/5 | Rate this item | 49 users have rated this item.
 

An Introduction to Game Programming with JavaScript

Some fundamental principles apply to game programming regardless of the language you use to create the game. These principles include gathering input from users, processing game data, and rendering game objects to the screen. This article shows you how to use JavaScript to program a simple game.  


advertisement
ost game programs follow the same recipe—the game must gather input from the user, process that input and any other data, and render objects to the screen. Usually, the program creates event handlers that listen for user input via the mouse, keyboard, or other input device, and a game loop that manages data processing and rendering the display. Once launched, the game loop continues until it encounters some end condition.


In this article, I'll create a simple demo called Rebound that should get you started with game programming in JavaScript. Rebound is a simple ball and paddle game where the user controls a paddle with the keyboard and must keep a moving ball from getting beyond the paddle. You can view the demo here.


How do you create JavaScript Game Programs?


Use keyboard events to gather input from users and animation techniques to create games in JavaScript.

  Next Page: Create the Game Elements


Page 1: IntroductionPage 3: Write and Register a Keyboard Event Handler
Page 2: Create the Game ElementsPage 4: The Game Loop Details
Please rate this item (5=best)
 1  2  3  4  5
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Help  |   Site Map  |   Network Map  |   About


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers