常用攻击程序- -| 回首页 | 2005年索引 | - -精细绘图及动画

计算机作图- -

                                      

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

你可以用上、下、左、右、Home,Page Up,End,Page Down来辅助计算机作图,也可以稍作修改自//己作图.

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

#include #include #include #include #include

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

void main(){ int mode(int), PutIcon(int image[100][100], int, int), x, y, image[100][100], Init(int image[100][100]), PutPoint(int, int, int); 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+1) continue; else if (k2 < k1 && k2 == k1-1) continue; else break; }while(1);

switch(k1) { case 1: key = 0x4800; break; case 2: key = 0x5000; break; case 3: key = 0x4b00; break; case 4: key = 0x4d00; break; case 5: key = 0x4700; break; case 6: key = 0x4900; break; case 7: key = 0x5100; break; case 8: key = 0x4f00; break; default: break; } t1.ti_sec = t2.ti_sec; } }

delay(100);

switch(key) { case 0x4800: if (y > BASEY) { y--; k2 = k1; } break; case 0x5000: if (y < BASEY+100) { y++; k2 = k1; } break; case 0x4b00: if (x > BASEX) { x--; k2 = k1; } break; case 0x4d00: if (x < BASEX+100) { x++; k2 = k1; } break; case 0x4700: if (x > BASEX && y > BASEY) { x--; y--; k2 = k1; } break; case 0x4900: if (x < BASEX+100 && y > BASEY) { x++; y--; k2 = k1; } break; case 0x5100: if (x < BASEX+100 && y < BASEY+100) { x++; y++; k2 = k1; } break; case 0x4f00: if (x > BASEX && y < BASEY+100) { x--; y++; k2 = k1; } break; default : 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; }

- 作者: 刘加开 2005年03月29日, 星期二 14:52 加入博采

Trackback

你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=1049054

回复

评论内容: