void thread_input() { char c; int r; c = getchar(); switch(c) { case 'z': haut(); break; case 's': bas(); break; case 'd': droite(); break; case 'q': gauche(); break; case 27: r = 1; while ((c = getchar()) != -1) { if (c == 27) { r = 1; continue; } r = r * 128 + c; } switch (r) { case 28097: haut(); break; case 28098: bas(); break; case 28099: droite(); break; case 28100: gauche(); break; } } }
void second_letter_one(t_grille grille, t_mots *mot, int i, int j) { if ((j < grille.y) && (mot->word[1] == grille.tab[i][j + 1] && mot->trouve != 1)) droite(grille, mot, i ,j); if ((j > 0) && (mot->word[1] == grille.tab[i][j - 1] && mot->trouve != 1)) gauche(grille, mot, i ,j); if ((i > 0) && (mot->word[1] == grille.tab[i - 1][j] && mot->trouve != 1)) haut(grille, mot, i ,j); if ((i < grille.x) && (mot->word[1] == grille.tab[i + 1][j] && mot->trouve != 1)) bas(grille, mot, i ,j); }
int main() { for(int i=0;i<9;++i) haut(); droite(); for(int j=0;j<5;++j) { for(int i=0;i<8;++i) droite(); bas(); for(int i=0;i<8;++i) gauche(); if(j!=4) bas(); } gauche(); }
void trouver_chemin(GameElements::Map * map, Math::Vector2<int> & my_cell,Math::Vector2<int> & target_cell,std::vector<Math::Vector2<int>> & chemin) { value_tab[my_cell[0]][my_cell[1]] =0; Math::Vector2<int> current_cell = target_cell; int val_h = 0,val_b = 0,val_d = 0,val_g = 0; while(!(current_cell[0] == my_cell[0] && current_cell[1] == my_cell[1])) { val_h =0; val_b =0; val_g =0; val_d =0; //calculer les index des cellules autour Math::Vector2<int> haut(current_cell); Math::Vector2<int> bas(current_cell); Math::Vector2<int> gauche(current_cell); Math::Vector2<int> droite(current_cell); Math::Vector2<int> choice(current_cell); if(bas[0] < map->height()-1) bas[0] ++; if(haut[0] > 0) haut[0] --; if(gauche[1] > 0) gauche[1] --; if(droite[1] < map->width()-1) droite[1] ++; int min_val = value_tab[current_cell[0]][current_cell[1]]; if(haut[0] != current_cell[0]){val_h = value_tab[haut[0]][haut[1]];} if(gauche[1] != current_cell[1]){val_g = value_tab[gauche[0]][gauche[1]];} if(droite[1] != current_cell[1]){val_d = value_tab[droite[0]][droite[1]];} if(bas[0] != current_cell[0]){ val_b = value_tab[bas[0]][bas[1]] ;} //rechercher la cellule avec la valeur min la plus proche if(val_h == -1 && val_d == -1 && val_g == -1 && val_b == -1){std::cout << "CELLULE NON ATTEINTE !! " << std::endl;break;} else{ if(val_h != -1) if(min_val > val_h) { min_val = val_h; choice = haut; } if(val_g != -1) if(min_val > val_g) { min_val = val_g; choice = gauche; } if(val_d != -1) if(min_val > val_d) { min_val = val_d; choice = droite; } if(val_b != -1) if(min_val > val_b) { min_val = val_b; choice = bas; } current_cell = choice ; chemin.push_back(choice); } } }