API

iGameLib is designed to be extremely simple to use, and also to integrate with your existing game.

Initialization

In your game’s HTML “header” section, include the following:

<SCRIPT TYPE="text/javascript" SRC="http://www.throughput.biz/iGameLib/1.01/iGameLib.js">
</SCRIPT>

Immediately after the BODY tag, add the following:
<SCRIPT TYPE="text/javascript"><!--
var iGame = new iGamelib();
--> </SCRIPT>

Setting the Player’s Name

By default, iGameLib will prompt the player for their name the first time they submit a score. If you want to supress this, you can call the following function prior to calling “endGame.”
iGame.setPlayer(playerName);

Starting the Game

When you start a new game, make the following call:
iGame.startGame();

Ending the Game

When the game is over, make the following call. This is the call that submits the high score to the database:
iGame.endGame(finalScore);

Refresh the High Score list

When iGameLib starts, no high scores are loaded. Calling the following function will retrieve a list of the top scores for your game. Note than when you call “endGame,” a new list of scores centered around that last submitted score will be loaded.

iGame.refresh();

Show the High Scores

By default, the high score display is hidden. To display the high scores, make the following call. Note that you’ll also need to “refresh()” or else “endGame()” before you see any scores.
iGame.showScores();

Hide the High Scores

To hide the high scores, make the following call:
iGame.hideScores();

Settings

The following methods define the behavior and appearance of the high score list.
iGame.setColor(fg_color); (defaults to black)
iGame.setBGColor(bg_color); (defaults to transparent)
iGame.setDimensions(x, y, width, height); (integers, in pixels)
iGame.setNumScores(num); (defaults to showing 9 scores)