beijing

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<stdlib.h>
 4 #include<graphics.h>
 5 #include<conio.h>
 6 #include<math.h>
 7 #include<dos.h>
 8 int init;
 9 int read_mouse;
10 void cursor;
11 void newxy;
12 int main()
13 {
14     int buttons,x,y;
15     char str[300];
16     int driver=VCA;
17     int moede=VGAHT;
18     initgraph(&gdriver,&mode,"");
19     cleardevice();
20     rectangle(0,0,639,479);
21     setfillstyle(1,5);
22     circle(320,240,100);
23     x=320,y=240;
24     cursor(x,y);
25     for(;;)
26     {
27 
28         newxy(&x,&y,&butttons);
29         if(x>=280&&x<=300&&y>=12&&y<=33&&buttons)
30         {
31             cleardevice();
32             closegraph();
33             exit(0);
34         }
35     }
36 }
37 void(int x,int y)
38 {
39 
40     int x1,x2,y1,y2;
41     x1=x-4;
42     x2=x+4;
43     y1=y-3;
44     y2=y+3;
45     line(x1,y,x2,y);
46     line(x,y1,x,y2);
47 }
48 int read_mouse(int*mx,int*my,int*mbutton)
49 {
50     union REGS regs;
51     int x0=*mx,y0=*my,button0=*mbutton;
52     int xnew,ynew;
53     do
54     {
55         regs.x.ax=3;
56         int86(0x33,&regs,&regs);
57         xnew=regs.x.cx;
58         ynew=regs.x.dx;
59         *mbutton=regs.x.bx;
60     }
61     while(xnew==x0&&ynew==y0&&*mbutton==button0);
62     *mx=xnew;
63     *my=ynew;
64     switch(*mbutton)
65     {
66 
67     case 0:
68         return 0;
69     case 1:
70         return 1;
71     case 2:
72         return 2;
73     case 3:
74         return3;
75     default :
76         return4;
77     }
78 }
79 void newxy(int *mx,int *my,int *mbutt)
80 {
81 
82   int ch,xx0=*mx,yy0=*my;
83   int xm,ym;
84   ch=read_mouse(&xm,&ym,mbutt);
85   curse(xx0,yy0);
86   curse(xm,xy);
87   switch(ch)
88   {
89 
90       case 0: break;
91       case 1: cirse(xm,ym,6);break;
92       case 2: rectangle(xm-6,ym-6,xm+6,ym+6);break;
93       default : putpixel(xm,ym,7);break;
94   }
95     *mx=xm;
96     *my=ym;
97 }

 

posted @ 2018-05-01 22:41  左手边五十米  阅读(213)  评论(0编辑  收藏  举报