Ajout d'un visuel de dommage (les dégats reçu s'affiche pendant un court instant) - Ajout des sons pour les tirs et les dégats reçus - Ajout d'une page de fin (Gagner ou Perdu) - Ajout de la possibilité de retourner au menu ou de recommencer sur cette page de fin - Création des boutons, en Fr et en En, Home - Next - Retry - Le bouton Next est pour le moment inutilisable
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 28 KiB |
@ -1 +1 @@
|
||||
function selectWord(e,t){switch(LANG){case"fr":return t;default:return e}}var LANG=navigator.language.substr(0,2).toLowerCase();const 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;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"};let father=new Phaser.Game(config);father.scene.add("Boot",new Boot(father)),father.scene.add("Type",Type),father.scene.add("Game",new Game(father)),father.scene.start("Boot");
|
||||
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))}var LANG=navigator.language.substr(0,2).toLowerCase();const MYSELF="myself",SHIELD_PER_SECOND=5,COLOR_ATTACK=16711680,COLOR_MOVE=255,COLOR_CONDITION=921102,DURATION_DAMAGE=700,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;var config={type:Phaser.AUTO,width:WIDTH_WINDOW,height:HEIGHT_WINDOW,parent:"all",backgroundColor:"#35363A"};let father=new Phaser.Game(config);father.scene.add("Boot",new Boot(father)),father.scene.start("Boot");
|
@ -1 +1 @@
|
||||
class AddNode extends Phaser.Scene{constructor(e,t,n){super("AddNode"),this.father=e,this.gameR=t,this.selected=n,this.lCategory=[]}create(e){let t=HEIGHT_WINDOW/(4/3);this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,t,3487290).setOrigin(0,.5),this.createButtonCancel(),this.createButtonAdd(e)}addButton(e,t,n,r,i,a=new Category,s){let d=this.createButton(e,t,n,r,i);return d.on("pointerdown",()=>this.click(d,a,s)),d}createButton(e,t,n,r,i){let a=this.add.image(e,t,i).setOrigin(.5,.5).setInteractive();return a.on("pointerover",()=>a.setFrame(1)),a.on("pointerout",()=>a.setFrame(0)),a.displayHeight=r,null===n?a.scaleX=a.scaleY:a.displayWidth=n,a}click(e,t,n){e.isTinted?t.remove(e):t.add(e,n)}newCategory(e,t,n){let r=new Category(e,t,n);return this.lCategory.push(r),r}addTitle(e,t,n){let r={font:(HEIGHT_WINDOW/12).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(e,t,n,r).setOrigin(.5,.5)}createButtonCancel(){this.createButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/(16/15),null,HEIGHT_WINDOW/9,"cancel").on("pointerdown",()=>this.cancel())}createButtonAdd(e){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),null,HEIGHT_WINDOW/9,"add").on("pointerdown",()=>e.addNode())}verifyCategory(){for(let e=0;e<this.lCategory.length;e++)if(!this.lCategory[e].validate())return!1;return!0}cancel(){this.scene.resume("Game"),this.scene.stop("AddNode"),this.father.scene.remove("AddNode")}}
|
||||
class AddNode extends Phaser.Scene{constructor(e,t,n){super("AddNode"),this.father=e,this.gameR=t,this.selected=n,this.lCategory=[]}create(e){let t=HEIGHT_WINDOW/(4/3);this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,t,3487290).setOrigin(0,.5),this.createButtonCancel(),this.createButtonAdd(e)}addButton(e,t,n,s,i,r=new Category,o){let a=this.createButton(e,t,n,s,i);return a.on("pointerdown",()=>this.click(a,r,o)),a}createButton(e,t,n,s,i){let r=this.add.image(e,t,i).setOrigin(.5,.5).setInteractive();return r.on("pointerover",()=>r.setFrame(1)),r.on("pointerout",()=>r.setFrame(0)),r.displayHeight=s,null===n?r.scaleX=r.scaleY:r.displayWidth=n,r}click(e,t,n){e.isTinted?t.remove(e):t.add(e,n)}newCategory(e,t,n){let s=new Category(e,t,n);return this.lCategory.push(s),s}addTitle(e,t,n){let s={font:(HEIGHT_WINDOW/12).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(e,t,n,s).setOrigin(.5,.5)}createButtonCancel(){this.createButton(WIDTH_WINDOW/3,HEIGHT_WINDOW/(16/15),null,HEIGHT_WINDOW/9,"cancel").on("pointerdown",()=>this.cancel())}createButtonAdd(e){this.createButton(WIDTH_WINDOW/1.5,HEIGHT_WINDOW/(16/15),null,HEIGHT_WINDOW/9,"add").on("pointerdown",()=>e.addNode())}verifyCategory(){for(let e=0;e<this.lCategory.length;e++)if(!this.lCategory[e].validate())return!1;return!0}cancel(){this.scene.resume("Game"),this.scene.stop("AddNode"),this.father.scene.remove("AddNode")}}class Finish extends Phaser.Scene{constructor(e){super("Finish"),this.father=e}create(){this.add.rectangle(0,0,WIDTH_WINDOW,HEIGHT_WINDOW,0).setOrigin(0,0).setAlpha(.5),this.add.rectangle(0,HEIGHT_WINDOW/2,WIDTH_WINDOW,HEIGHT_WINDOW/2,3487290).setOrigin(0,.5)}addTitle(e){let t={font:(HEIGHT_WINDOW/6).toString()+"px stencil",fill:"#e2e2e2"};this.add.text(WIDTH_WINDOW/2,HEIGHT_WINDOW/2,e,t).setOrigin(.5,.5)}createButton(e,t){let n=this.add.image(e,HEIGHT_WINDOW/8*7,t).setOrigin(.5,.5).setInteractive();return n.on("pointerover",()=>n.setFrame(1)),n.on("pointerout",()=>n.setFrame(0)),n.displayHeight=HEIGHT_WINDOW/9,n.scaleX=n.scaleY,n}btnRetry(e){e.on("pointerdown",()=>this.retry())}retry(){console.log("RETRY"),this.close(),newGame(this.father),this.father.scene.start("Game")}btnHome(e){e.on("pointerdown",()=>this.home())}home(){console.log("HOME"),this.close(),this.father.scene.start("Type")}btnNext(e){e.on("pointerdown",()=>this.next())}next(){console.log("NEXT")}close(){this.sound.stopAll(),this.father.scene.remove("GamingBoard"),this.father.scene.remove("Game"),this.father.scene.remove("Finish")}}
|
@ -0,0 +1,12 @@
|
||||
class Looser extends Finish {
|
||||
constructor(father) {
|
||||
super(father);
|
||||
}
|
||||
|
||||
create() {
|
||||
super.create();
|
||||
super.addTitle(selectWord("GAME OVER", "PARTIE PERDUE"));
|
||||
super.btnRetry(super.createButton(WIDTH_WINDOW / 3, 'retry'));
|
||||
super.btnHome(super.createButton(WIDTH_WINDOW / 1.5, 'home'));
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
class Winner extends Finish {
|
||||
constructor(father) {
|
||||
super(father);
|
||||
}
|
||||
|
||||
create() {
|
||||
super.create();
|
||||
super.addTitle(selectWord("WINNER", "GAGNER"));
|
||||
super.btnRetry(super.createButton(WIDTH_WINDOW / 4, 'retry'));
|
||||
super.btnHome(super.createButton(WIDTH_WINDOW / 2, 'home'));
|
||||
super.btnNext(super.createButton(WIDTH_WINDOW / 4 * 3, 'next'));
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
class Finish extends Phaser.Scene {
|
||||
constructor(father) {
|
||||
super('Finish');
|
||||
this.father = father;
|
||||
}
|
||||
|
||||
create() {
|
||||
this.add.rectangle(0, 0, WIDTH_WINDOW, HEIGHT_WINDOW, 0x000000).setOrigin(0, 0).setAlpha(0.5);
|
||||
this.add.rectangle(0, HEIGHT_WINDOW / 2, WIDTH_WINDOW, HEIGHT_WINDOW / 2, 0x35363A).setOrigin(0, 0.5);
|
||||
}
|
||||
|
||||
addTitle(title) {
|
||||
let sizeText = HEIGHT_WINDOW / 6;
|
||||
let style = {font: sizeText.toString() + 'px stencil', fill: "#e2e2e2"};
|
||||
this.add.text(WIDTH_WINDOW / 2, HEIGHT_WINDOW / 2, title, style).setOrigin(0.5, 0.5);
|
||||
}
|
||||
|
||||
createButton(x, texture) {
|
||||
let btn = this.add.image(x, HEIGHT_WINDOW / 8 * 7, texture).setOrigin(0.5, 0.5).setInteractive();
|
||||
btn.on('pointerover', () => btn.setFrame(1));
|
||||
btn.on('pointerout', () => btn.setFrame(0));
|
||||
|
||||
btn.displayHeight = HEIGHT_WINDOW / 9;
|
||||
btn.scaleX = btn.scaleY;
|
||||
|
||||
return btn;
|
||||
}
|
||||
|
||||
btnRetry(btn) {
|
||||
btn.on('pointerdown', () => this.retry());
|
||||
}
|
||||
|
||||
retry() {
|
||||
console.log("RETRY");
|
||||
this.close();
|
||||
newGame(this.father);
|
||||
this.father.scene.start('Game');
|
||||
}
|
||||
|
||||
btnHome(btn) {
|
||||
btn.on('pointerdown', () => this.home());
|
||||
}
|
||||
|
||||
home() {
|
||||
console.log("HOME");
|
||||
this.close();
|
||||
this.father.scene.start('Type');
|
||||
}
|
||||
|
||||
btnNext(btn) {
|
||||
btn.on('pointerdown', () => this.next());
|
||||
}
|
||||
|
||||
next() {
|
||||
console.log("NEXT");
|
||||
}
|
||||
|
||||
close() {
|
||||
this.sound.stopAll();
|
||||
this.father.scene.remove('GamingBoard');
|
||||
this.father.scene.remove('Game');
|
||||
this.father.scene.remove('Finish');
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 46 KiB |