//----- // Nom du projet : Fly Simulator // Version : - dev - // Dernière modification le : 23 juillet 2019 //----- #include #include #include #include #define C_RED 0xf800 #define C_GREEN 0x07e0 #define C_BLUE 0x001f //communication : gère les communications entre la tour et l'avion void communication (int *com_id, int *id, const int langue); //display_comm : affiche les communications void display_comm (char *msg_1,char *msg_2,char *msg_3, const int *joueur); //fill_char : initialise une chaine avec un nombre de caractères répétés 'n' fois char *fill_char(char *dest, const char *src, unsigned int debut, unsigned int fin); int main (void) { int com_id = 1, id = 0, langue = 0;// variables des communications int key = 0;//variables diverses dclear(C_WHITE); dtext(1, 1, "Choix de la langue", C_RED, C_NONE); dtext(1, 12, " 1. Francais", C_BLUE, C_NONE); dtext(1, 23, " 2. Anglais", C_BLACK, C_NONE); dupdate(); while (langue == 0) { key = getkey().key; if (key == KEY_1) langue = 1; if (key == KEY_2) langue = 2; } langue -= 1; while(com_id <= 26) { communication(&com_id, &id, langue); key = getkey().key; dupdate(); if(key == KEY_EXIT) return 0; } getkey(); return 0; } void communication(int *com_id, int *id, const int langue) { //faire un choix de la langue Français / Anglais const char *avion = "Cessna 172", *immat = "F-GUXF", *immat_courte = "F-XF", *aipt_depart = "Caen", *aipt_arrivee = "Le Havre", *freq_cont = "117.15", *freq_arrivee = "122.80", *passagers = "4";//données de l'avion et de son trajet char *comm_1[2] = {"%s tour, %s. Bonjour.", "%s tower, %s. Good morning."}, *comm_2[2] = {"%s, %s bonjour.", "%s, %s Hello."}, *comm_3_1[2] = {"%s %s. %s passagers a bord. Demandons", "%s %s. %s passengers on board. Request"}, *comm_3_2[2] = {"vol vers %s.", "flight to %s."}, *comm_4[2] = {"%s vol autorise. Rappelez pret au depart.", "%s authorized flight. Call back clear to take off."}, *comm_5[2] = {"Rappelons pret au depart, %s.", "Call back clear to take off, %s."}, *comm_6[2] = {"%s, pret au depart.", "%s, clear for take off." }, *comm_7[2] = {"%s, autorise decollage.", "%s, authorized take off."}, *comm_8[2] = {"Autorise decollage, %s.", "Authorized take off, %s."}, *comm_9_1[2] = {"%s, vous quittez mon espace. Services radar", "%s, you leave my airpace. Services radar"}, *comm_9_2[2] = {"et radio termines. Informations de vol avec", "and radio terminated. Informations for flight"}, *comm_9_3[2] = {"Controle, %s. Au revoir.", "with Controle, %s. Bye."}, *comm_10[2] = {"Controle, %s. Bonne journee, %s.", "Controle, %s. See you, %s."}, *comm_11[2] = {"Controle %s. Bonjour.", "Controle %s. Hello."}, *comm_12[2] = {"%s Controle, bienvenu.", "%s Controle, welcome."}, *comm_13_1[2] = {"%s %s. %s passagers a bord. Sortie de", "%s %s. %s passengers on board. Exit"}, *comm_13_2[2] = {"%s vers %s.", "%s towards %s."}, *comm_14[2] = {"%s, identifie radar.", "%s, identify radar."}, *comm_15_1[2] = {"%s, vous quittez mon espace. Contactez", "%s, you leave my airspace. Contact"}, *comm_15_2[2] = {"%s, %s. Bon vol.", "%s, %s. Have a good flight."}, *comm_16[2] = {"%s %s. Au revoir, %s.", "%s %s. Good bye, %s."}, *comm_17[2] = {"%s tour, %s. Bonjour.", "%s tower, %s. Hy."}, *comm_18[2] = {"%s, %s, a l'ecoute.", "%s, %s, listen."}, *comm_19_1[2] = {"%s %s. %s passagers a bord. Demandons", "%s %s. %s passengers on board. Request"}, *comm_19_2[2] = {"consignes pour atterrissage sur %s.", "instructions for landing on %s."}, *comm_20[2] = {"%s, commencez votre approche.", "%s, starts your approach."}, *comm_21[2] = {"Commencons notre approche, %s.", "We start our approach, %s."}, *comm_22_1[2] = {"%s en finale, demandons autorisation", "%s on final, request clearance"}, *comm_22_2[2] = {"d'atterrissage.", "to landing."}, *comm_23[2] = {"%s, autorise atterrissage. Rappelez au sol.", "%s, authorized landing. Call back on ground."}, *comm_24[2] = {"Autorise atterrissage, rappelons au sol, %s.", "Authorized landing, call back on ground, %s."}, *comm_25[2] = {"%s, au sol, pour quitter. Merci.", "%s, on ground for leave. Thanks."}, *comm_26[2] = {"%s, quittez la frequence a bientot.", "%s, leave frequence, see you."}; char msg_1[70], msg_2[70], msg_3[70]; fill_char(msg_1, " ", 0, 70); fill_char(msg_2, " ", 0, 70); fill_char(msg_3, " ", 0, 70); switch (*com_id) { case 1: *id = 1; sprintf(msg_1, comm_1[langue], aipt_depart, immat); break; case 2: *id = 0; sprintf(msg_1, comm_2[langue], immat, aipt_depart); break; case 3: *id = 1; sprintf(msg_1, comm_3_1[langue], immat, avion, passagers); sprintf(msg_2, comm_3_2[langue], aipt_arrivee); break; case 4: *id = 0; sprintf(msg_1, comm_4[langue], immat_courte); break; case 5: *id = 1; sprintf(msg_1, comm_5[langue], immat_courte); break; case 6: *id = 1; sprintf(msg_1, comm_6[langue], immat_courte); break; case 7: *id = 0; sprintf(msg_1, comm_7[langue], immat_courte); break; case 8: *id = 1; sprintf(msg_1, comm_8[langue], immat_courte); break; case 9: *id = 0; sprintf(msg_1, comm_9_1[langue], immat_courte); sprintf(msg_2, comm_9_2[langue]); sprintf(msg_3, comm_9_3[langue], freq_cont); break; case 10: *id = 1; sprintf(msg_1, comm_10[langue], freq_cont, immat_courte); break; case 11: *id = 1; sprintf(msg_1, comm_11[langue], immat); break; case 12: *id = 0; sprintf(msg_1, comm_12[langue], immat_courte); break; case 13: *id = 1; sprintf(msg_1, comm_13_1[langue], immat, avion, passagers); sprintf(msg_2, comm_13_2[langue], aipt_depart, aipt_arrivee); break; case 14: *id = 0; sprintf(msg_1, comm_14[langue], immat_courte); break; case 15: *id = 0; sprintf(msg_1, comm_15_1[langue], immat_courte); sprintf(msg_2, comm_15_2[langue], aipt_arrivee, freq_arrivee); break; case 16: *id = 1; sprintf(msg_1, comm_16[langue], aipt_arrivee, freq_arrivee, immat_courte); break; case 17: *id = 1; sprintf(msg_1, comm_17[langue], aipt_arrivee, immat); break; case 18: *id = 0; sprintf(msg_1, comm_18[langue], immat_courte, aipt_arrivee); break; case 19: *id = 1; sprintf(msg_1, comm_19_1[langue], immat, avion, passagers); sprintf(msg_2, comm_19_2[langue], aipt_arrivee); break; case 20: *id = 0; sprintf(msg_1, comm_20[langue], immat_courte); break; case 21: *id = 1; sprintf(msg_1, comm_21[langue], immat_courte); break; case 22: *id = 1; sprintf(msg_1, comm_22_1[langue], immat_courte); sprintf(msg_2, comm_22_2[langue]); break; case 23: *id = 0; sprintf(msg_1, comm_23[langue], immat_courte); break; case 24: *id = 1; sprintf(msg_1, comm_24[langue], immat_courte); break; case 25: *id = 1; sprintf(msg_1, comm_25[langue], immat_courte); break; case 26: *id = 0; sprintf(msg_1, comm_26[langue], immat_courte); break; } display_comm(msg_1, msg_2, msg_3, &(*id)); *com_id += 1; } void display_comm (char *msg_1,char *msg_2, char *msg_3, const int *joueur) { fill_char(msg_1, " ", strlen(msg_1), 70); fill_char(msg_2, " ", strlen(msg_2), 70); fill_char(msg_3, " ", strlen(msg_3), 70); if (*joueur == 1){ dtext(1, 1, msg_1, C_BLUE, C_WHITE); dtext(1, 12, msg_2, C_BLUE, C_WHITE); dtext(1, 23, msg_3, C_BLUE, C_WHITE); } else{ dtext(1, 1, msg_1, C_BLACK, C_WHITE); dtext(1, 12, msg_2, C_BLACK, C_WHITE); dtext(1, 23, msg_3, C_BLACK, C_WHITE); } } char *fill_char(char *dest, const char *src, unsigned int debut, unsigned int fin) { unsigned int i; for (i = debut ; i < fin ; i++) { dest[i] = src[0]; } dest[fin] = '\0'; return dest; }