Created
November 27, 2013 04:41
-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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