Aween

向.NET进发

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

//你可以用上、下、左、右、Home,Page Up,End,Page Down来辅助计算机作图,也可以稍作修改自//己作图,如有Bug,请通知我,谢谢。

//程序将在左上角显示正常大小的图符,并在右边显示一个放大一倍的非精细图符。

#include #include #include #include #include 

#define EXPAND 1#define BASEX 50#define BASEY 50

void main()int mode(int), PutIcon(int image[100][100], intint), x, y, image[100][100], Init(int image[100][100]), PutPoint(intintint); int Edit(int image[100][100]), Save(int image[100][100]);

mode(
16); Init(image);

for (y = 1; y < 480; y++for (x = 1; x < 640; x++) PutPoint (x, y, 7);

Edit(image); Save(image); getch(); mode(
3); }


int mode(int value){ union REGS r; r.h.ah = 0; r.h.al = value;

int86(
0x10&r, &r); return 1; }


int PutPoint(int x, int y, int color){ union REGS r;

r.h.ah 
= 12; r.h.bh = 0; r.h.al = color; r.x.cx = x; r.x.dx = y;

int86(
0x10&r, &r); return 1; }


int PutIcon(int image[100][100], int x, int y){

for (y = BASEY; y < 100+BASEY; y++for (x = BASEX; x < 100+BASEX; x++) PutPoint (x, y, image[y-BASEY][x-BASEX]);

for (y = BASEY+50; y < 100+BASEY+50; y++for (x = BASEX+300; x < 100+BASEX+300; x++) PutPoint (x+(x-BASEX-300)*EXPAND, y+(y-BASEY-50)*EXPAND, image[y-BASEY-50][x-BASEX-300]);

return 0; }


int Init(int image[100][100])int i, j; FILE *fp;

if ((fp = fopen("data.pic""rb")) != NULL) { fread(image, sizeof(image), 1, fp); fclose(fp); } else for (i = 0; i < 100; i++for (j = 0; j < 100; j++) image[i][j] = BLUE; } return 1; }


int Cls(){ union REGS r;

r.h.ah 
= 6; r.h.al = 0; r.h.bh = 7; r.h.ch = 0; r.h.cl = 0; r.h.dh = 24; r.h.dl = 79;

int86(
0x10&r, &r); return 0; }


int Edit(int image[100][100])int pen = GREEN; int x, y, key = 0x4800, GetKey(), k2, k1; struct time t1, t2; x = BASEX; y = BASEY;

PutIcon(image, BASEX, BASEY); randomize(); gettime(
&t1);

do{

if (bioskey(1)) //manual control key = GetKey(); else { gettime(&t2); //computer control if (t2.ti_sec != t1.ti_sec) //time distance { do{ k1 = rand()%9;

if (k2 > k1 && k2 == k1+1continueelse if (k2 < k1 && k2 == k1-1continueelse break; }
while(1);

switch(k1) case 1: key = 0x4800breakcase 2: key = 0x5000breakcase 3: key = 0x4b00breakcase 4: key = 0x4d00breakcase 5: key = 0x4700breakcase 6: key = 0x4900breakcase 7: key = 0x5100breakcase 8: key = 0x4f00breakdefaultbreak; } t1.ti_sec = t2.ti_sec; }
 }

delay(
100);

switch(key) case 0x4800if (y > BASEY) { y--; k2 = k1; } breakcase 0x5000if (y < BASEY+100{ y++; k2 = k1; } breakcase 0x4b00if (x > BASEX) { x--; k2 = k1; } breakcase 0x4d00if (x < BASEX+100{ x++; k2 = k1; } breakcase 0x4700if (x > BASEX && y > BASEY) { x--; y--; k2 = k1; } breakcase 0x4900if (x < BASEX+100 && y > BASEY) { x++; y--; k2 = k1; } breakcase 0x5100if (x < BASEX+100 && y < BASEY+100{ x++; y++; k2 = k1; } breakcase 0x4f00if (x > BASEX && y < BASEY+100{ x--; y++; k2 = k1; } breakdefault : break; }

image[x
-BASEX][y-BASEY] = pen; PutPoint(x, y, image[x-BASEX][y-BASEY]); PutPoint(x+600+(x-BASEX-300)*EXPAND, y+100+(y-BASEY-50)*EXPAND, image[x-BASEX][y-BASEY]); }while(key != 0x011b);

return 1; }

int GetKey()int key;

key 
= bioskey(0);

return key; }


int Save(int image[100][100]){ FILE *fp;

if ((fp = fopen("data.pic""wb")) == NULL) { printf ("\nError Open File!"); return 0; }

fwrite(image, 
sizeof(image), 1, fp); fclose(fp);

return 1; }





posted on 2006-03-02 21:48  Aween's Blog  阅读(399)  评论(0编辑  收藏  举报