JavaScript

From GPWiki

Files:GUITutorial_warn.gif The Game Programming Wiki has moved! Files:GUITutorial_warn.gif

The wiki is now hosted by GameDev.NET at wiki.gamedev.net. All gpwiki.org content has been moved to the new server.

However, the GPWiki forums are still active! Come say hello.

This page is far from complete, go ahead and write some more!
You can extend this page by editing it.

Javascript is a scripting language created in collaboration between Sun Microsystems (hence the "java" part) and Netscape. It is used mostly in browsers as a way to provide interactive web sites. There has been a huge explosion in interest in the language due to improved browser support and compatibility.

Contents

History

Spawned in 1995 by the need to make Netscape Navigator's newly added support for Java applets more accessible to non-Java programmers and web designers, a powerful scripting language too often described as "simple."

Plagued in its early days by security flaws, crippled by a lack of powerful development tools such as integrated development environments, debuggers, and meaningful error messages, extended to contexts that range far beyond the initial intent of its designers, and saddled with the legacy of incompatible browser object models, JavaScript has suffered for years at the hands of those who would criticize it for being too unlike Java, or too much like Perl, or too often used by well-meaning but otherwise ignorant web designers, shoehorned into pages without thought of future compatibility, intelligent abstraction, or code reuse.

Yet it is by far the most popular language on the Web, the foundation for the next generation of dynamic client-side Web applications, a solid core with amazing potential and power.

Features

  • Prototype inheritance (supports classical aswell)
  • No distinction between classes and instances

Language

Variables, functions, arrays, strings, etc.

Game Programming

Javascript is becoming more and more popular as a game programming language because it is so powerful and nearly ever computer has at least one javascript intrepeter on it.

Browser-based games are games that run with a browser. They can dynamically edit the html of a webpage and update it with new content. They majority of browser based games so far are text-based however improvements mean that loading content from servers without reloading the page is possible(AJAX) - note: this has been possible for a long time but not used until recently.

Javascript can also be used as a scripting language(like lua) to script games. Example: Story scripting in a rpg parsed by the SpiderMonkey (JavaScript-C) Engine.

Example Games

External Links

  • [1]: about the JavaScript language (a bit focused on JavaScript in Web browsers)
  • [2]: Sphere (License: GPL, Interpreter used: SpiderMonkey)

Description: "Ever had that perfect plot idea for an RPG but didn't have the programming knowledge to create it? Enter Sphere. Sphere is a console-style RPG engine that allows others to create an RPG similar to Final Fantasy, Dragon Quest, or Phantasy Star."

  • [3] : EGachine (License: GPL, Interpreter used: SpiderMonkey)

Description: "EGachine is a JavaScript game engine focused on 2D multi-player (networked) games. The idea is to provide a tool for learning by writing computer games. EGachine is based upon a simple extensible JavaScript shell (EJS) and different modules providing functionality required for programing games."

  • [4] : Eloquent JavaScript - a tutorial for the language.