1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| public boolean marcherAvant(int _angle)
{
double posX = Math.round(this.pos.getX()*100.00)/100.00;
double posY = Math.round(this.pos.getY()*100.00)/100.00;
double moveCos = Math.round(Math.cos(this.angle*Math.PI/180)*100.00)/100.00;
double moveSin = Math.round(Math.sin(this.angle*Math.PI/180)*100.00)/100.00;
if(this.estOn)
{
this.pos.setX(posX + Math.round(this.vitesse*moveCos*100.00)/100.00);
this.pos.setY(posY + Math.round(this.vitesse*moveSin*100.00)/100.00);
return true;
}
else
{
return false;
}
}
public boolean marcherArriere(int _angle)
{
double posX = Math.round(this.pos.getX()*100.00)/100.00;
double posY = Math.round(this.pos.getY()*100.00)/100.00;
double moveCos = Math.round(Math.cos((this.angle+180)*Math.PI/180)*100.00)/100.00;
double moveSin = Math.round(Math.sin((this.angle+180)*Math.PI/180)*100.00)/100.00;
if(this.estOn)
{
this.pos.setX(posX+ Math.round(this.vitesse*moveCos*100)/100);
this.pos.setY(posX+ Math.round(this.vitesse*moveSin*100)/100);
return true;
}
else
{
return false;
}
} |