javascript games made easy

Content

Description

gameQuery is a jQuery plug-in to help make javascript games easier to develop by adding some simple mechanism and commodity. It's still in a very early stage of development may change a lot in the versions to come. The project has now also a Google Code page where the svn repository of the project is hosted.

From version 0.2.0 the API should be mostly forward-compatibe, i.e.: a game writen for this version should run on any newer version. This means that you can start coding your games without to many risks! If you've done a game and want to show it around I will gladly host it on this page, send me a mail!

Remark

I'm no javascript wizard and this is my first jQuery plugin so there may well be bad practice, bugs or worst. If you have any comments, bug to report or suggestion you're welcome to send a mail to: gamequery(at)onaluf(dot)org. You can also leave a comment the gameQuery entry of my blog.

News

13 Novembre 2008:

Ok, I know, I still haven't published the tutorial. But I moved to a new place and it took much more of my spare time that I would have tougth. Will do soon, I promise.

And now for something completly different: polls result. To my great suprise, at this date, 26% of you would like to see some sound support in gameQuery. So I've been looking into it. Rafael pointed me to his implementation of a sound management he used for his tetris and this gave me a great lot of clues as what I could do to make sound work in my plugin. One thing I'm still working on is a way to detect that the sound is completly loaded. So far, most plugins seam to offer this possibility but one of the remaining problem is to detect if a plugin is loading and will eventualy be ready to answer to the javascript or not. But still, some improvement in this domain should come shortly after the tutorial is published.

23 September 2008:

Many things happend since the las update. Ajaxian did an entry on gameQuery which led to a total of more than 10,000 view. To celebrate I just posted the version 0.2.5 with support for collision detection. Look at the doc and the new demo for more details on how it works. The tutorial I spoke about in the last news is on it's way, stay tuned!

You may want to take a second to answer this simple poll so that I'll know what feature you want to see in gameQuery next:

What features you would want to see next in gameQuery?
  
pollcode.com free polls

7 August 2008:

Since the 26th of June There have been more than 2,000 unique visitor for the demo! So what's to come in the next week or so? First I'll try my best to add a collision detection mechanisme as soon as possible. Then I will write a tutorial on a complete making of a small shoot'em up. I there is any features you want to see included in the next release don't hesitate to contacte me!

Download

Previous versions

Release notes

Demos

Mechalchemist

This game is a money idol exchanger clone. To play use the 'a' to move the probe left, 'd' to move the probe right, the 's' arrow to take a stone and the 'w' arrow to drop it. Your goal is to make the stone disappear. Use the conversion table at the right. The probe can store any number of stone but all from the same kind.

The graphics still lacks some polish but I've already spend WAY to much time on those for a simple proof of concept. I will likely spend the time I have improving the library and documentation so don't expect a new version of this demo to soon!

(Open in a new windows)

Collision Demo

This is a simple demo for the collision detection, it's not a game! Whenever a red square hits the blue one it explodes. You can move the blue square with the a,s,d,w keys.

(Open in a new windows)

Demo from other people

DerFichtl published a pong clone made with gameQuery here.

raist is working on a port of his side-shooter HoneyBlaster.

Manual

Animations

gameQuery allows you to declare animations. Animations are made of one image with a succession of frames just like in a css sprite. An animation in itself doesn't exist until it’s associated with a sprite. Those are the attributes an animation can have:

Exemple:

var myAnimation = new Animation({ imageURL: "./myAnimation.png", numberOfFrame: 10, delta: 60, rate: 90, type: Animation.VERTICAL | Animation.ONCE});

playground(expression, options)

This function defines the div to be used to display the game. All the objects to be added to the DOM by gameQuery will be added to this element or on of its child. If more than one element results from the expression only the first will be used.

Options may contain:

Exemple:

$().playground("#someId",{refreshRate: 60});

playground()

Called without any parameters the playground function returns the current playground.

startGame(function)

This function will prepare the game to be started by pre-loading the resources and will start the main loop. If a function is given as a parameter it will be called once everything is loaded.

Exemple:

$("#startbutton").click(function(){ $().playground().startGame(function(){ $("#welcomeScreen").remove(); }); })

registerCallback(function, rate)

This function registers a function to be called at a regular interval. The rate is the number of milliseconds between two successive calls to the function given as argument. This function will be called as long as the return value is false.

addSprite(name, options)

This function adds a sprite to the current selected element. This element is expected to be the playground, a group or another sprite. Any sprite created this way will automatically animate itself. The sprite will stay hidden as long as the start() function hasn't been called.

Options may include:

Exemple:

$(document).playground("#playground", {height: playgroundHeight, width: playgroundWidth}) .addSprite("sprite1",{animation: animation1});

addGroup(name, options)

This function behaves almost in the same way as the addSprite one but it creates a transparent sprite.

Options may include:

Exemple:

$(document).playground("#playground", {height: playgroundHeight, width: playgroundWidth}) .addGroup("group1",{overflow: "visible"}) .addSprite("sprite1",{animation: animation1}) .addSprite("sprite2",{animation: animation1});

setAnimation(animation, callback)

This function allow to change the animation of the element on which it's called. This element is expected to be a sprite. Callback is a function to call at the end of each animation cycle. It's an optional parameter that will only be used if the animation is of type Animation.CALLBACK.

collision(filter)

This method returns the list of elements collisioning with the selected one but only those that match with the filter given as parameter.

Exemple:

$("#spaceship").collision(".missiles").each(function(){ killspaceship(); explodemissil(this); });

addSound(name, url) experimental!

This function allows adding a sound to the game. The sound will not be played but will be added to the preload.

playSound() experimental!

This function plays the sound on which it's called.

setLoadBar(id, width)

This function sets the div to use as a loading bar. This div will see its width increase progressively from 0 to width as the items on the preload list are loaded.

Tutorial

not ready yet...

License

This library is under the an MIT license.