Cómo implementar el control del mouse usando el programa C
No agregué demasiados comentarios, explore el algoritmo de conversión usted mismo, preste atención a los cambios en I y J
#include lt
; p>#include lt;graphics.hgt;
#include lt;bios.hgt;
#include lt;bios.hgt;
#include lt;bios .hgt;
#include lt; bios.hgt; <
#include dos.hgt; ; /*función inicial **/
void Cursor(); /*función de movimiento del cursor**/
void Save() /*función de registro**/
int New();/*nueva función de archivo**
int KeyUp();/* función de teclado**
estructura typedef
{
int shape[32];
char hotx; /* X coordenadas del punto caliente**
char hoty;/* Y coordenadas del punto caliente** /
}SHAPE;/* Estructura del cursor del mouse**/
typedef struct
{
char *m_Two[16];
}TtoS;
char FileName[12]="Noname.csr";
int main()
{ p>
char hotx , hoty;
int x=240, y=150, ox, oy, i=0, j=0, hx=0, hy=0, key, marcado= 0;
char Ctemp[64][5];
Init(Ctemp
hacer
{
;buey=x; oy=y;
clave=KeyUp();
cambiar(tecla)
{
caso 77: {
if(xlt;390)
.p> {
j ; x =10
hx ;
if(jgt;3amp;amp;xlt;390)
{
i ;
} p>
}
descanso
}
caso 75: {
if(xgt; 240)
{
p>
j--; x-=10;
hx--;
if(jlt;0amp; amp;xgt;240)
{
i--;
}
}
descanso;
}
caso 72: {
if(ygt;150)
{
i-=4; y-=10;
hy--;
}
descanso
}
<p> }
caso 80: {
if(ylt; 300)
{
i =4;
hy;
}
descanso
}
caso 81: {
if(xlt;390amp;amp;ylt;300)
{
i =4; j;
x =10;
hx ; hy ;
}
si(jgt; 3)
{
i ; =0;
}
descanso
}
caso 71: {
if(xgt; 240amp;amp;ygt;150)
{
i-=4; j--;
x-=10;
hx--;hy--;
}
if(jlt;0)
{
i--; j=3;
}
descanso
}
caso 79: {
if(xgt; 240amp; amp; ylt; 300)
{
i =4; j--;
x-=10; =10;
hx--;hy;
}
if(jlt;0)
{
i--; j=3;
}
descanso
}
caso 73: {
if(xlt;390amp;amp;ygt;150)
{
i-=4; j;
x =10; =10;
hx .hy--;
}
if(jgt;3)
{
i; j=0;
}
romper;
}
caso 24: marcar=1; /p>
caso 44: Guardar(Ctemp, hotx, hoty);
caso 49: marcado=Nuevo(Ctemp);
caso 35: hotx; =hx; hoty=hy.break;
};
Cursor(x, y, oy, marcando); );
printf("d d d d d d", clave, j, i, x, y
if (marcado) Ctemp [i][j]='1'); /p>
else Ctemp[i][j]='0';
} while(key! =1);
closegraph();
}
void Init(char Ct[64][5])
{
int px=240, py=150, pi, pj
int graphdri;
ve=0, graphmode=0;
initgraph(amp;graphdrive,amp;graphmode,"");
rectángulo(40, 50, 140, 150);
rectángulo(42, 52, 138, 148);
outtextxy(55, 65, "Nuevo archivo");
outtextxy(55, 85, "Guardar archivo" ");
outtextxy(55, 105, "Punto Caliente");
outtextxy(55, 125, "Esc Salir");
setcolor( 14);
salidatextxy(55, 65, "N");
salidatextxy(55, 85, "S"); 105, "H");
outtextxy(55, 125, "E");
setcolor(15);
setfillstyle(1, 1) ;
for(pi=0.pilt; 16; pi )
{
for(pj=0; pjlt; 16; pj )
{
barra(px-3, py-3, px 3, py 3
px =10;
}); p>
py =10;
px=240;
}
para(pi=0; pilt; 64; pi )
for(pj=0; pjlt; 5; pj)
{
if(pjgt;=4) Ct[pi][pj]=NULL; p> p>
else Ct[pi][pj]='0';
}
px=240; setcolor( 15);
rectángulo(px-5, py-5, px 5, py 5);
}
int KeyUp( ) p>
{
return bioskey(0)gt;gt;8;
}
void Cursor(int cx, int cy, int ocx , int ocy, int cmarking)
{
int color;
if(cmarking) color=15
else color= 1;
setfillstyle(1, color);
bar(cx-3, cy-3, cx 3, cy 3);
rectángulo(ocx-5,ocy-5,ocx 5,ocy 5);
setcolor(15);
rectángulo(cx-5); ,cy -5, cx 5, cy 5);
}
void Save(char Sct[ 64][5], int hx, int hy)
{
ARCHIVO *fp;
FORMA Spe;
ttos={"0000", "0001", "0010", "0011",
"0100", "0101", "0110", "0111",
" 1000", "1001", "1010", "1011",
"1100", "1101", "1110", "1111"}};
int si, sj;
int Temp[64], seis[16];
for(si=0; limo; 64; si )
for(sj= 0; sjlt; 16; sj )
{
if(!strcmp(ttos.m_Two[sj],Sct[si]))
Temp[ si]=sj
}
sj=0
for(si=0; limo; 64; si =4)
seis[sj]=Temp[si]lt;lt;12|Temp[si 1]lt;lt;8|Temp[si 2]lt;lt;4|Temp[si 3]
for(si=0; limo; 16; si)
{
Spe.shape[si]=~six[si];
Spe .shape[si 16]=seis[si];
}
Spe.hotx=hx
Spe.hoty=hy
;Spe.hoty=hx;
gotoxy(25, 5);
scanf("s", Nombre de archivo
setfillstyle(0, 1);
bar(150, 35, 350, 100);
setfillstyle(1, 1);
para (ni=0; nilt; 16; ni )
{
for(nj=0; njlt; 16; nj )
{
bar(nx- 3, ny-3, nx 3, ny 3);
nx =10;
}
ny =10; nx=240;
}
para(ni=0; nilt; 64; ni )
para(nj=0; njlt; 5; nj )
{
if(njgt;=4) Nct[ni][nj]=NULL;
else Nct[ni][nj ]='0';
}
devuelve 0;
}