Résolution du problème de l'affichage du son désactivé - Lorsque le robot recule contre un mur, il ne perd normalement plus de vitesse, la vitesse qu'il ne peut pas utiliser est restransmise pour longer le mur - Modification de la touche pour supprimé de ECHAP vers SUPPR - la fonction getNode est faite de manière plus récursive dans le but de réduire la taille du code mais aussi l'exécution - Suppression du temps aléatoire de rechargement (il sera possible par la suite de modifier ce temps de rechargement en cours ou avant le jeu) - Modification du cercle rouge par l'image du robot

master
clmaisonha 5 years ago
parent c744f783cd
commit b08d2c8df9

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

@ -1 +1 @@
function selectWord(e,t){switch(LANG){case"fr":return t;default:return e}}function newGame(e){-1!==e.scene.getIndex("Game")&&e.scene.remove("Game"),e.scene.add("Game",new Game(e))}function chooseTarget(e,t){let a=2*WIDTH_MAP,n=[];return t.forEach(function(t){if(t!==e){let o=Math.hypot(t.x-e.x,t.y-e.y);a>=o&&(a>o&&(a=o,n=[]),n.push(t))}}),n.length>1?n[Math.floor(Math.random()*(n.length+1))]:n[0]}var listBonus=[],LANG=navigator.language.substr(0,2).toLowerCase(),SPEED_GAME=1;const MYSELF="myself",SHIELD_PER_SECOND=5,COLOR_ATTACK=16711680,COLOR_MOVE=255,COLOR_CONDITION=921102,WIDTH_WINDOW=$(document).width()-20,HEIGHT_WINDOW=$(document).height()-20,WIDTH_MAP=WIDTH_WINDOW<HEIGHT_WINDOW?.8*WIDTH_WINDOW:.8*HEIGHT_WINDOW,SPEED=2,LIFE=100,DAMAGE=40,SHIELD=100,RANGE=WIDTH_MAP/2,HEIGHT_BONUS=WIDTH_MAP/10,HEIGHT_DAMAGE=WIDTH_MAP/20,DURATION_DAMAGE=700;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"};let father=new Phaser.Game(config);father.scene.add("LoadFile",new LoadFile(father,"Boot",new Boot(father))),father.scene.start("LoadFile");
function selectWord(e,t){switch(LANG){case"fr":return t;default:return e}}function newGame(e){-1!==e.scene.getIndex("Game")&&e.scene.remove("Game"),e.scene.add("Game",new Game(e))}function chooseTarget(e,t){let a=2*WIDTH_MAP,n=[];return t.forEach(function(t){if(t!==e){let o=Math.hypot(t.x-e.x,t.y-e.y);a>=o&&(a>o&&(a=o,n=[]),n.push(t))}}),n.length>1?n[Math.floor(Math.random()*(n.length+1))]:n[0]}var listBonus=[],LANG=navigator.language.substr(0,2).toLowerCase(),SPEED_GAME=1;const MYSELF="myself",SHIELD_PER_SECOND=5,COLOR_ATTACK=16711680,COLOR_MOVE=255,COLOR_CONDITION=921102,WIDTH_WINDOW=$(document).width()-20,HEIGHT_WINDOW=$(document).height()-20,WIDTH_MAP=WIDTH_WINDOW<HEIGHT_WINDOW?.8*WIDTH_WINDOW:.8*HEIGHT_WINDOW,SPEED=2,LIFE=100,DAMAGE=40,SHIELD=100,RANGE=WIDTH_MAP/2,HEIGHT_BONUS=WIDTH_MAP/10,HEIGHT_DAMAGE=WIDTH_MAP/20,DURATION_DAMAGE=700,TIME_RELOAD=1e3;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"};let father=new Phaser.Game(config);father.scene.add("LoadFile",new LoadFile(father,"Boot",new Boot(father))),father.scene.start("LoadFile");

File diff suppressed because one or more lines are too long

@ -56,6 +56,7 @@ const RANGE = WIDTH_MAP / 2;
const HEIGHT_BONUS = WIDTH_MAP / 10;
const HEIGHT_DAMAGE = WIDTH_MAP / 20;
const DURATION_DAMAGE = 700;
const TIME_RELOAD = 1000;
var config = {

@ -2,12 +2,12 @@ class Game extends ManageLang {
constructor(father) {
super('Game', father);
super.addOtherScenes('GamingBoard');
SPEED_GAME = 1;
}
create() {
super.create();
this.doLine = false;
SPEED_GAME = 1;
this.gm = new GamingBoard(this);
if (this.father.scene.getIndex('GamingBoard') !== -1) {
this.father.scene.remove('GamingBoard');
@ -38,7 +38,7 @@ class Game extends ManageLang {
this.gm.addRobot(new Robot(WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.1, WIDTH_MAP * 0.9, 0xff0000, this.gm));
this.input.keyboard.on('keydown-ESC', () => {
this.input.keyboard.on('keydown-DELETE', () => {
this.clickBin();
});
}
@ -112,7 +112,7 @@ class Game extends ManageLang {
let sortDesc = (a, b) => a.getX() - b.getX();
this.tree.sort(sortDesc);
this.gm.modifyNodes(this.tree.getNodes());
this.gm.modifyNodes(this.tree.getNode());
this.gm.resume();
}
@ -140,12 +140,18 @@ class Game extends ManageLang {
let mute = this.add.sprite(x - diffX * 5, y, 'mute').setOrigin(1, 0).setInteractive();
this.linePlay = 0;
this.lineSpeed = 0;
if (SPEED_GAME === 1) {
this.lineSpeed = 0;
} else {
this.lineSpeed = 1;
}
this.changeFrame(speed, 0, this.lineSpeed);
if (this.father.sound.mute) {
this.lineMute = 1;
} else {
this.lineMute = 0;
}
this.changeFrame(mute, 0, this.lineMute);
back.displayHeight = back.displayWidth = width;

@ -2,8 +2,8 @@ class HealthBar {
constructor(scene, width, height, x, y, valueMax, color) {
this.bar = new Phaser.GameObjects.Graphics(scene);
this.width = width;
this.height = height;
this.width = Math.floor(width);
this.height = Math.floor(height);
this.valueMax = valueMax;
this.value = valueMax;
this.color = color;

@ -45,6 +45,8 @@ class LoadFile extends Phaser.Scene {
this.loadImage('bonusSpeed1', 'bonus/', true);
this.loadImage('bonusSpeed2', 'bonus/', true);
this.loadImage('enemy', 'robots/');
this.loadSprite('playLetter', 550, 150, 'buttons/');
this.loadSprite('cancel', 550, 150, 'buttons/');
this.loadSprite('add', 550, 150, 'buttons/');

@ -118,29 +118,17 @@ class RectangleNode {
}
getNode() {
if (this.canAddNode) {
this.node.clearNodes();
this.lRect.forEach(rect => this.node.addNode(rect.node));
console.log(this);
}
return this.node;
}
getNodes() {
if (this.node === undefined) {
let lNodes = [];
this.lRect.forEach(function (element) {
if (element.node !== undefined) {
if (element.canAddNode) {
element.node.clearNodes();
element.lRect.forEach(rect => element.node.addNode(rect.getNode()));
}
lNodes.push(element.node);
}
lNodes.push(element.getNode());
});
return lNodes;
} else if (this.canAddNode) {
this.node.clearNodes();
this.lRect.forEach(rect => this.node.addNode(rect.getNode()));
}
return this.node;
}
sort(sortDesc) {

@ -1,6 +1,7 @@
class Robot {
constructor(height, width, posX, posY, color, scene, name = 'enemy', speed = 1) {
this.speed = speed;
this.timeReload = TIME_RELOAD;
this.name = name;
this.height = height;
this.width = width;
@ -30,7 +31,12 @@ class Robot {
addScene(scene) {
this.scene = scene;
this.circle = this.scene.add.circle(this.x, this.y, this.width / 2, this.color).setInteractive();
if (this.name === 'enemy') {
this.circle = this.scene.add.image(this.x, this.y, 'enemy').setOrigin(0.5, 0.5).setInteractive();
this.circle.displayWidth = this.circle.displayHeight = this.width;
} else {
this.circle = this.scene.add.circle(this.x, this.y, this.width / 2, this.color).setInteractive();
}
this.circle.on('pointerdown', () => this.click());
}
@ -125,10 +131,10 @@ class Robot {
fleeFrom(target) {
if (this.target.x !== this.x || this.target.y !== this.y) {
let velocity = this.getVelocity(target);
if (velocity[0] >= 0 && this.x - this.width / 2 <= 0)
let velocity = this.getVelocity(target, true);
if (velocity[0] >= 0 && this.x - this.width / 2 <= 0) {
this.setX(this.width / 2);
else if (velocity[0] <= 0 && this.x + this.width / 2 >= WIDTH_MAP)
} else if (velocity[0] <= 0 && this.x + this.width / 2 >= WIDTH_MAP)
this.setX(WIDTH_MAP - this.width / 2);
else
this.setX(this.x - velocity[0]);
@ -144,13 +150,28 @@ class Robot {
return false;
}
getVelocity(target) {
getVelocity(target, calcul = false) {
let velocity = [];
let diffX = target.x - this.x;
let diffY = target.y - this.y;
let hypot = Math.hypot(diffX, diffY);
velocity[0] = diffX / hypot * WIDTH_MAP / 1000 * SPEED * this.speed * SPEED_GAME;
velocity[1] = diffY / hypot * WIDTH_MAP / 1000 * SPEED * this.speed * SPEED_GAME;
if (calcul) {
if (this.x + this.width / 2 + velocity[0] > WIDTH_MAP || this.x - this.width / 2 + velocity[0] < 0) {
console.log(velocity);
velocity[1] += velocity[0] * Math.sign(velocity[1]);
velocity[0] = 0;
console.log(velocity);
} else {
if (this.y + this.width / 2 + velocity[1] > WIDTH_MAP || this.y - this.width / 2 + velocity[1] < 0) {
console.log(velocity);
velocity[0] += velocity[1] * Math.sign(velocity[0]);
velocity[1] = 0;
}
}
}
return velocity;
}
@ -196,7 +217,7 @@ class Robot {
});
this.scene.time.addEvent({
delay: Phaser.Math.Between(1000 / SPEED_GAME, 3000 / SPEED_GAME),
delay: this.timeReload / SPEED_GAME,
callback: this.reload,
callbackScope: this
});

Loading…
Cancel
Save