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.
58 lines
1.2 KiB
58 lines
1.2 KiB
class Pacman extends Sprite {
|
|
|
|
//Attributs
|
|
public scene_ : Jeu;
|
|
private ecouteurDeplacer : any;
|
|
//Constructeur
|
|
public constructor(scene : Jeu,element : HTMLElement){
|
|
super(element);
|
|
this.scene_ = scene;
|
|
this.ecouteurDeplacer
|
|
}
|
|
|
|
public haut(){
|
|
if(this.scene_.carte_[this.scene_.py-1][this.scene_.px] == 1){
|
|
|
|
}else{
|
|
this.setXY(this.getX()-this.scene_.pas_,this.getY());
|
|
}
|
|
}
|
|
public bas(){
|
|
if(this.scene_.carte_[this.scene_.py+1][this.scene_.px] == 1){
|
|
|
|
}else{
|
|
this.setXY(this.getX()+this.scene_.pas_,this.getY());
|
|
}
|
|
}
|
|
public gauche(){
|
|
if(this.scene_.carte_[this.scene_.py][this.scene_.px-1] == 1){
|
|
|
|
}else{
|
|
this.setXY(this.getX(),this.getY()-this.scene_.pas_);
|
|
}
|
|
}
|
|
public droite(){
|
|
if(this.scene_.carte_[this.scene_.py+1][this.scene_.px+1] == 1){
|
|
|
|
}else{
|
|
this.setXY(this.getX(),this.getY()+this.scene_.pas_);
|
|
}
|
|
}
|
|
private deplacer(event : KeyboardEvent){
|
|
if(event.key == "ArrowLeft"){
|
|
this.gauche();
|
|
}
|
|
if(event.key == "ArrowRight"){
|
|
this.droite();
|
|
}
|
|
if(event.key == "ArrowDown"){
|
|
this.haut();
|
|
}
|
|
if(event.key == "ArrowLeft"){
|
|
this.bas();
|
|
}
|
|
}
|
|
public animer(){
|
|
|
|
}
|
|
} |