These examples each demonstrate a part of the gamelib library. It's modular in design, so you only link
in the parts you require for a page. Since you're linking in the javascript code, pages using the
library will load faster than those with inline code as the browser will load the scripts from
the cache!
These examples have a lot of comments and explanations within the example scripts themselves, and in the gamelib.zip file there are full docs for each module, listing all relevent properties and methods as well as several global functions not mentioned here. This library is constantly being updated and improved and should lead to a very useful API for budding game programmers or anyone wishing to add dynamic content to their sites, quickly and easily! | |
Cookie Example This example demonstrates the ease with which you can use cookies to save data between pages and browser sessions. This example counts the times you've visited a site. |
Cookie Example 2 Another cookie example. This one remembers your name between visits |
Layer Example This is a demonstration of layer creation and manipulation. Although not game specific, layers are incredibly useful, so much so that they are actually part of gamelib's core library. Layers can load external content, be dragged and dropped, trigger mouse events and much more! |
Layer Example 2 An example of a layer following a sprite around. You can set layers to follow either a sprite or the mouse, so popups or speech bubbles are simple! This layer has its background set to an image and has also been resized, showing various methods... |
Mouse Example The mouse object is used to track the mouse pointer, as well as opening up a range of extra features with layers and sprites. Using this object, you can drag and drop elements, as well as trigger various events. This demonstration shows these techniques with a group of sprites. |
Sound Example A bit of a murky area, the sound object and its methods should allow easy manipulation of sound. It's simplified for games use, and works well with Internet Explorer 4/5, and with Netscape 4 depending on the Plugin. This example triggers sounds when you press buttons (which are actually sprites masquarading as buttons :) |
Sprite Example Sprites are the central feature of Gamelib. These are game objects which move around and animate under timer control. They are incredibly easy to use, but offer a lot of power for games, reporting collisions themselves, responding to the mouse, having speed, zoom size and direction and many other properties and methods. Anyone writing a game that uses sprites will find things a lot easier using Gamelib, especially since the library allows other functions to be "hooked" into the central animation loop, keeping things synchronized! This example demonstrates collision. |
Sprite Example 2 Another example of sprite use. The one demonstrates the canvas animation technique. The gamelib sprites can be animated by storing all stages of animation on ONE image, which is faster for downloading, smoother for animation and easier for updating (only one image, instead of lots for a game) |
Sprite Example 3 This example demonstrates the follow and target methods for sprites, as well as the new hitEvent property. Basically, any sprite can now follow another sprite or the mouse, much like the layer objects. Also sprites can target another sprite or the mouse, which means they home in on the target object. The new hitEvents are events that will fire when a sprite hits another sprite. You can set different events based on which sprites hit which, so for example if sprite a hits b, it fires an event, if sprite a hits c, it fires another event and so on. Think of them like mouse events, the sprite does the thinking for you! |
Keyboard Example Here the gamelib is used to provide keyboard objects, in this case to render a very simple bat and ball game. The Gamelib is optimized for multiple key presses at once, as there is likely to be in a game situation. |
Download Gamelib.zip Click the link above to download Gamelib. It's completely free to use in non-commercial pages and games, but please include a link back to Javascript Games on your site if you use it! Do not redistribute Gamelib from your own site, just include a link to http://www.javascript-games.org/gamelib/gamelib.zip where the latest version of the library will always be placed. | |
Gamelib was created by and is maintained by Scott Porter. |