Created
May 27, 2014 08:13
-
-
Save ooflorent/dd81be9ff41ae08c16df to your computer and use it in GitHub Desktop.
Lowrezjam Phaser bootstrap
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
var MightyOoze = { | |
width: 256, | |
height: 256, | |
pixelCanvas: null, | |
pixelContext: null | |
}; | |
MightyOoze.Boot = function() {}; | |
MightyOoze.Boot.prototype = { | |
create: function() { | |
MightyOoze.pixelCanvas = document.getElementById("pixel"); | |
MightyOoze.pixelContext = MightyOoze.pixelCanvas.getContext("2d"); | |
MightyOoze.width = MightyOoze.pixelCanvas.width; | |
MightyOoze.height = MightyOoze.pixelCanvas.height; | |
Phaser.Canvas.setSmoothingEnabled(MightyOoze.pixelContext, false); | |
this.physics.startSystem(Phaser.Physics.ARCADE) | |
this.state.start("Game"); | |
} | |
}; | |
MightyOoze.Game = function() {}; | |
MightyOoze.Game.prototype = { | |
preload: function() { | |
// Load assets | |
}, | |
create: function() { | |
// Create game objects | |
}, | |
update: function() { | |
// Update logic | |
}, | |
render: function() { | |
MightyOoze.pixelContext.drawImage(game.canvas, 0, 0, 32, 32, 0, 0, MightyOoze.width, MightyOoze.height) | |
} | |
}; | |
window.onload = function() { | |
var game = new Phaser.Game(32, 32, Phaser.CANVAS, "game", MightyOoze); | |
// Define states | |
game.state.add("Boot", MightyOoze.Boot); | |
game.state.add("Game", MightyOoze.Game); | |
// Start the game | |
game.state.start("Boot"); | |
}; |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<style> | |
#game { | |
display: none; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="game"></div> | |
<div id="game-pixel"> | |
<canvas id="pixel" width="256" height="256" /> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment