You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.5 KiB

"use strict";
class Jeu extends Scene {
constructor(element) {
super(element, false);
this.zoneDeJeu_ = new Sprite(document.getElementById("jeu"));
this.zoneDeJeu_.setWidth(this.getWidth());
this.zoneDeJeu_.setHeight(this.getHeight());
this.score_ = new Sprite(document.getElementById("score"));
this.compteurScore = 0;
this.monnaie_ = new Sprite(document.getElementById("monnaie"));
this.compteurMonnaie = 0;
}
start() {
this.start_ = new Start(document.getElementById("starting"), this);
}
partieCommencer() {
this.creerJoueur();
this.afficherRegles();
this.afficherShop();
this.creerObject();
}
creerJoueur() {
this.joueur_ = new Joueur(document.createElement("img"), this);
this.joueur_.setImage("img/joe.png", 60, 80);
this.joueur_.setX(this.zoneDeJeu_.getWidth() / 2 - this.joueur_.getWidth() / 2);
this.joueur_.setY(this.zoneDeJeu_.getHeight() / 2 - this.joueur_.getHeight() / 2);
this.appendChild(this.joueur_);
this.joueur_.animer();
}
afficherRegles() {
this.regles_ = new Regles(document.getElementById("regles"), this);
}
afficherShop() {
this.shop_ = new Shop(document.getElementById("Shop"), this);
}
creerObject() {
this.objet_ = new Objet(document.createElement("img"), this);
this.intervalFruit = setInterval(() => { this.objet_.creerFruit(); }, 3000);
this.intervalPoison = setInterval(() => { this.objet_.creerPoison(); }, 3000);
this.intervalPlante = setInterval(() => { this.objet_.creerPlante(); }, 3000);
this.intervalCollision = setInterval(() => { this.joueur_.collisionObjet(); }, 1000 / 144);
}
figerObjet() {
clearInterval(this.intervalFruit);
clearInterval(this.intervalPoison);
clearInterval(this.intervalPlante);
clearInterval(this.intervalCollision);
}
augmenterScore() {
this.compteurScore += 100;
this.score_.getElement().textContent = "" + this.compteurScore;
console.log(this.compteurScore);
}
reduireScore() {
this.compteurScore -= 200;
this.score_.getElement().textContent = "" + this.compteurScore;
console.log(this.compteurScore);
}
augmenterMonnaie() {
this.compteurMonnaie += 25;
this.monnaie_.getElement().textContent = "" + this.compteurMonnaie;
console.log(this.compteurMonnaie);
}
pause() {
}
unpause() {
}
clean() {
}
}