vbfrance102
Messages postés2Date d'inscriptionlundi 23 janvier 2006StatutMembreDernière intervention28 septembre 2011
-
26 sept. 2011 à 11:57
vbfrance102
Messages postés2Date d'inscriptionlundi 23 janvier 2006StatutMembreDernière intervention28 septembre 2011
-
28 sept. 2011 à 01:18
salut
si qlq'un peut m'aider je suis débutant en c et j'essaye de faire une petit jeu qui a 1 threads sous forme de boucle infinie et je veux qu'il me récupère régulièrement la valeure d'un variable voici le code :
#include <conio.h>
#include <stdio.h>
#include <windows.h>
#include
#define LEFT 75
#define RIGHT 77
#define ESC 27
void commande(int *v,char d){
if((v[0]!=39)&(d==RIGHT)){v[0]+=1;clrscr();route();afficheavion(v);}
if((v[0]!=1)&(d==LEFT)){v[0]-=1;clrscr();route();afficheavion(v);}
if(d==ESC){info("APPUYER SUR UNE TOUCHE POUR CONTINUER");
getche();
//affichage de la bombe *********************************
void affichebombe(int *e){
gotoxy(e[0],e[1]);printf(" ");
gotoxy(e[0],e[1]+1);printf(" %c%c%d ",178,178,un);
gotoxy(e[0],e[1]+2);printf(" %c%c%d %d ",178,178,e[0],e[1]+1);
gotoxy(e[0],e[1]+3);printf(" ");
}
//mouvement de la bombe *********************************
void* mvtbombe(){
int i,j;
int bombe[2]={2,1};
for(;;){
affichebombe(bombe);
bombe[1]=1;
for (i=0;i<21;i++)
{
Sleep(230);
bombe[1]++;
affichebombe(bombe);
//--> c'est d'ici que je veux extraire la position de la bombe pour verifier s'il ya un contacte avec l'avion
}
}
}
main(){
struct XY {int x,y;};
int i,j;
int avion[2]={20,18};
int bombe[2]={2,1};
int bombe2[2]={10,1};
int e[2]={2,1};
char touche;
route();
afficheavion(avion);
affichescore(30,40,5,3);
pthread_t ta;// On crée un thread ta
affichebombe(bombe);
pthread_create(&ta, NULL, mvtbombe, NULL);// Permet d'exécuter la fonction mvtbombe (mouvement de la bombe) en boucle infinie
for(;;){
// verification du contact avec l'avion*******************************
// c'est ici que je veux la valeur de la position de la bombe pour verifier s'il y a contact avec l'avion
if(avion[0]==bombe[0])&
(avion[1]==bombe[1]||
avion[1]==bombe[1]+2||
avion[1]==bombe[1]+3||
avion[1]==bombe[1]+4||
avion[1]==bombe[1]+5||
avion[1]==bombe[1]+6||
avion[1]==bombe[1]+7||
avion[1]==bombe[1]+1
avion[1]==bombe[1]-2||
avion[1]==bombe[1]-3||
avion[1]==bombe[1]-4||
avion[1]==bombe[1]-5||
avion[1]==bombe[1]-6||
avion[1]==bombe[1]-7){
info(" VOUS ETES MORT");
}*/
while (kbhit()){
touche = getch();
commande(avion,touche);
affichescore(30,40,5,3);
}
}
getch();
}