Browse Source

💄 Règle la taille dynamiquement et retire le fond en image

main
Clément 1 year ago
parent
commit
82c150fa93
  1. 23
      js/main.js

23
js/main.js

@ -1,8 +1,13 @@
let width = window.innerWidth * window.devicePixelRatio;
let height = window.innerHeight * window.devicePixelRatio;
let config = {
title: "Happy 2021!",
url: "http://shikiryu.ovh/new_year_2021",
type: Phaser.AUTO,
width: 800,
height: 600,
width: width,
height: height,
background: 0xffffff,
scene: {
preload: preload,
create: create,
@ -32,7 +37,6 @@ function preload() {
this.load.image('bleu', 'img/virus-bleu.png');
this.load.image('rouge', 'img/virus-rouge.png');
this.load.image('vert', 'img/virus-vert.png');
this.load.image('bg', 'img/bg.png');
}
function killVirus(player, virus) {
@ -41,8 +45,8 @@ function killVirus(player, virus) {
enemiesText.setText('virus restant : '+enemiesCount);
if (enemiesCount === 0) {
enemiesText.visible = false;
that.add.text(200, 250, 'Bonne annnée 2021 !', { fontSize: '32px', fill: '#000' });
that.add.text(250, 300, 'Si possible, sans virus', { fontSize: '14px', fill: '#000' });
that.add.text(width/2-200, height/2-50, 'Bonne annnée 2021 !', { fontSize: '32px', fill: '#000' });
that.add.text(width/2-50, height/2, 'Si possible, sans virus', { fontSize: '14px', fill: '#000' });
win.play();
}
}
@ -52,19 +56,19 @@ function getRandomInt(max) {
}
function create() {
this.add.image(400, 300, 'bg');
shoot = this.sound.add('shoot');
win = this.sound.add('win');
enemiesText = this.add.text(16, 16, 'virus restant : '+maxEnemies, { fontSize: '32px', fill: '#000' });
graphics = this.add.graphics();
graphics.fillGradientStyle(0x3d6d7d, 0x3d6d7d, 0x9addf3, 0x9addf3, 1);
graphics.fillRect(0, 0, width, height);
viruses = new Array(maxEnemies).fill(null).map(
function() {
let color = colors[Math.floor(Math.random() * colors.length)];
return that.add.image(getRandomInt(800), getRandomInt(600), color);
return that.add.image(getRandomInt(width), getRandomInt(height), color);
}
);
@ -78,6 +82,8 @@ function create() {
});
this.input.on('pointerdown', function (pointer) {
target.x = pointer.x;
target.y = pointer.y;
let pointerX = pointer.x;
let pointerY = pointer.y;
shoot.play();
@ -95,6 +101,7 @@ function create() {
}
}
}, this);
}
function update() {

Loading…
Cancel
Save