初学者天地---游戏制作
c语言吧
全部回复
仅看楼主
level 1
c闲人 楼主
c语言怎么编游戏http://post.baidu.com/f?kz=4276396 扫雷游戏http://post.baidu.com/f?kz=3651013做游戏常用到的一些函数http://post.baidu.com/f?kz=5416486赛车游戏的完整图 http://post.baidu.com/f?kz=5417016简单打飞碟小游戏http://post.baidu.com/f?kz=3650980坦克大战小游戏http://post.baidu.com/f?kz=3650938吃豆小游戏 http://post.baidu.com/f?kz=3651039
2004年10月22日 14点10分 1
level 1
c闲人 楼主
INT10中断号 http://post.baidu.com/f?kz=5416399
2004年10月22日 14点10分 2
int 10 汇编?
2012年08月21日 12点08分
level 1
c闲人 楼主
运动与静止同时实现在这里我用圆实现运动方块实现静止代码如下:#include
#include
#include
#include
int main(void){ int gdriver = DETECT, gmode; void *ball; int x, y,maxx; unsigned int size; initgraph(&gdriver, &gmode, ""); maxx = getmaxx(); x = 0; y = 200; rectangle(x,y+11,x+20,y
+3
1); circle(x+10,y,10); size = imagesize(x, y-10, x+20, y+10); ball = malloc(size); setfillstyle(SOLID_FILL, BLACK); while (!kbhit()) { cleardevice(); x += 10; if (x >= maxx) x = 0; rectangle(0,211,20,231); circle(x+10,y,10); delay(100); } free(ball); closegraph(); return 0;}
2004年10月22日 14点10分 4
我的显示fatal error C1083,求解。
2013年07月09日 09点07分
level 1
c闲人 楼主
在来说一下赛车游戏我上面给大家可以说是从第一步:制作简单的场景和玩家的赛车到第二步:进一步完善场景,大家可能已经有所领会下面我们就把它做成一个简单的游戏代码如下:#include
#include
#include
#include
#include
static int c=1;static int e=0;static int u=0;static int v=0;static int x=1;static int y=0;static int j=-21;static int i;static int b;void begin(void){int xmax, ymax;int startx,starty,endx,endy;setbkcolor(WHITE);xmax = getmaxx();ymax = getmaxy();endx=20;endy=20;startx=10;starty=10;setcolor(RED);settextstyle(1,HORIZ_DIR,4);outtextxy(10,240,"Bus Bus Bus");outtextxy(300,300,"Made by PU BIN.");setlinestyle(SOLID_LINE,0,3);setwritemode(XOR_PUT);setcolor(GREEN);while(startx
2004年10月22日 14点10分 5
level 1
c闲人 楼主
outtextxy(40,80,"23"); }else if(x==24){ outtextxy(40,80,"23"); outtextxy(40,80,"24"); }else if(x==25){ outtextxy(40,80,"24"); outtextxy(40,80,"25"); y=1; v=1;}}void bus2(void){ setcolor(BLUE); rectangle(180+c*100,350,220+c*100,390);rectangle(170+c*100,340,230+c*100,350); rectangle(190+c*100,320,210+c*100,340); rectangle(170+c*100,390,230+c*100,400); setcolor(5); line(190+c*100,350,190+c*100,390); line(200+c*100,350,200+c*100,390); line(210+c*100,350,210+c*100,390); line(200+c*100,300,200+c*100,320);line(185+c*100,300,215+c*100,300);if((b==0x4b00)&&(c>0)) c--; else if((b==0x4d00)&&(c<2)) c++; else if((b==0x5000)&&(c<2))sleep(1); setcolor(BLUE);rectangle(180+c*100,350,220+c*100,390); rectangle(170+c*100,340,230+c*100,350); rectangle(190+c*100,320,210+c*100,340); rectangle(170+c*100,390,230+c*100,400); setcolor(5); line(190+c*100,350,190+c*100,390); line(200+c*100,350,200+c*100,390); line(210+c*100,350,210+c*100,390); line(200+c*100,300,200+c*100,320);line(185+c*100,300,215+c*100,300);setcolor(BLUE);}void light(void){ rectangle(535,65,565,155); floodfill(545,100,BLUE);setfillstyle(1,RED); fillellipse(550,80,10,10); sound(650); delay(300); nosound(); delay(100); setfillstyle(1,YELLOW); fillellipse(550,110,10,10);sound(650); delay(300); nosound(); delay(100); setfillstyle(1,GREEN); fillellipse(550,140,10,10);sound(650); delay(300); nosound(); delay(100);setcolor(10); setlinestyle(SOLID_LINE,0,3); rectangle(150,400,450,460); outtextxy(160,410,"Ready,Begin!");}void brock(void){if((c==i)&&(j>4)&&(j<38))e=1;}void tree(void){int w;int poly[14];setcolor(10);for (w=-3;w<3;w=w+2){line(85,-25+u*15+w*157,85,35+u*15+w*157);line(95,-25+u*15+w*157,95,35+u*15+w*157);line(105,-25+u*15+w*157,105,35+u*15+w*157);line(115,-25+u*15+w*157,115,35+u*15+w*157);line(75,-9+u*15+w*157,75,19+u*15+w*157);line(125,-9+u*15+w*157,125,19+u*15+w*157);}for (w=-2;w<3;w=w+2){poly[0] = 530;poly[1] = u*15+w*157;poly[2] =515;poly[3] = 25+u*15+w*157;poly[4] =485;poly[5] =25+u*15+w*157 ;poly[6] =470;poly[7] =u*15+w*157 ;poly[8] =485;poly[9] =-25+u*15+w*157;poly[10] =515;poly[11] =-25+u*15+w*157 ;poly[12] = poly[0];poly[13] = poly[1];drawpoly(7,poly);}}void bus1(void){randomize();i=random(3);setlinestyle(SOLID_LINE,0,3);do{do{if((x!=7)&&(x!=16)&&(x!=23))setcolor(x);elsesetcolor(2);rectangle(170+i*100,j*10,230+i*100,60+j*10); rectangle(160+i*100,70+j*10,240+i*100,260+j*10);line(180+i*100,70+j*10,180+i*100,260+j*10); line(200+i*100,70+j*10,200+i*100,260+j*10); line(220+i*100,70+j*10,220+i*100,260+j*10); tree();sound(j*10);delay(10);nosound();if((x!=7)&&(x!=16)&&(x!=23))setcolor(x);elsesetcolor(2);rectangle(170+i*100,j*10,230+i*100,60+j*10);rectangle(160+i*100,70+j*10,240+i*100,260+j*10);line(180+i*100,70+j*10,180+i*100,260+j*10);line(200+i*100,70+j*10,200+i*100,260+j*10);line(220+i*100,70+j*10,220+i*100,260+j*10);tree();u++;j++;brock();if(e==1){j=48;y=1;u=63;v=0;}}while((bioskey(1)==0)&&(j<=47)&&(u<=62));if((j<=47)&&(u<=62))/* function 0 returns the key that is waiting */{b= bioskey(0);bus2();} else if(u<=62){j=-21; randomize(); i=rand()%3; x++; math(); setcolor(x);}elseu=0;}while(y!=1);}void end(){if (v==1){ for(j=0;j<94;j++){ rectangle(150,j*5,450,60+j*5); settextstyle(1,HORIZ_DIR,4); outtextxy(160,10+j*5,"STOP! You win!"); sound(500+j*10); delay(2); nosound(); setlinestyle(SOLID_LINE,0,3); rectangle(150,j*5,450,60+j*5);outtextxy(160,10+j*5,"STOP! You win!"); } closegraph(); printf("\n\nyou win!");} else if(v==0 ){ closegraph();printf("\n\nYou lose."); }printf("\n\n\nCome back again.\n\n Made by YOU LIAO working house. [email protected]");getch();getch();}void car(){ setcolor(BLUE); setlinestyle(SOLID_LINE,0,3);rectangle(280,350,320,390); rectangle(270,340,330,350); rectangle(290,320,310,340); rectangle(270,390,330,400);setcolor(5);line(290,350,290,390);line(300,300,300,320);line(300,350,300,390);line(310,350,310,390);line(285,300,315,300);setcolor(BLUE);}void main(void){int gdriver = DETECT , gmode; initgraph(&gdriver, &gmode, "");begin();setbkcolor(7);setcolor(WHITE);setwritemode(XOR_PUT);road();car();light();bus1();end();}
2004年10月22日 14点10分 6
level 0
太快了,控制不了啊。
2004年10月22日 15点10分 7
level 0
真的不错
2004年10月24日 16点10分 8
level 0
高手!!!!!!
2004年10月25日 11点10分 9
level 1
c闲人 楼主
游戏声音:音效在游戏里是非常重要的这里介绍用pc喇叭产生的最简单的声音,以后在给大家介绍如何驱动声卡使音箱发声c语言函数库提供了两个声音函数 sound(),nosound()和延迟函数delay()sound()函数中频率参数的单位是(Hz),根据测试,调用参数18Hz以上的sound()函数可以被人耳识别,以下是一个利用循环改变声音频率的例子,发出来的生音频率从低到高代码如下:#include
void main(void){ int i; for(i=0;i<=1000;i++) { sound(i); delay(1000); nosound(); }}在游戏中sound()函数通常在某一游戏动画图像画好后处于延迟的时候使用这里使用delay()延迟函数一举两得,即使游戏动画图像进行了一定时间的停留,又使声音进行了一定时间的播放需要提醒大家的是: 不同的机器在使用delay()延迟函数时延迟时间不同,这是因为受cpu速度的影响最终我们将不使用delay()函数作为延迟函数。
2004年10月27日 05点10分 10
level 0
lihai
2004年10月27日 05点10分 11
level 0
ding
2004年10月27日 07点10分 12
level 0
这里的人真的比较好,我相信你们
2004年10月31日 11点10分 13
level 0
真的谢谢 在这里小弟谢谢大哥了
2004年11月03日 07点11分 14
level 1
c闲人 楼主
扫描仪的制作:#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define VGA256 0x13
#define TEXT_MODE 0x03#
define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 200#
define PALETTE_MASK 0x3c6#define PALETTE_REGISTER_RD 0x3c7#define PALETTE_REGISTER_WR 0x3c8#define PALETTE_DATA 0x3c9typedef struct RGB_color_typ{unsigned char red;unsigned char green;unsigned char blue;}RGB_color,*RGB_color_ptr;unsigned char far *video_buffer=(char far *)0xA0000000L;float sin_look[361];float cos_look[361];void Delay(int clicks){unsigned int far *clock=(unsigned int far *)0x0000046CL;unsigned int now;now=*clock;while(abs(*clock-now)
red);outp(PALETTE_DATA,color->green);outp(PALETTE_DATA,color->blue);}void Get_Palette_Register(int index,RGB_color_ptr color){outp(PALETTE_MASK,0xff);outp(PALETTE_REGISTER_RD,index);color->red=inp(PALETTE_DATA);color->green=inp(PALETTE_DATA);color->blue=inp(PALETTE_DATA);}void Set_Video_Mode(int mode){union REGS inregs,outregs;inregs.h.ah=0;inregs.h.al=(unsigned char)mode;int86(0x10,&inregs,&outregs);}void Plot_Pixel_Fast(int x,int y,char color){video_buffer[((y<<8)+(y<<6))+x]=color;}void BPlot_Pixel_Fast(int x,int y,char color){video_buffer[((y<<8)+(y<<6))+x]=color;video_buffer[((y<<8)+(y<<6))+x-1]=color;video_buffer[((y<<8)+(y<<6))+x-320]=color;video_buffer[((y<<8)+(y<<6))+x-321]=color;}void Bline(int x0,int y0,int x1,int y1,unsigned char color){int dx,dy,x_inc,y_inc,error=0,index;unsigned char far *vb_start=video_buffer;vb_start=vb_start+((unsigned int )y0<<6)+((unsigned int)y0<<8)+(unsigned int)x0;dx=x1-x0;dy=y1-y0;if(dx>=0){x_inc=1;}else{x_inc=-1;dx=-dx;}if(dy>=0){y_inc=320;}else{y_inc=-320;dy=-dy;}if(dx>dy){for(index=0;index<=dx;index++){*vb_start=color;error+=dy;if(error>dx){error-=dx;vb_start+=y_inc;}vb_start+=x_inc;}}else{for(index=0;index<=dy;index++){*vb_start=color;error+=dx;if(error>0){error-=dy;vb_start+=x_inc;}vb_start+=y_inc;}}}void H_Line(int x1,int x2,int y,unsigned int color){memset( (char far *) (video_buffer + ( (y<<8) + (y<<6) ) + x1) , color , x2-x1+1 );}void V_Line(int y1,int y2,int x,unsigned int color){int i;for(i=y1;i
2004年11月07日 14点11分 15
level 1
c闲人 楼主
y1=x0*sin_look[index]+y0*cos_look[index];Plot_Pixel_Fast(x+x1,y+y1,color);}}void BCircle(int x,int y,int r,int color){int x0,y0,x1,y1,index;x0=y0=r/sqrt(2);for(index=0;index<=360;index++){x1=x0*cos_look[index]-y0*sin_look[index];y1=x0*sin_look[index]+y0*cos_look[index];Plot_Pixel_Fast(x+x1,y+y1,color);Plot_Pixel_Fast(x+x1-1,y+y1,color);Plot_Pixel_Fast(x+x1,y+y1-1,color);Plot_Pixel_Fast(x+x1+1,y+y1,color);Plot_Pixel_Fast(x+x1,y+y1+1,color);Plot_Pixel_Fast(x+x1-1,y+y1-1,color);Plot_Pixel_Fast(x+x1+1,y+y1-1,color);Plot_Pixel_Fast(x+x1+1,y+y1+1,color);Plot_Pixel_Fast(x+x1-1,y+y1+1,color);}}void Fill_Circle(int x,int y,int r,int color){int index;for(index=r;index>0;index--){BCircle(x,y,index,color);}}void main(void){int index,x0=160,y0=100,x1=50,y1=50,x2,y2,curr_color=1,i,flag=0,son=0;RGB_color color,color_1,color_2;Create_Tables();Set_Video_Mode(VGA256);color.red=0;color.green=0;color.blue=5;Set_Palette_Register(0,(RGB_color_ptr)&color);for(index=1;index<=255;index++){color.red=0;color.green=10;color.blue=0;Set_Palette_Register(index,(RGB_color_ptr)&color);}color.red=0;color.green=30;color.blue=0;Set_Palette_Register(182,(RGB_color_ptr)&color);color.red=0;color.green=10;color.blue=0;Set_Palette_Register(183,(RGB_color_ptr)&color);for(index=184;index<=188;index++){color.red=0;color.green=30+(index-184)*10;color.blue=0;Set_Palette_Register(index,(RGB_color_ptr)&color);}Fill_Circle(160,100,73,183);for(index=0;index<=360;index++){x2=x1*cos_look[index]-y1*sin_look[index];y2=x1*sin_look[index]+y1*cos_look[index];Bline(x0,y0,x0+x2,y0+y2,index/2+1);}V_Line(22,178,160,182);H_Line(82,238,100,182);for(index=0;index<4;index++)BCircle(160,100,73+index,184+index);for(index=0;index<4;index++)BCircle(160,100,76+index,187-index);for(index=1;index<=158;index=index+5){Plot_Pixel_Fast(81+index,99,182);Plot_Pixel_Fast(161,21+index,182);}for(index=0;index<10;index++){BPlot_Pixel_Fast(143+index*8,140-index*2,190+index);Plot_Pixel_Fast(116-index*2,72+index*5,190+index);Plot_Pixel_Fast(122+index*2,145-index*3,190+index);BPlot_Pixel_Fast(190-index*8,150-index*2,190+index);Plot_Pixel_Fast(136+index*2,152-index*5,190+index);Plot_Pixel_Fast(172-index*2,145-index*3,190+index);}color_1.red=0;color_1.green=10;color_1.blue=0;color_2.red=255;color_2.green=0;color_2.blue=0;color.red=0;color.blue=0;while(!kbhit())for(index=1;index<=181;index++){for(i=0;i<15;i++){color.green=20+i*2;if(index+i>181)Set_Palette_Register(index+i-181,(RGB_color_ptr)&color);elseSet_Palette_Register(index+i,(RGB_color_ptr)&color);}color.green=255;if(index+i>181)Set_Palette_Register(index+i-181,(RGB_color_ptr)&color);elseSet_Palette_Register(index+i,(RGB_color_ptr)&color);Set_Palette_Register(index,(RGB_color_ptr)&color_1);if(index==181){flag=0;if(flag==0){flag=1;son=(son)%10+1;Set_Palette_Register(189+son-1,(RGB_color_ptr)&color_1);Set_Palette_Register(189+son,(RGB_color_ptr)&color_2);}}else if(flag==1){if(son!=10)flag=2;elseflag=0;Set_Palette_Register(189+son,(RGB_color_ptr)&color_1);}else if(flag==2){flag=1;Set_Palette_Register(189+son,(RGB_color_ptr)&color_2);}delay(10);}getch();Set_Video_Mode(TEXT_MODE);}
2004年11月07日 14点11分 16
师傅,请收下这个徒弟。
2014年03月20日 06点03分
level 1
c闲人 楼主
大家也可以叫这个是雷达
2004年11月07日 14点11分 17
level 1
c闲人 楼主
窗口和按钮的制作:#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include

#define WINDOWS 0#
define BUTTON 1
#define BUTTON_PRESS 2#
define BUTTON_SMALL 3
#define BUTTON_SMALL_PRESS 4#
define BUTTON_CLOSE 5
#define BUTTON_CLOSE_PRESS 6#
define BUTTON_MENU 7
#define BUTTON_COLOR 24#
define BUTTON_COLOR_LIGHT 7
#define BUTTON_COLOR_DARK 8#
define BUTTON_X 35
#define BUTTON_Y 10#
define BUTTON_XY 8
#define WINDOWS_X 50#
define WINDOWS_Y 50
#define WINDOWS_X_MOVE 240#
define WINDOWS_Y_MOVE 150
#define WINDOWS_COLOR_OUT 24#
define WINDOWS_COLOR_IN 15#define WINDOWS_COLOR_LIGHT 7#define WINDOWS_COLOR_DARK 8#define WINDOWS_COLOR_TITLE 12#define MAX 0#define MIN 1#define ACTIVE 1#define NOACTIVE 0#define ACTIVE_COLOR 1#define NOACTIVE_COLOR 8#define VGA256 0x13#define TEXT_MODE 0x03#define SCREEN_WIDTH 320#define SCREEN_HEIGHT 200#define PALETTE_MASK 0x3c6#define PALETTE_REGISTER_RD 0x3c7#define PALETTE_REGISTER_WR 0x3c8#define PALETTE_DATA 0x3c9#define CHAR_HEIGHT 8#define CHAR_WIDTH 8#define MOUSE_INT 0x33#define MOUSE_RESET 0x00#define MOUSE_SHOW 0x01#define MOUSE_HIDE 0x02#define MOUSE_BUTT_POS 0x03#define MOUSE_SET_SENSITIVITY 0x1A#define MOUSE_MOTION_REL 0x0B#define MOUSE_LEFT_BUTTON 0x01#define MOUSE_RIGHT_BUTTON 0x02#define MOUSE_CENTER_BUTTON 0x04typedef struct{ int mak[2][16]; int hor; int ver; }mscurstype;mscurstype handcurs={-7681,-7681,-7681,-7681,-7681,-8192,-8192,-8192, 0, 0, 0, 0, 0, 0, 0, 0, 7680,4608,4608,4608,4608,5119,4681,4681,4681, -28671,-28671,-28671,-22767,-32767,-32767,-1,4,0};mscurstype arrow={0x3fff,0x1fff,0x0fff,0x07ff, 0x03ff,0x01ff,0x00ff,0x007f, 0x003f,0x00ff,0x01ff,0x10ff, 0x30ff,0xf87f,0xf87f,0xfc3f, 0x0000,0x4000,0x6000,0x7000, 0x7800,0x7c00,0x7e00,0x7f00, 0x7f80,0x7e00,0x7c00,0x4600, 0x0600,0x0300,0x0300,0x0180,0,0};mscurstype lin={0xe3e3,0xe3e3,0xe3e3,0xe3e3,0x8080, 0x8080,0x8080,0xe3e3,0xc1c1, 0x8080,0x0000,0x2323,0xe3e3,0xe3e3,0xe3e3, 0xe3e3, 0x0000,0x0808,0x0808,0x0808, 0x0808,0x3e3e,0x0808,0x0808, 0x1c1c,0x2a2a,0x4848,0x0808, 0x0808,0x0808,0x0808,0x0000,2,0};mscurstype qi={0xff89,0xff88,0xff8e,0x8001,0x8001,0x8001,0x8d8f,0x8c8c,0x8d8c,0x8d88,0x8009,0x8983,0x9542,0x1540,0x39b0,0x7d79,0x0000,0x0020,0x0020,0x0020,0x3ffc,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x2020,0x0000,0x4008,0x0004,0x0000,16,0};mscurstype arrowcurs={16383,8191,4095,2047,1023,511,225,127,63, 31,511,4351,12543,-1921,-1921,-961,0,16348, 24576,28672,30720,31744,32256,32512,32640, 32704,31744,17920,17920,768,384,192,-1,-1};int Squeeze_Mouse(int command,int *x,int *y,int *buttons){union REGS inregs,outregs;switch(command){case MOUSE_RESET:{inregs.x.ax=0x00;int86(MOUSE_INT,&inregs,&outregs);*buttons=outregs.x.bx;return(outregs.x.ax);
2004年11月07日 14点11分 18
level 1
c闲人 楼主
}break;case MOUSE_SHOW:{inregs.x.ax=0x01;int86(MOUSE_INT,&inregs,&outregs);return(1);}break;case MOUSE_HIDE:{inregs.x.ax=0x02;int86(MOUSE_INT,&inregs,&outregs);return(1);}break;case MOUSE_BUTT_POS:{inregs.x.ax=0x03;int86(MOUSE_INT,&inregs,&outregs);*x=outregs.x.cx;*y=outregs.x.dx;*buttons=outregs.x.bx;return(1);}break;case MOUSE_MOTION_REL:{inregs.x.ax=0x03;int86(MOUSE_INT,&inregs,&outregs);*x=outregs.x.cx;*y=outregs.x.dx;return(1);}break;case MOUSE_SET_SENSITIVITY:{inregs.x.ax=0x04;inregs.x.bx=*buttons;inregs.x.cx=*x;inregs.x.dx=*y;int86(MOUSE_INT,&inregs,&outregs);return(1);}break;default:break;}}void setcurshape(mscurstype mask){ union REGS r; struct SREGS s; r.x.ax=9; r.x.bx=mask.hor; r.x.cx=mask.ver; r.x.dx=FP_OFF(&mask); s.es=FP_SEG(&mask); int86x(0x33,&r,&r,&s);}void mscurson(mscurstype shape){int msvisible; union REGS r; struct SREGS s; setcurshape(shape); r.x.ax=1; msvisible=1; int86x(0x33,&r,&r,&s); }typedef struct point{int x;int y;}point;typedef struct windows{int kind;point top;point move;char *word;int color;int bk_color;int status;//char *ico;//void (far *build)();char *hotkey;void (far *windows)(struct windows *win);char far *background;int bk_flag;struct windows *next;struct windows *father;int active;} windows, *windows_ptr;windows_ptr head;windows_ptr now;windows_ptr pre;windows_ptr win_now;windows_ptr last;typedef struct RGB_color_typ{unsigned char red;unsigned char green;unsigned char blue;}RGB_color,*RGB_color_ptr;unsigned char far *video_buffer=(char far *)0xA0000000L;unsigned char far *rom_char_set=(char far *)0xF000FA6EL;float sin_look[361];float cos_look[361];void men(windows_ptr win);void Delay(int clicks){unsigned int far *clock=(unsigned int far *)0x0000046CL;unsigned int now;now=*clock;while(abs(*clock-now)
red);outp(PALETTE_DATA,color->green);outp(PALETTE_DATA,color->blue);}void Get_Palette_Register(int index,RGB_color_ptr color){outp(PALETTE_MASK,0xff);outp(PALETTE_REGISTER_RD,index);color->red=inp(PALETTE_DATA);color->green=inp(PALETTE_DATA);color->blue=inp(PALETTE_DATA);}void Set_Video_Mode(int mode){union REGS inregs,outregs;inregs.h.ah=0;inregs.h.al=(unsigned char)mode;int86(0x10,&inregs,&outregs);}void Plot_Pixel_Fast(int x,int y,char color){video_buffer[((y<<8)+(y<<6))+x]=color;}void BPlot_Pixel_Fast(int x,int y,char color){video_buffer[((y<<8)+(y<<6))+x]=color;video_buffer[((y<<8)+(y<<6))+x-1]=color;
2004年11月07日 14点11分 19
level 1
c闲人 楼主
video_buffer[((y<<8)+(y<<6))+x-320]=color;video_buffer[((y<<8)+(y<<6))+x-321]=color;}void Bline(int x0,int y0,int x1,int y1,unsigned char color){int dx,dy,x_inc,y_inc,error=0,index;unsigned char far *vb_start=video_buffer;vb_start=vb_start+((unsigned int )y0<<6)+((unsigned int)y0<<8)+(unsigned int)x0;dx=x1-x0;dy=y1-y0;if(dx>=0){x_inc=1;}else{x_inc=-1;dx=-dx;}if(dy>=0){y_inc=320;}else{y_inc=-320;dy=-dy;}if(dx>dy){for(index=0;index<=dx;index++){*vb_start=color;error+=dy;if(error>dx){error-=dx;vb_start+=y_inc;}vb_start+=x_inc;}}else{for(index=0;index<=dy;index++){*vb_start=color;error+=dx;if(error>0){error-=dy;vb_start+=x_inc;}vb_start+=y_inc;}}}void H_Line(int x1,int x2,int y,unsigned int color){memset( (char far *) (video_buffer + ( (y<<8) + (y<<6) ) + x1) , color , x2-x1+1 );}void V_Line(int y1,int y2,int x,unsigned int color){int i;for(i=y1;i
>1);}offset+=SCREEN_WIDTH;work_char++;}}void Blit_String(int x,int y,int color,char *string,int trans_flag)
2004年11月07日 14点11分 20
level 1
c闲人 楼主
{int index;for(index=0;string[index]!=0;index++){Blit_Char(x+(index<<3),y,string[index],color,trans_flag);}}void Draw_Windows(windows_ptr win){switch(win->kind){case WINDOWS:{Fill_Rectangle(win->top.x,win->top.y,win->top.x+win->move.x,win->top.y+win->move.y,WINDOWS_COLOR_DARK);Fill_Rectangle(win->top.x,win->top.y,win->top.x+win->move.x-1,win->top.y+win->move.y-1,WINDOWS_COLOR_LIGHT);Fill_Rectangle(win->top.x+1,win->top.y+1,win->top.x+win->move.x-1,win->top.y+win->move.y-1,WINDOWS_COLOR_OUT);Fill_Rectangle(win->top.x+1,win->top.y+1,win->top.x+win->move.x-1,win->top.y+10,WINDOWS_COLOR_TITLE);if(win->active==ACTIVE)Blit_String(win->top.x+2,win->top.y+2,win->color,win->word,1);elseBlit_String(win->top.x+2,win->top.y+2,NOACTIVE_COLOR,win->word,1);Fill_Rectangle(win->top.x+2,win->top.y+22,win->top.x+win->move.x-2,win->top.y+win->move.y-2,WINDOWS_COLOR_LIGHT);Fill_Rectangle(win->top.x+2,win->top.y+22,win->top.x+win->move.x-3,win->top.y+win->move.y-3,WINDOWS_COLOR_DARK);Fill_Rectangle(win->top.x+3,win->top.y+23,win->top.x+win->move.x-3,win->top.y+win->move.y-3,WINDOWS_COLOR_IN);break;}case BUTTON_MENU:{if(win->active==ACTIVE)Blit_String(win->top.x+2,win->top.y+1,win->color,win->word,1);elseBlit_String(win->top.x+2,win->top.y+1,NOACTIVE_COLOR,win->word,1);break;}case BUTTON:{Fill_Rectangle(win->top.x,win->top.y,win->top.x+win->move.x,win->top.y+win->move.y,BUTTON_COLOR_DARK);Fill_Rectangle(win->top.x,win->top.y,win->top.x+win->move.x-1,win->top.y+win->move.y-1,BUTTON_COLOR_LIGHT);Fill_Rectangle(win->top.x+1,win->top.y+1,win->top.x+win->move.x-1,win->top.y+win->move.y-1,BUTTON_COLOR);if(win->active==ACTIVE)Blit_String(win->top.x+2,win->top.y+1,win->color,win->word,1);elseBlit_String(win->top.x+2,win->top.y+1,NOACTIVE_COLOR,win->word,1);break;}case BUTTON_PRESS:{Fill_Rectangle(win->top.x,win->top.y,win->top.x+win->move.x,win->top.y+win->move.y,BUTTON_COLOR_LIGHT);Fill_Rectangle(win->top.x,win->top.y,win->top.x+win->move.x-1,win->top.y+win->move.y-1,BUTTON_COLOR_DARK);Fill_Rectangle(win->top.x+1,win->top.y+1,win->top.x+win->move.x-1,win->top.y+win->move.y-1,BUTTON_COLOR);Blit_String(win->top.x+2,win->top.y+1,win->color,win->word,1);break;}case BUTTON_CLOSE:{Fill_Rectangle(win->top.x,win->top.y,win->top.x+win->move.x,win->top.y+win->move.y,BUTTON_COLOR_DARK);Fill_Rectangle(win->top.x,win->top.y,win->top.x+win->move.x-1,win->top.y+win->move.y-1,BUTTON_COLOR_LIGHT);Fill_Rectangle(win->top.x+1,win->top.y+1,win->top.x+win->move.x-1,win->top.y+win->move.y-1,BUTTON_COLOR);if(win->active==ACTIVE){Bline(win->top.x+2,win->top.y+2,win->top.x+win->move.x-2,win->top.y+win->move.y-2,win->color);Bline(win->top.x+win->move.x-2,win->top.y+2,win->top.x+2,win->top.y+win->move.y-2,win->color);}else{Bline(win->top.x+2,win->top.y+2,win->top.x+win->move.x-2,win->top.y+win->move.y-2,NOACTIVE_COLOR);
2004年11月07日 14点11分 21
1 2 3 4 5 6 尾页