Skip to content

Instantly share code, notes, and snippets.

Created November 27, 2013 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7670757 to your computer and use it in GitHub Desktop.
Save anonymous/7670757 to your computer and use it in GitHub Desktop.
This snippet covers most of the steps in WADE's video tutorial #1, "Set up and make a simple game in 17 minutes". WADE is the Web App Development Engine -- a Javascript framework for building HTML5 games. http://www.clockworkchilli.com/index.php/main/tech For this snippet to work, you need WADE 0.9.1 and the image assets used in the video tutori…
App = function()
{
this.load = function()
{
wade.loadImage('mole.png');
wade.loadImage('hole.png');
wade.loadImage('holeBottom.png');
wade.loadImage('holeTop.png');
};
this.init = function()
{
var sprite = new Sprite('mole.png',10);
var mole = new SceneObject(sprite);
wade.addSceneObject(mole);
// since the hole is set at origin of 0,0 we set mole a bit lower
mole.setPosition(0, 50);
// and start mole moving
mole.moveTo(0, -40, 100);
mole.state = 'down';
mole.onMoveComplete = function()
{
if (mole.state == 'down')
{
mole.state = 'up';
mole.moveTo(0, -40, 100);
}
else if (mole.state == 'up')
{
mole.state = 'down';
mole.moveTo(0, 44, 100);
}
};
var holeTop = new Sprite('holeTop.png', 20);
var holeBottom = new Sprite('holeBottom.png', 5);
//scene object made up of two sprites
var hole = new SceneObject([holeTop, holeBottom]);
//offset the two sprites to fit for the halves of the sprite
hole.setSpriteOffset(0, {x:0, y:-64});
hole.setSpriteOffset(1, {x:0, y:64});
wade.addSceneObject(hole);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment