JSFiddle - React, Tailwind, and code Playground
by InferOn
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.2/phaser.min.js"></script>
CSS
body {
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}
a {
color: #00B7FF;
}
#gamebox {
margin: auto;
width: 900px;
height: 500px;
}
JavaScript
window.onload = function() {
var game = new Phaser.Game(900, 500, Phaser.AUTO, 'gamebox', {
preload: preload,
create: create,
update: update
});
var spaceKey;
var arch, arches;
var temple, temples;
var tree1, tree2, tree3, tree4, tree5, tree6;
var obstacle1, obstacle2, obstacle3, obstacles;
function preload() {
game.load.image('bg1', 'images/bg1.png');
game.load.image('arch1', 'images/arch1.png');
game.load.image('arch2', 'images/arch2.png');
game.load.image('arch3', 'images/arch3.png');
game.load.image('arch4', 'images/arch4.png');
game.load.image('temple1', 'images/temple1.png');
game.load.image('temple2', 'images/temple2.png');
game.load.image('temple3', 'images/temple3.png');
game.load.image('obstacle1', 'images/obstacle1.png');
game.load.image('obstacle2', 'images/obstacle2.png');
game.load.image('obstacle3', 'images/obstacle3.png');
game.load.image('obstacle4', 'images/obstacle4.png');
game.load.image('obstacle5', 'images/obstacle5.png');
game.load.image('obstacle6', 'images/obstacle6.png');
game.load.image('palm-tree1', 'images/palm-tree1.png');
game.load.image('palm-tree2', 'images/palm-tree2.png');
game.load.image('palm-tree3', 'images/palm-tree3.png');
game.load.image('palm-tree4', 'images/palm-tree4.png');
game.load.image('palm-tree5', 'images/palm-tree5.png');
game.load.image('palm-tree6', 'images/palm-tree6.png');
game.load.image('palm-tree7', 'images/palm-tree7.png');
game.load.spritesheet('tuktuk', 'images/tuktuksprite.png', 420, 209, 3);
game.load.audio('motorcycle', 'files/motorcycle.ogg');
}
function create() {
background_objects = game.add.group();
background = game.add.tileSprite(0, -180, 900, 800, 'bg1');
//arch1= game.add.image(450,155, 'arch1');
arches = game.add.group();
arches.enableBody = true;
temples = game.add.group();
...