💄 Règle la taille dynamiquement et retire le fond en image
This commit is contained in:
parent
fe089ed815
commit
82c150fa93
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 = {
|
let config = {
|
||||||
|
title: "Happy 2021!",
|
||||||
|
url: "http://shikiryu.ovh/new_year_2021",
|
||||||
type: Phaser.AUTO,
|
type: Phaser.AUTO,
|
||||||
width: 800,
|
width: width,
|
||||||
height: 600,
|
height: height,
|
||||||
|
background: 0xffffff,
|
||||||
scene: {
|
scene: {
|
||||||
preload: preload,
|
preload: preload,
|
||||||
create: create,
|
create: create,
|
||||||
@ -32,7 +37,6 @@ function preload() {
|
|||||||
this.load.image('bleu', 'img/virus-bleu.png');
|
this.load.image('bleu', 'img/virus-bleu.png');
|
||||||
this.load.image('rouge', 'img/virus-rouge.png');
|
this.load.image('rouge', 'img/virus-rouge.png');
|
||||||
this.load.image('vert', 'img/virus-vert.png');
|
this.load.image('vert', 'img/virus-vert.png');
|
||||||
this.load.image('bg', 'img/bg.png');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function killVirus(player, virus) {
|
function killVirus(player, virus) {
|
||||||
@ -41,8 +45,8 @@ function killVirus(player, virus) {
|
|||||||
enemiesText.setText('virus restant : '+enemiesCount);
|
enemiesText.setText('virus restant : '+enemiesCount);
|
||||||
if (enemiesCount === 0) {
|
if (enemiesCount === 0) {
|
||||||
enemiesText.visible = false;
|
enemiesText.visible = false;
|
||||||
that.add.text(200, 250, 'Bonne annnée 2021 !', { fontSize: '32px', fill: '#000' });
|
that.add.text(width/2-200, height/2-50, '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-50, height/2, 'Si possible, sans virus', { fontSize: '14px', fill: '#000' });
|
||||||
win.play();
|
win.play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,19 +56,19 @@ function getRandomInt(max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function create() {
|
function create() {
|
||||||
this.add.image(400, 300, 'bg');
|
|
||||||
|
|
||||||
shoot = this.sound.add('shoot');
|
shoot = this.sound.add('shoot');
|
||||||
win = this.sound.add('win');
|
win = this.sound.add('win');
|
||||||
|
|
||||||
enemiesText = this.add.text(16, 16, 'virus restant : '+maxEnemies, { fontSize: '32px', fill: '#000' });
|
enemiesText = this.add.text(16, 16, 'virus restant : '+maxEnemies, { fontSize: '32px', fill: '#000' });
|
||||||
|
|
||||||
graphics = this.add.graphics();
|
graphics = this.add.graphics();
|
||||||
|
graphics.fillGradientStyle(0x3d6d7d, 0x3d6d7d, 0x9addf3, 0x9addf3, 1);
|
||||||
|
graphics.fillRect(0, 0, width, height);
|
||||||
|
|
||||||
viruses = new Array(maxEnemies).fill(null).map(
|
viruses = new Array(maxEnemies).fill(null).map(
|
||||||
function() {
|
function() {
|
||||||
let color = colors[Math.floor(Math.random() * colors.length)];
|
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) {
|
this.input.on('pointerdown', function (pointer) {
|
||||||
|
target.x = pointer.x;
|
||||||
|
target.y = pointer.y;
|
||||||
let pointerX = pointer.x;
|
let pointerX = pointer.x;
|
||||||
let pointerY = pointer.y;
|
let pointerY = pointer.y;
|
||||||
shoot.play();
|
shoot.play();
|
||||||
@ -95,6 +101,7 @@ function create() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
|
Loading…
Reference in New Issue
Block a user