Le code suivant ne fonctionne pas comme desiré, le probleme vien que lorsque j'apuis sur 'a' un dessin devrai s'aficher(au fur et a mesure )
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <time.h>
#include <conio.h>
#include <mmsystem.h>
 
//-----------------------------------------------------------------------------  
void Ecran(int Mode) // parametre Mode : 1=plein ecran et 2=mode fenetre
{
     typedef BOOL WINAPI (*SetConsoleDisplayModeT)(HANDLE,DWORD,DWORD*);
     SetConsoleDisplayModeT SetConsoleDisplayMode;
 
    HINSTANCE hLib=LoadLibrary("KERNEL32.DLL");
    SetConsoleDisplayMode=(SetConsoleDisplayModeT)
       GetProcAddress(hLib,"SetConsoleDisplayMode");
 
    HANDLE h=CreateFile("CONOUT$",GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ |
       FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,0);
 
    DWORD oldmode;
 
    SetConsoleDisplayMode(h,Mode,&oldmode);
}
//-----------------------------------------------------------------------------
void aff(int x,int y)
{
  int c,touche=0;
 
  HANDLE handle=GetStdHandle(STD_OUTPUT_HANDLE);
  COORD pos={x,y};
  SetConsoleCursorPosition(handle,pos); 
 
  if (kbhit()!=0) 
     while ((touche==0||touche==224)&&(touche!=27||touche!=97))
           touche=getch();
  /*if (kbhit())
     touche==getch();*/
 
  if(touche==27) exit(0);
 
  if (touche==97)
  {
     //SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 1);//0x0a
     if (y==10&&x>10&&x<70)
           printf("%c",196);
   else if (y==10&&x==10)
           printf("%c",218);
   else if (y==10&&x==70)
           printf("%c",191);
     else if (y==40&&x>10&&x<70)
           printf("%c",196);
     else if (y==40&&x==10)
           printf("%c",192);
     else if (y==40&&x==70)
           printf("%c",217);
     else if (x==10&&y>10&&y<40)
           printf("%c",179);
     else if (x==70&&y>10&&y<40)
           printf("%c",179);
     }
  else if (x!=79||y!=50)
  {
      //SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
      c=(rand()%200)+10;
      printf("%c",c);
  }
}
 
 
//-----------------------------------------------------------------------------
 
int main()
{
  printf(" Par Pierre BLACHE...");
  Sleep(5000);
  system("cls"); 
  int x,x1,x2,x3,x4,x5,x6,x7,x8,x9,y,y1,y2,y3,y4,y5,y6,y7,y8,y9;
  Ecran(1);
  srand((unsigned)time(NULL));
 
  SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
 
  for (x=0;x<80;x++) for (y=1;y<=50;y++) aff(x,y);
 
  y1=rand()%50;
  y2=rand()%50;
  y3=rand()%50;  
  y4=rand()%50;
  y5=rand()%50;
  y6=rand()%50;
  y7=rand()%50;
  y8=rand()%50;
  y9=rand()%50;
 
  while(1)
  {
 
  y1++;
  y2++;
  y3++;
  y4++;
  y5++;
  y6++;
  y7++;
  y8++;
  y9++;
 
  if (y1>50){ x1=rand()%80; y1=1;}
  aff(x1,y1);
 
  if (y2>50){ x2=rand()%80; y2=1;}
  aff(x2,y2);
 
  if (y3>50){ x3=rand()%80; y3=1;}
  aff(x3,y3);
 
  if (y4>50){ x4=rand()%80; y4=1;}
  aff(x4,y4);
 
  if (y5>50){ x5=rand()%80; y5=1;}
  aff(x5,y5);
 
  if (y6>50){ x6=rand()%80; y6=1;}
  aff(x6,y6);
 
  if (y7>50){ x7=rand()%80; y7=1;}
  aff(x7,y7);
 
  if (y8>50){ x8=rand()%80; y8=1;}
  aff(x8,y8);
 
  if (y9>50){ x9=rand()%80; y9=1;}
  aff(x9,y9);
 
//  sndPlaySound("Son.wav", SND_SYNC );
 
  Sleep(20);
  }
 
  return 0;
}