|
|
@ -16,8 +16,12 @@ class Jeu extends Scene {
|
|
|
|
public arrivery_ : number;
|
|
|
|
public arrivery_ : number;
|
|
|
|
public compteurfromage_ : number;
|
|
|
|
public compteurfromage_ : number;
|
|
|
|
public compteurfraise_ : number;
|
|
|
|
public compteurfraise_ : number;
|
|
|
|
|
|
|
|
public totalfraise_ : number;
|
|
|
|
|
|
|
|
public totalfromage_ : number;
|
|
|
|
public mangerfromage_ : Array<Array<Sprite>>;
|
|
|
|
public mangerfromage_ : Array<Array<Sprite>>;
|
|
|
|
public mangerfraise_ : Array<Array<Sprite>>;
|
|
|
|
public mangerfraise_ : Array<Array<Sprite>>;
|
|
|
|
|
|
|
|
public compteurfromagemoins_ : number;
|
|
|
|
|
|
|
|
public compteurfraisemoins_ : number;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -28,6 +32,8 @@ class Jeu extends Scene {
|
|
|
|
this.pas_ = 32;
|
|
|
|
this.pas_ = 32;
|
|
|
|
this.mangerfromage_ = [];
|
|
|
|
this.mangerfromage_ = [];
|
|
|
|
this.mangerfraise_ = [];
|
|
|
|
this.mangerfraise_ = [];
|
|
|
|
|
|
|
|
this.compteurfromagemoins_ = 0;
|
|
|
|
|
|
|
|
this.compteurfraisemoins_ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -60,7 +66,6 @@ public dessinerLabyrinthe(){
|
|
|
|
if (this.carte_[i][j] == 9){
|
|
|
|
if (this.carte_[i][j] == 9){
|
|
|
|
this.arriverx_ = j;
|
|
|
|
this.arriverx_ = j;
|
|
|
|
this.arrivery_ = i;
|
|
|
|
this.arrivery_ = i;
|
|
|
|
// console.log(this.arriverx_,this.arrivery_);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.carte_[i][j] == 1){
|
|
|
|
if(this.carte_[i][j] == 1){
|
|
|
|
this.wall_ = new Sprite(document.createElement("img"));
|
|
|
|
this.wall_ = new Sprite(document.createElement("img"));
|
|
|
@ -89,13 +94,11 @@ public dessinerLabyrinthe(){
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.carte_[i][j] == 2){
|
|
|
|
if(this.carte_[i][j] == 2){
|
|
|
|
this.mangerfromage_[i][j] = this.fromage_;
|
|
|
|
this.mangerfromage_[i][j] = this.fromage_;
|
|
|
|
this.compteurfromage_++;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.mangerfromage_[i][j] = null;
|
|
|
|
this.mangerfromage_[i][j] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.carte_[i][j] == 3){
|
|
|
|
if(this.carte_[i][j] == 3){
|
|
|
|
this.mangerfraise_[i][j] = this.fraise_;
|
|
|
|
this.mangerfraise_[i][j] = this.fraise_;
|
|
|
|
this.compteurfraise_++;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
this.mangerfraise_[i][j] = null;
|
|
|
|
this.mangerfraise_[i][j] = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -104,8 +107,6 @@ public dessinerLabyrinthe(){
|
|
|
|
console.log(this.mangerfromage_);
|
|
|
|
console.log(this.mangerfromage_);
|
|
|
|
console.log(this.mangerfraise_);
|
|
|
|
console.log(this.mangerfraise_);
|
|
|
|
console.log(this.carte_);
|
|
|
|
console.log(this.carte_);
|
|
|
|
console.log(this.compteurfraise_);
|
|
|
|
|
|
|
|
console.log(this.compteurfromage_);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public retirerFromage(y : number, x : number){
|
|
|
|
public retirerFromage(y : number, x : number){
|
|
|
@ -115,6 +116,9 @@ public retirerFromage(y : number, x : number){
|
|
|
|
for(let j = 0 ; j<this.carte_[i].length; j++){
|
|
|
|
for(let j = 0 ; j<this.carte_[i].length; j++){
|
|
|
|
if (this.carte_[i][j] == 8){
|
|
|
|
if (this.carte_[i][j] == 8){
|
|
|
|
this.carte_[i][j] = 4;
|
|
|
|
this.carte_[i][j] = 4;
|
|
|
|
|
|
|
|
this.compteurfromagemoins_++;
|
|
|
|
|
|
|
|
this.compteurfromage_ = this.totalfromage_ - this.compteurfromagemoins_;
|
|
|
|
|
|
|
|
console.log(this.compteurfromage_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -127,23 +131,59 @@ public retirerFraise(y : number, x : number){
|
|
|
|
for(let j = 0 ; j<this.carte_[i].length; j++){
|
|
|
|
for(let j = 0 ; j<this.carte_[i].length; j++){
|
|
|
|
if (this.carte_[i][j] == 8){
|
|
|
|
if (this.carte_[i][j] == 8){
|
|
|
|
this.carte_[i][j] = 4;
|
|
|
|
this.carte_[i][j] = 4;
|
|
|
|
|
|
|
|
this.compteurfraisemoins_++;
|
|
|
|
|
|
|
|
this.compteurfraise_ = this.totalfraise_ - this.compteurfraisemoins_;
|
|
|
|
|
|
|
|
console.log(this.compteurfraise_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.removeAllChildNodes();
|
|
|
|
this.removeAllChildNodes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public replacerPersonnage(ny : number, nx : number, ay : number, ax : number){
|
|
|
|
|
|
|
|
this.carte_[ny][nx] = 8;
|
|
|
|
|
|
|
|
this.carte_[ay][ax] = 4;
|
|
|
|
|
|
|
|
// for(let i = 0 ; i<this.carte_.length; i++){
|
|
|
|
|
|
|
|
// for(let j = 0 ; j<this.carte_[i].length; j++){
|
|
|
|
|
|
|
|
// if (this.carte_[i][j] == 8){
|
|
|
|
|
|
|
|
// this.carte_[i][j] = 4;
|
|
|
|
|
|
|
|
// console.log("j'ai bouger");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
this.removeAllChildNodes();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public removeAllChildNodes() {
|
|
|
|
public removeAllChildNodes() {
|
|
|
|
const scene = document.getElementById('scene')
|
|
|
|
const scene = document.getElementById('scene')
|
|
|
|
while (scene.firstChild) {
|
|
|
|
while (scene.firstChild) {
|
|
|
|
scene.removeChild(scene.firstChild);
|
|
|
|
scene.removeChild(scene.firstChild);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public compteur(){
|
|
|
|
|
|
|
|
this.totalfromage_ = 0;
|
|
|
|
|
|
|
|
this.totalfraise_ = 0;
|
|
|
|
|
|
|
|
for(let i = 0 ; i<this.carte_.length; i++){
|
|
|
|
|
|
|
|
for(let j = 0 ; j<this.carte_[i].length; j++){
|
|
|
|
|
|
|
|
if(this.carte_[i][j] == 2){
|
|
|
|
|
|
|
|
this.totalfromage_++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.carte_[i][j] == 3){
|
|
|
|
|
|
|
|
this.totalfraise_++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(this.totalfraise_);
|
|
|
|
|
|
|
|
console.log(this.totalfromage_);
|
|
|
|
|
|
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------start
|
|
|
|
//--------------------------------------------------------------------------------------------start
|
|
|
|
public override start() {
|
|
|
|
public override start() {
|
|
|
|
/* Ecrire ici le code qui demarre la scene. */
|
|
|
|
/* Ecrire ici le code qui demarre la scene. */
|
|
|
|
console.log(this.carte_);
|
|
|
|
console.log(this.carte_);
|
|
|
|
this.initialiserCarte();
|
|
|
|
this.initialiserCarte();
|
|
|
|
this.dessinerLabyrinthe();
|
|
|
|
this.dessinerLabyrinthe();
|
|
|
|
|
|
|
|
this.compteur();
|
|
|
|
this.rat_.animer();
|
|
|
|
this.rat_.animer();
|
|
|
|
this.rat_.estArriver();
|
|
|
|
this.rat_.estArriver();
|
|
|
|
}
|
|
|
|
}
|
|
|
|