Phaser - Flappy box

From http://pgl.ilinov.eu/

by Mladen Mihajlovic

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.1.2/phaser.min.js"></script>
<div id="game_div"></div>

CSS

#game_div {
     width: 400px;
     margin: auto;
     margin-top: 40px;
 }

JavaScript

/* 
Flappy Box v0.7

Coded by Hady Hayman, Available as Public domain (CC0).
You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission. See link below for more info.
http://creativecommons.org/publicdomain/zero/1.0/

Special thanks to Thomas Palef for the tutorial, graphics and sound.
Also lewster32 and Dumtard for their great and fast help on the forums.

Best way to code a game is to start really simple and keep iterating.

v0.1 Old game added with new Phaser and some code tweaks.
v0.2 More coding to fix bugs.
v0.3 No bugs so far.
v0.4 Controls added, Tap to jump!
v0.5 Added sound plus fixed double-jumps only on mobiles.
v0.6 Fixed sound plus added pipes.
v0.7 Pipes are normally generated (no bugs) Better view on mobiles.
v0.8 Better gameplay, Score text works.
v0.9 Commented version and minified version available, Game can be paused by pressing P key on keyboard and resumed by pressing R (Doesn't work on mobiles).
v1.0 On-screen pause/resume. On-screen mute/unmute.

-Coming soon:
v1.1 Menu state with a Play button, Losing state with a retry and menu buttons.
v1.2 Fullscreen mobile scaling (Optional, might not be done.)
*/

/* Here we identify the game, 320 is the game's width,480 is the height, Phaser.AUTO tells phaser to check wether WebGL is supported or not
(If yes, It'll choose it, if not it'll render in the canvas.) and 'game_div' is the ID of the divider in .html file. While other functions are the ones that'll always run. */
var game = new Phaser.Game(320, 480, Phaser.AUTO, 'game_div');


// Here we identify our Score variable.
var score = -1;

// We identify our most important objects (As a global variable) that are going to be used in more than one state/function.
var box;
var pipe;
var gasp;
var choiceLabel;
var pause_label;
var muted = false;
var trueScore = 1;

// Then we start with states. First state is load_state which we'll preload all our assets in it.
var load_state = {
    // Our first...