int Avancer2(char table[][MAZE_MAX_SIZE], unsigned int X, unsigned int Y, unsigned int sens) { int i; int tourner = 0; int avancer = 0; table[Y][X] = table[Y][X] | 16; // Interrogation des capteurs pour déterminer si il y a un mur devant/droite/gauche // GetPosition(X, Y, sens, table); display2(table, 20, sens); // est-on sur la case de fin if (table[Y][X] == 0x10) { tabsens[increment + 1] = sens; return (increment + 1); // On est en dehors de l'initialisation du tableau donc hors du labyrinthe } if (!trouve2) { // On n'a pas encore trouvé l'arrivée char porte; unsigned char tmpX, tmpY; for (i = 0; i <= 3; i++) { if (!trouve2) { porte = (table[Y][X] & _porte2[i]); // Test N, E, S, W if (porte == 0) { //0= pas de mur! tmpX = (X + dx2[i]); // Calcul de la prochaine position tmpY = (Y + dy2[i]); porte = (table[tmpY][tmpX]) & 0x10; // Pour tester si on est déjà passé par là if (porte == 0) { // c'est bon on est pas encore passé par là increment++; tabsens[increment] = i; // Enregistrer la nouvelle position tourner = tabsens[increment] - tabsens[increment - 1]; // calcul de la rotation à envoyer avancer = 1; //commande( tourner,avancer); trouve2 = Avancer2(table, tmpX, tmpY, i); } } } } // Si on ne veut pas que le robot retourne au depart tout en marche arriere depuis l'arrivee tourner = tabsens[increment] - tabsens[increment - 1]; increment--; avancer = 1; // table[Y][X] = table[Y][X]-16; // on efface la trace de notre passage commande(tourner, avancer); } return trouve2; }
gboolean icon_clicked(void **arg, GdkEvent *ev) { if(ev->type==GDK_BUTTON_PRESS) { PurpleConversation *conv=arg[0]; char **args=malloc(2*sizeof(char*)); args[0]=arg[1]; args[1]=NULL; commande(conv, g_strdup("jeu"), args, NULL, NULL); return TRUE; } return FALSE; }
Console::Console(QObject *parent, Datas *datas) : QObject(parent) { //Affectation this->datas = datas; //Création des widget liste = new QListWidget(); line = new QLineEdit(); //Layout des widget QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(liste); layout->addWidget(line); //Widget contenant le tout QWidget *contenuDock = new QWidget; contenuDock->setLayout(layout); //Création du dock dock = new QDockWidget(); dock->setWidget(contenuDock); connect(line, SIGNAL(returnPressed()), this, SLOT(commande())); connect(this, SIGNAL(newItem(QListWidgetItem*)), liste, SLOT(scrollToBottom())); //Configuration de base log_client = false; log_serveur = false; log_main = false; log_collision = false; log_collision_latence = false; log_avion = false; log_horloge = false; logCollisionLatenceItem = new QListWidgetItem(); timerTest = new QTimer(this); connect(timerTest, SIGNAL(timeout()), this, SLOT(timerSlot())); }