#gameDiv {
margin-top: 200px;
}
let spriteExample = new Phaser.Scene('spriteExample');
function launchBitcoinWallet() {
var fallbackLink = 'https://getalby.com/p/btcapsule';
var fallbackTimeout = setTimeout(function () {
window.location.href = fallbackLink;
}, 1000);
window.location.href = 'walletofsatoshi://bronzeping54@walletofsatoshi.com';
window.onblur = function () {
clearTimeout(fallbackTimeout);
};
}
var config = {
type: Phaser.AUTO,
width: 950,
height: 1800,
parent: 'gameDiv',
backgroundColor: '#ffffff',
audio: { disableWebAudio: true },
plugins: {
scene: [{
plugin: PhaserMatterCollisionPlugin.default,
key: "matterCollision",
mapping: "matterCollision"
}]
},
scene: {
create: create
},
physics: {
default: 'matter',
matter: {
gravity: {
x: 0,
y: 3
},
//debug: true
}
}
};
var fart;
var jump;
var score = 0;
var maxScore = 0;
var scoreText;
var game = new Phaser.Game(config);
function create() {
this.load.spritesheet('player', '
', {
frameWidth: 466.64,
frameHeight: 400
});
this.load.image('block', '
')
this.load.image('coin', '
')
this.load.image('shitcoin', '
')
this.load.image('dogeShit', '
')
this.load.image('retry', '
')
this.load.image('menu', '
')
this.load.image('zap', '
')
this.load.audio('zap_sound', ['https://nostr.build/p/nb9083.mp3']);
this.load.audio('theBeginning', ['https://nostr.build/p/nb9074.mp3']);
this.load.audio('fail', ['https://nostr.build/p/nb9076.mp3']);
this.sound.unlock();
var poly = '69.090 0.500, 139.603 114.347, 71.013 211.838, 0.500 115.309';
var scene = this;
this.scene = {
preload: function () {
scene.load.spritesheet('player', '
', {
frameWidth: 466.64,
frameHeight: 400
});
scene.load.image('block', '
');
scene.load.image('coin', '
');
scene.load.image('shitcoin', '
');
scene.load.image('dogeShit', '
');
scene.load.image('retry', '
');
scene.load.image('menu', '
');
scene.load.image('zap', '
');
scene.load.audio('zap_sound', ['https://nostr.build/p/nb9083.mp3']);
scene.load.audio('theBeginning', ['https://nostr.build/p/nb9074.mp3']);
scene.load.audio('fail', ['https://nostr.build/p/nb9076.mp3']);
},
create: function () {
var poly = '69.090 0.500, 139.603 114.347, 71.013 211.838, 0.500 115.309';
fart = scene.sound.add('zap_sound');
fart.allowMultiple = true;
jump = scene.sound.add('theBeginning');
jump.allowMultiple = true;
fail = scene.sound.add('fail');
fail.allowMultiple = true;
scoreText = scene.add.text(16, 16, 'Score: 0', {
fontSize: '32px',
fill: '#000'
});
player = scene.matter.add.sprite(200, 200, 'player');
player.setScale(0.4);
player.setOrigin(0, 0);
scene.anims.create({
key: 'run',
frames: scene.anims.generateFrameNumbers('player', {
start: 0,
end: 14
}),
frameRate: 20,
repeat: -1
});
player.anims.play('run');
var platformGroup = scene.matter.world.nextGroup(true);
var platform = scene.matter.add.image(475, 2000, 'block', null, {
shape: poly
});
platform.setStatic(true);
platform.setCollisionGroup(platformGroup);
player.setCollisionGroup(platformGroup);
scene.matterCollision.addOnCollideStart({
objectA: platform,
callback: function (eventData) {
var platform = eventData.gameObjectA;
var player = eventData.gameObjectB;
if (player.y <= platform.y - 150) {
score++;
scoreText.setText('Score: ' + score);
fart.play();
if (score > maxScore) {
maxScore = score;
}
} else {
scene.scene.start('EndScene');
fail.play();
score = 0;
}
}
});
var coinGroup = scene.matter.world.nextGroup(true);
var coin = scene.matter.add.image(200, 500, 'coin', null, {
shape: poly
});
coin.setStatic(true);
coin.setCollisionGroup(coinGroup);
player.setCollisionGroup(coinGroup);
scene.matterCollision.addOnCollideStart({
objectA: coin,
callback: function (eventData) {
var coin = eventData.gameObjectA;
var player = eventData.gameObjectB;
coin.destroy();
score += 10;
scoreText.setText('Score: ' + score);
fart.play();
if (score > maxScore) {
maxScore = score;
}
}
});
var shitcoinGroup = scene.matter.world.nextGroup(true);
var shitcoin = scene.matter.add.image(700, 500, 'shitcoin', null, {
shape: poly
});
shitcoin.setStatic(true);
shitcoin.setCollisionGroup(shitcoinGroup);
player.setCollisionGroup(shitcoinGroup);
scene.matterCollision.addOnCollideStart({
objectA: shitcoin,
callback: function (eventData) {
var shitcoin = eventData.gameObjectA;
var player = eventData.gameObjectB;
shitcoin.destroy();
score -= 5;
scoreText.setText('Score: ' + score);
fart.play();
if (score > maxScore) {
maxScore = score;
}
}
});
var dogeShitGroup = scene.matter.world.nextGroup(true);
var dogeShit = scene.matter.add.image(400, 800, 'dogeShit', null, {
shape: poly
});
dogeShit.setStatic(true);
dogeShit.setCollisionGroup(dogeShitGroup);
player.setCollisionGroup(dogeShitGroup);
scene.matterCollision.addOnCollideStart({
objectA: dogeShit,
callback: function (eventData) {
var dogeShit = eventData.gameObjectA;
var player = eventData.gameObjectB;
dogeShit.destroy();
score -= 10;
scoreText.setText('Score: ' + score);
fart.play();
if (score > maxScore) {
maxScore = score;
}
}
});
scene.input.on('pointerdown', function () {
player.applyForce({
x: 0,
y: -0.1
});
jump.play();
});
scene.matter.world.on('collisionstart', function (event, bodyA, bodyB) {
if (bodyA.gameObject === null || bodyB.gameObject === null) {
return;
}
var gameObjectA = bodyA.gameObject;
var gameObjectB = bodyB.gameObject;
if (gameObjectA.texture.key === 'player' && gameObjectB.texture.key === 'retry') {
scene.scene.restart();
fart.play();
}
if (gameObjectA.texture.key === 'player' && gameObjectB.texture.key === 'menu') {
launchBitcoinWallet();
fart.play();
}
});
scene.events.on('shutdown', function () {
scene.matter.world.off('collisionstart');
});
}
};
game.scene.add('spriteExample', scene);
game.scene.start('spriteExample');
}
//** Here I think this code includes all the necessary fixes to make it work properly. However, I haven't tested the functionality of the game, per se. **//