public boolean getbool(int posX, int posY, Direction laDirect){ int index; boolean actif; index = 0; actif = true; if (laDirect == Direction.VERS_LE_HAUT){ index = (((posY-1) * 45) + (posX) ); } else if (laDirect == Direction.VERS_LE_BAS){ index = ((posY * 45) + (posX )); } else if (laDirect == Direction.VERS_LA_GAUCHE){ index = (((posY - 1) * 45) + (posX-1) ); } else if (laDirect == Direction.VERS_LA_DROITE){ index = ((posY * 45) + (posX+1) ); } if (laby[index] == 1){ actif = true; } else if (laby[index] == 0){ actif = false; } else if (laby[index] == 2){ actif = false; } return actif; }
public boolean getbool(int posX, int posY, Direction laDirect){ int index; boolean actif; index = 0; switch(laDirect){ case Direction.VERS_LE_HAUT: index = (((posY-1) * 45) + (posX) ); break; case Direction.VERS_LE_BAS: index = ((posY * 45) + (posX )); break; case Direction.VERS_LA_GAUCHE: index = (((posY - 1) * 45) + (posX-1) ); break; case Direction.VERS_LA_DROITE: index = ((posY * 45) + (posX+1) ); break; } return laby[index] == 1; }
- Vaut t'il mieu que je m'y prenne autrement ? ( sachant que j'aimerais que mon pacman commence a bouger que lorque j'appuis sur une touche , actuellement il bouge automatiquement vers la gauche dès le lancer du jeu )
- Si oui comment ? ^^
public void calcul(){ this.lelabyrinthe.calcul(); //this.lanourriture.calcul(); int laPosX, laPosY ; laPosX = (this.leperso.getPosX() / Constantes.CASE_EN_PIXELS) ; laPosY = (this.leperso.getPosY() / Constantes.CASE_EN_PIXELS) ; laDirect = this.leperso.laDirection(); if (laDirect != null){ if (this.lelabyrinthe.getbool(laPosX, laPosY, laDirect) == true){ this.laDirect = null; } else { this.leperso.calcul(); } } }
- Lorsque le pacman arrive sur un mur ma direction passe a null donc le mouvement s'arrete ( forcement ) comment faut'il que je m'y prenne pour le faire repartir dans une autre direction ? ( ccar actuellement il ne bouge plus je suis obligé de relancer le jeu )
int laPosX, laPosY ; laPosX = (this.leperso.getPosX() / Constantes.CASE_EN_PIXELS) ; laPosY = (this.leperso.getPosY() / Constantes.CASE_EN_PIXELS) ; //laDirect = Direction.VERS_LE_BAS; if (this.lelabyrinthe.getbool(laPosX, laPosY, laDirect) == true){ this.laDirect = null; } else { this.leperso.calcul(); }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpublic boolean getbool(int posX, int posY, Direction laDirect){ int index; boolean actif; index = 0; actif = true; if (laDirect == Direction.VERS_LE_HAUT){ index = (((posY-1) * 45) + (posX) ); } else if (laDirect == Direction.VERS_LE_BAS){ index = ((posY * 45) + (posX )); } else if (laDirect == Direction.VERS_LA_GAUCHE){ index = (((posY - 1) * 45) + (posX-1) ); } else if (laDirect == Direction.VERS_LA_DROITE){ index = ((posY * 45) + (posX+1) ); } if (laby[index] == 1){ actif = true; } else if (laby[index] == 0){ actif = false; } else if (laby[index] == 2){ actif = false; } return actif; }
int laPosX, laPosY ; laPosX = (this.leperso.getPosX() / Constantes.CASE_EN_PIXELS) ; laPosY = (this.leperso.getPosY() / Constantes.CASE_EN_PIXELS) ; //laDirect = Direction.VERS_LE_BAS; if (this.lelabyrinthe.getbool(laPosX, laPosY, laDirect) == true){ this.laDirect = null; } else { this.leperso.calcul(); }
laDirect = Direction.VERS_LA_GAUCHE;
laDirect = Direction.VERS_LA_DROITE;
laDirect = Direction.VERS_LA_GAUCHE;
laDirect = Direction.VERS_LA_DROITE;
public void calcul(){ this.lelabyrinthe.calcul(); //this.lanourriture.calcul(); int laPosX, laPosY ; laPosX = (this.leperso.getPosX() / Constantes.CASE_EN_PIXELS) ; laPosY = (this.leperso.getPosY() / Constantes.CASE_EN_PIXELS) ; laDirect = this.leperso.laDirection(); if (laDirect == null){ laDirect = Direction.VERS_LA_GAUCHE; } if (this.lelabyrinthe.getbool(laPosX, laPosY, laDirect) == true){ this.laDirect = null; } else { this.leperso.calcul(); } }