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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
| /*
#include "fonctions.h"
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
/*
*
*/
int main(int argc, char** argv) {
typeElement el, el1, el2;
int touche, rejouer;
char pseudo[255], pseudo1[255];
WINDOW *boite;
time_t depart, arrivee;
time(&depart);
int speed = 0;
printf("oooooooooo. .oooooo. ooooo ooo oooo .oooooo. ooooo ooo ooooooooo. \n");
printf("`888' `Y8b d8P' `Y8b `888b. `8' 888 d8P' `Y8b `888' `8' `888 `Y88. \n");
printf("888 888 888 888 8 `88b. 8 888 888 888 888 8 888 .d88' \n");
printf("888oooo888' 888 888 8 `88b. 8 888 888 888 888 8 888ooo88P' \n");
printf("888 `88b 888 888 8 `88b.8 888 888 888 888 8 888`88b. \n");
printf("888 .88P `88b d88' 8 `888 888 `88b d88' `88. .8' 888 `88b. \n");
printf("o888bood8P' `Y8bood8P' o8o `8 .o.88P `Y8bood8P' `YbodP' o888o o888o \n");
printf(" `Y888P \n");
printf("\n");
printf("8ooooooooo. oooooooooooo .oooooo. ooooo oooooooooooo .oooooo..o \n");
printf("`888 `Y88. `888' `8 d8P' `Y8b `888' `888' `8 d8P' `Y8 \n");
printf("888 .d88' 888 888 888 888 Y88bo. \n");
printf("888ooo88P' 888oooo8 888 888 888oooo8 `Y8888o. \n");
printf("888`88b. 888 888 ooooo 888 888 `Y88b \n");
printf("888 `88b. 888 o `88. .88' 888 o 888 o oo .d8P \n");
printf("o888o o888o o888ooooood8 `Y8bood8P' o888ooooood8 o888ooooood8 8""88888P' \n");
printf("\n");
printf("essayez de survivre le plus longtemps possible à l'attaque de l'ovni\n");
printf("Prenez l'étoile pour aller aussi vite que la lumière !");
printf("\n");
printf("controle du multijoueur : ");
printf("%s Donnez le nom du premier joueur :", BLUE);
scanf("%s", pseudo);
printf("%s Donnez le nom du deuxieme joueur : ", BLUE);
scanf("%s", pseudo1);
do {
setlocale(LC_ALL, ""); // mettre la console en compatibilité d'affichage unicode sous linux
initscr(); // Initialise la structure WINDOW et autres paramètres
el.symbole = 0x1F680; // symbole est une flamme
el.x = 15;
el.y = 15;
el.speed = 1;
el1.symbole = 0x1F6F8;
el1.x = 5;
el1.y = 5;
el1.speed = 1;
el2.symbole = 0x2605;
el2.x = 20;
el2.y = 5;
el2.speed = 1;
boite = subwin(stdscr, HAUTEUR, LARGEUR, 1, 1); // boite positionnee en 1,1 avec comme dimension LARGEURxHAUTEUR
box(boite, ACS_VLINE, ACS_HLINE); // dessiner le contour de la boite
wrefresh(boite); // mettre a jour l'affichage de la boite
mvwprintw(boite, el.y, el.x, "%lc", el.symbole); // on affiche l'element en x,y dans la boite
mvwprintw(boite, el1.y, el1.x, "%lc", el1.symbole);
mvwprintw(boite, el2.y, el2.x, "%lc", el2.symbole);
mvprintw(0, 1, " Joueur 1 : %s Joueur 2 : %s", pseudo, pseudo1);
mvprintw(21, 2, "SPACE WAR");
mvprintw(21, 57, "By SpaceXmas");
curs_set(0); //curseur invisible
noecho(); // pas d'echo de la touche appuyée
time(&depart);
do {
time(&arrivee);
mvprintw(0, 40, "Temps : %.0f secondes", difftime(arrivee, depart));
touche = getch(); // recupérer la valeur de la touche appuyée
if (speed > 0) {
}
switch (touche) {
case '4':bouger(&el, GAUCHE, boite);
break;
case '6':bouger(&el, DROITE, boite);
break;
case '8':bouger(&el, HAUT, boite);
break;
case '2':bouger(&el, BAS, boite);
break;
}
switch (touche) {
case 'q':bouger(&el1, GAUCHE, boite);
bouger(&el2, DROITE, boite);
break;
case 'd':bouger(&el1, DROITE, boite);
bouger(&el2, GAUCHE, boite);
break;
case 'z':bouger(&el1, HAUT, boite);
bouger(&el2, BAS, boite);
break;
case 's':bouger(&el1, BAS, boite);
bouger(&el2, HAUT, boite);
break;
}
if (el.x == el1.x && el.y == el1.y) {
time(&arrivee);
mvprintw(0, 40, "Temps : %.0f secondes", difftime(arrivee, depart));
touche = 'k';
}
if (el.x == el2.x && el.y == el2.y) {
el.speed = 2;
el2.symbole = NULL;
}
if (el.x == el1.x && el.y == el1.y) {
el.symbole = 0x1F525;
}
refresh(); // mise a jour de l'affichage
wrefresh(boite);
} while (touche != 'k');
endwin();
/*for(int i=0;i<LARGEUR;i++){
for(int i=0;i<HAUTEUR;i++) {
mvwprintw(boite, LARGEUR, HAUTEUR,"% ");
}
}*/
printf("%sVoulez vous rejouer (o/n)? ", GREY);
scanf(" %c", &rejouer);
wrefresh(boite);
} while (rejouer != 'n');
endwin(); // remettre le terminal dans son état initial
printf("La fusée à survecu %.0f secondes\n", difftime(arrivee, depart));
return (EXIT_SUCCESS);
} |
Partager