Fifteen game
Phaser.js
by vishalvasani
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.1/phaser.min.js"></script>
JavaScript
var Fifteen = {
Game: function(game) {
this.chips = null;
Fifteen.null_cell = {x: 3, y: 3};
},
Win: function(game) {}
};
Fifteen.Win.prototype = {
create: function () {
var modal, winText, newGameText;
modal = this.add.graphics(0, 0);
modal.alpha = 0.5;
modal.beginFill('#000');
modal.drawRect(0, 0, this.world.width, this.world.height);
winText = this.add.text(this.world.centerX, this.world.centerY, 'ПОБЕДА', { font: "bold 50px Arial", align: "center", fill: "#0F0", boundsAlignH: "center", boundsAlignV: "middle"});
winText.anchor.setTo(0.5);
winText.addColor('#FF0', 7);
winText.addColor('#0F0', 8);
winText.stroke = '#E40';
winText.strokeThickness = 6;
newGameText = this.add.text(this.world.centerX, this.world.centerY + 130, 'НОВАЯ ИГРА', { font: "bold 20px Arial", align: "center", fill: "#FFF", boundsAlignH: "center", boundsAlignV: "middle" });
newGameText.anchor.setTo(0.5);
newGameText.stroke = '#55F';
newGameText.strokeThickness = 3;
newGameText.inputEnabled = true;
newGameText.input.useHandCursor = true;
newGameText.events.onInputDown.addOnce(this.start, this);
newGameText.events.onInputOver.add(this.over);
newGameText.events.onInputOut.add(this.out);
},
over: function(item) { item.strokeThickness = 6; },
out: function(item) { item.strokeThickness = 3; },
start: function() { this.state.start('Game', false, false); }
}
Fifteen.Game.prototype = {
create: function(){
this.world.removeAll();
this.create_chips();
this.last_chip_index;
for (var i = 0; i < 200; i++) {
this.time.events.add(10 * i, () => {
this.mix()
});
}
},
create_chips: function() {
var graphics = this.game.add.graphics(0, 0);
graphics.beginFill(0xBBBB00, 1);
graphics.drawRect(0, 0, 96, 96);
graphics.endFill();
graphics.visible = false;
var chip_texture = graphics.generateTexture();
if (this.chips) this.chips.destroy();
this.chips =...