parent
9ee942037d
commit
cca8533f05
@ -0,0 +1,58 @@
|
||||
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(){
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in new issue