//================================================================================================== // ANIMATION AVEC TYPESCRIPT Jeu.ts //================================================================================================== // Classe J e u //--------------------------------------------------------------------------------- class Jeu extends Scene { //----------------------------------------------------------------------------------------Attributs /* Declarer ici les attributs de la scene. */ public carte_ : Array>; public wall_ : Sprite; public pas_ : number; public rat_ : Rat; public fromage_ : Sprite; public fraise_ : Sprite; public arriverx_ : number; public arrivery_ : number; public compteurfromage_ : number; public compteurfraise_ : number; public totalfraise_ : number; public totalfromage_ : number; public mangerfromage_ : Array>; public mangerfraise_ : Array>; public compteurfromagemoins_ : number; public compteurfraisemoins_ : number; public niveau_ : any; private idniveau_ : number; //-------------------------------------------------------------------------------------Constructeur public constructor(element : HTMLElement) { super(element,false); /* Ecrire ici le code qui initialise la scene. */ this.pas_ = 32; this.mangerfromage_ = []; this.mangerfraise_ = []; this.compteurfromagemoins_ = 0; this.compteurfraisemoins_ = 0; this.idniveau_ = 1; } private telechargerNiveau(id : number){ let requete : XMLHttpRequest = new XMLHttpRequest(); let parametres : string = "id=" + id; requete.open("get", "http://localhost/SAE/index.php?" + parametres); /* Ecouteur déclenché à la réception des données */ requete.onreadystatechange = () => { if (requete.readyState == XMLHttpRequest.DONE && requete.status == 200) { this.niveau_ = JSON.parse(requete.responseText); /* Suite du code */ console.log(this.niveau_.id); console.log(this.niveau_.niveau); this.start_suite(); } } requete.send(); } private initialiserCarte(){ // this.carte_ = []; // this.carte_[0] = [1 ,1 ,1 ,0 ,0 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,0 ,1 ,1 ,1 ,1 ,1 ,0 ,0 ]; // this.carte_[1] = [1 ,8 ,1 ,0 ,0 ,1 ,2 ,2 ,2 ,2 ,2 ,1 ,0 ,1 ,2 ,2 ,2 ,1 ,0 ,0 ]; // this.carte_[2] = [1 ,2 ,1 ,0 ,0 ,1 ,2 ,4 ,4 ,4 ,2 ,1 ,0 ,1 ,2 ,1 ,2 ,1 ,1 ,0 ]; // this.carte_[3] = [1 ,2 ,1 ,0 ,0 ,1 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