Basic Phaser Template
Kudos Thomas Palef: http://www.lessmilk.com/
http://blog.lessmilk.com/how-to-make-flappy-bird-in-html5-1/
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/phaser/1.1.3/phaser.min.js"></script>
<div id="game_div"> </div>
CSS
#game_div {
width: 400px;
margin: auto;
margin-top: 50px;
}
JavaScript
// Initialize Phaser, and creates a 400x490px game
var game = new Phaser.Game(400, 490, Phaser.AUTO);
var game_state = {};
// Creates a new 'main' state that wil contain the game
game_state.main = function() { };
game_state.main.prototype = {
preload: function() {
// Function called first to load all the assets
},
create: function() {
// Fuction called after 'preload' to setup the game
this.mins =5
this.secs = 1
this.life = 1
},
update: function() {
// Function called 60 times per second
//alarm [0]
if (this.life < 3) {
this.secs -= 1
if (this.secs == -1) {
this.secs = 59
if (this.mins > 0) {
this.mins -= 1
} else {
if (this.mins == 0) {
this.life += 1
}
}
}
}
console.log(this.life)
},
};
// Add and start the 'main' state to start the game
game.state.add('main', game_state.main);
game.state.start('main');