|
|
|
@ -10,6 +10,18 @@ public balle_ : Balle;
|
|
|
|
|
public palet_ : Palet;
|
|
|
|
|
public brique_ : Array<Sprite>;
|
|
|
|
|
|
|
|
|
|
public score_ : HTMLElement;
|
|
|
|
|
public scoreFin_ : HTMLElement;
|
|
|
|
|
public compteurScore_ : number;
|
|
|
|
|
|
|
|
|
|
public defaite_ : HTMLElement;
|
|
|
|
|
public victoire_ : HTMLElement;
|
|
|
|
|
|
|
|
|
|
public recommencer_ : HTMLElement;
|
|
|
|
|
public pause_ : HTMLElement;
|
|
|
|
|
public textePause_ : HTMLElement;
|
|
|
|
|
public unpause_ : HTMLElement;
|
|
|
|
|
|
|
|
|
|
public zone_ : Sprite;
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------Constructeur
|
|
|
|
@ -22,6 +34,30 @@ public zone_ : Sprite;
|
|
|
|
|
this.zone_.setXY(10,10);
|
|
|
|
|
this.zone_.setWidth(this.getWidth()-20);
|
|
|
|
|
this.zone_.setHeight(this.getHeight()-20);
|
|
|
|
|
|
|
|
|
|
//Gestion des stats
|
|
|
|
|
this.compteurScore_ = 0;
|
|
|
|
|
this.score_ = document.getElementById('score');
|
|
|
|
|
this.score_.textContent = "Score : " + this.compteurScore_;
|
|
|
|
|
|
|
|
|
|
this.scoreFin_ = document.getElementById('scoreI');
|
|
|
|
|
|
|
|
|
|
//Gestion de la partie
|
|
|
|
|
this.defaite_ = document.getElementById('defaite');
|
|
|
|
|
this.defaite_.style.display = 'none';
|
|
|
|
|
|
|
|
|
|
this.victoire_ = document.getElementById('victoire');
|
|
|
|
|
this.victoire_.style.display = 'none';
|
|
|
|
|
|
|
|
|
|
this.recommencer_ = document.getElementById('recommencer');
|
|
|
|
|
this.pause_ = document.getElementById('pause');
|
|
|
|
|
this.textePause_ = document.getElementById('textepause');
|
|
|
|
|
this.unpause_ = document.getElementById('unpause');
|
|
|
|
|
|
|
|
|
|
this.clique();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------start
|
|
|
|
@ -85,21 +121,73 @@ public zone_ : Sprite;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public augmenterScore() {
|
|
|
|
|
this.compteurScore_ += 1;
|
|
|
|
|
this.score_.textContent = "Score : " + this.compteurScore_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partieGagnee() {
|
|
|
|
|
this.scoreFin_.textContent = "Votre score : " + this.compteurScore_ + "/" + this.brique_.length;
|
|
|
|
|
this.victoire_.style.display = "block";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public partiePerdue() {
|
|
|
|
|
this.scoreFin_.textContent = "Votre score : " + this.compteurScore_ + "/" + this.brique_.length;
|
|
|
|
|
this.defaite_.style.display = "block";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public clique() {
|
|
|
|
|
this.recommencer_.addEventListener('click',this.recommencer.bind(this));
|
|
|
|
|
this.pause_.addEventListener('click',this.pause.bind(this));
|
|
|
|
|
this.unpause_.addEventListener('click',this.unpause.bind(this));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public recommencer() {
|
|
|
|
|
this.clean();
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.start();
|
|
|
|
|
}, 1500);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------pause
|
|
|
|
|
public override pause() {
|
|
|
|
|
/* Ecrire ici le code qui met la scene en pause. */
|
|
|
|
|
this.textePause_.style.display = "block";
|
|
|
|
|
this.unpause_.style.display = "block";
|
|
|
|
|
this.pause_.style.display = "none";
|
|
|
|
|
this.balle_.figer();
|
|
|
|
|
this.palet_.figer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------unpause
|
|
|
|
|
public override unpause() {
|
|
|
|
|
/* Ecrire ici le code qui sort la scene de la pause. */
|
|
|
|
|
this.textePause_.style.display = "none";
|
|
|
|
|
this.unpause_.style.display = "none";
|
|
|
|
|
this.pause_.style.display = "block";
|
|
|
|
|
|
|
|
|
|
this.balle_.animer();
|
|
|
|
|
this.palet_.animer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------clean
|
|
|
|
|
public override clean() {
|
|
|
|
|
/* Ecrire ici le code qui nettoie la scene en vue d'un redemarrage. */
|
|
|
|
|
this.defaite_.style.display = "none";
|
|
|
|
|
this.victoire_.style.display = "none";
|
|
|
|
|
|
|
|
|
|
this.compteurScore_ = 0;
|
|
|
|
|
this.score_.textContent = "Score : " + this.compteurScore_;
|
|
|
|
|
|
|
|
|
|
this.removeChild(this.balle_);
|
|
|
|
|
this.removeChild(this.palet_);
|
|
|
|
|
|
|
|
|
|
for (let i : number = 0; i < this.brique_.length; i++) {
|
|
|
|
|
this.brique_[i].setXY(-1000000,-1000000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|