|
|
@ -15,44 +15,36 @@ class Rat extends Sprite {
|
|
|
|
this.getElement().style.zIndex = "2";
|
|
|
|
this.getElement().style.zIndex = "2";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public haut(){
|
|
|
|
async haut(){
|
|
|
|
if(this.scene_.carte_[this.py_-1][this.px_] == 1){
|
|
|
|
while(this.scene_.carte_[this.py_-1][this.px_] != 1){
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
this.py_ = this.py_-1;
|
|
|
|
this.py_ = this.py_-1;
|
|
|
|
this.setXY(this.getX(),this.getY()-this.scene_.pas_);
|
|
|
|
this.setXY(this.getX(),this.getY()-this.scene_.pas_);
|
|
|
|
this.getElement().style.transform = 'rotate(-90deg)';
|
|
|
|
this.getElement().style.transform = 'rotate(-90deg)';
|
|
|
|
// this.setXY(this.px_*this.scene_.pas_,this.py_*this.scene_.pas_);
|
|
|
|
await new Promise<void>(resolve => setTimeout(resolve, 20));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public bas(){
|
|
|
|
async bas(){
|
|
|
|
if(this.scene_.carte_[this.py_+1][this.px_] == 1){
|
|
|
|
while(this.scene_.carte_[this.py_+1][this.px_] != 1){
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
this.py_ = this.py_+1;
|
|
|
|
this.py_ = this.py_+1;
|
|
|
|
this.setXY(this.getX(),this.getY()+this.scene_.pas_);
|
|
|
|
this.setXY(this.getX(),this.getY()+this.scene_.pas_);
|
|
|
|
this.getElement().style.transform = 'rotate(90deg)';
|
|
|
|
this.getElement().style.transform = 'rotate(90deg)';
|
|
|
|
// this.setXY(this.px_*this.scene_.pas_,this.py_*this.scene_.pas_);
|
|
|
|
await new Promise<void>(resolve => setTimeout(resolve, 20));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public gauche(){
|
|
|
|
async gauche(){
|
|
|
|
if(this.scene_.carte_[this.py_][this.px_-1] == 1){
|
|
|
|
while(this.scene_.carte_[this.py_][this.px_-1] != 1){
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
this.px_ = this.px_-1;
|
|
|
|
this.px_ = this.px_-1;
|
|
|
|
this.setXY(this.getX()-this.scene_.pas_,this.getY());
|
|
|
|
this.setXY(this.getX()-this.scene_.pas_,this.getY());
|
|
|
|
this.getElement().style.transform = 'rotate(90deg) scale(-1,1)';
|
|
|
|
this.getElement().style.transform = 'rotate(90deg) scale(-1,1)';
|
|
|
|
// this.setXY(this.px_*this.scene_.pas_,this.py_*this.scene_.pas_);
|
|
|
|
await new Promise<void>(resolve => setTimeout(resolve, 20));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public droite(){
|
|
|
|
async droite(){
|
|
|
|
if(this.scene_.carte_[this.py_][this.px_+1] == 1){
|
|
|
|
while(this.scene_.carte_[this.py_][this.px_+1] != 1){
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
this.px_ = this.px_+1;
|
|
|
|
this.px_ = this.px_+1;
|
|
|
|
this.setXY(this.getX()+this.scene_.pas_,this.getY());
|
|
|
|
this.setXY(this.getX()+this.scene_.pas_,this.getY());
|
|
|
|
this.getElement().style.transform = 'rotate(90deg) scale(1,1)';
|
|
|
|
this.getElement().style.transform = 'rotate(90deg) scale(1,1)';
|
|
|
|
// this.setXY(this.px_*this.scene_.pas_,this.py_*this.scene_.pas_);
|
|
|
|
await new Promise<void>(resolve => setTimeout(resolve, 20));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private deplacer(event : KeyboardEvent){
|
|
|
|
private deplacer(event : KeyboardEvent){
|
|
|
@ -83,5 +75,5 @@ class Rat extends Sprite {
|
|
|
|
|
|
|
|
|
|
|
|
public estArriver(){
|
|
|
|
public estArriver(){
|
|
|
|
return this.scene_.carte_[this.py_][this.px_] == 9;
|
|
|
|
return this.scene_.carte_[this.py_][this.px_] == 9;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|