空间抽象思维问题.......请看如下代码... ( 积分: 0 )

  • 主题发起人 主题发起人 linuxcici
  • 开始时间 开始时间
L

linuxcici

Unregistered / Unconfirmed
GUEST, unregistred user!
#include<graphics.h>
#include<io.h>
#include<stdio.h>
#include<dos.h>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<bios.h>
#include<mem.h>
#include<fcntl.h>
#include<stdlib.h>
#include<conio.h>
#include<process.h>


int finall_count=0;
int ilinex1=265; int change_iline_floor=0; int screen_count=0;



float up_newline_screen=0; /*线行内步增量参数 */
float up_newline_1=0;




int iline2x1=267; int iline2y1=198; int change_iline_floor1=0;

int iline2x2=363,iline2y2=198; int up_line=0;



float iline_d1=269; /*地面线*/
float iline_d11=365;


float iline_d2=271; /*地面线(白)*/
float iline_d22=363;


float interface_door_count=0; /* 门入口线渐变变量 */
float interface_door_count_fast=0;
float interface_door_special=0;



float iline_leftt=114; /*左边线*/
float iline_leftt2=200;
float iline_leftt3=114;
float iline_leftt4=198;



float iline_left2=113; /*右边线*/
float iline_left22=200;
float iline_left3=114;
float iline_left4=200;


int iline_main=180; /*线性之差内部变量*/

/********************************************* 开始线性渐变变量 ********************************************************/

float wall_change_line_control=640; /*右上角线 */
float wall_change_line_controlx=0;


float wall_change_line_control1=0; /*左上角线 */
float wall_change_line_control1x=0;

float wall_change_line_controlY=0; /* 右边竖线 */
float wall_change_line_controlL_Y=0; /* 左边竖线 */


float fdoor_count=0; /* 门口既增量 */


/***********************************************************************************************************************/

void DELAY(int clicks)
{
unsigned int far *clock=(unsigned int far *)0x0000046CL;
unsigned int now;
now=*clock;
while(abs(*clock-now)<clicks){}
}







void wall_change_line(void) /*右边墙上角线渐变 */
{

if (wall_change_line_control>=450)
{
setcolor(7);
setlinestyle(0,1,3);

line
(
326+wall_change_line_controlx,
131-wall_change_line_controlx,
wall_change_line_control,
0
);

if(up_line % 4==0)
wall_change_line_controlx+=0.5;

wall_change_line_control-=2;


}

}




void wall_change_line_left(void) /*左上角线 */
{


if (wall_change_line_control1<=180)
{
setcolor(7);
setlinestyle(0,1,3);

line
(
304-wall_change_line_control1x,
131-wall_change_line_control1x,
wall_change_line_control1,
0
);

if(up_line % 4==0)
wall_change_line_control1x+=0.5;

wall_change_line_control1+=2;

}
}



/***************************************************************************************************************************/





void if_change_1(void) /* 第一组线复位 及 重合*/
{




if (up_newline_1==180)
{

while (iline_main<=183)
{


/**********************底边线变**********************/

setcolor(15);
setlinestyle(0,1,1);
if(finall_count %1==0)iline_d2-=0.97;
if(finall_count %1==0)iline_d22+=0.97;
line
(

iline_d2, /*271*/

198+iline_main,

iline_d22, /*363*/

198+iline_main

);


/********************左边线变***********************/
setcolor(7);
setlinestyle(0,1,1);

if(finall_count %4==0)iline_leftt3-=0.79+wall_change_line_controlL_Y;
if(finall_count %1==0)iline_leftt2+=1;
line(
267-iline_main,
iline_leftt3,

267-iline_main,

iline_leftt4
);



/*********************右边线变**********************/


setcolor(7);
setlinestyle(0,1,1);

if((finall_count<=2)&&(finall_count %4==0))iline_left3-=0.001;
if((finall_count %4 ==0) && (finall_count>=4) )iline_left3-=0.78+wall_change_line_controlY;

if(finall_count %1==0)iline_left4+=1;
line(

363+iline_main,



iline_left3, /*114*/

363+iline_main,

iline_left4
);




/**************************************************************************************************************************/




/*这里就运行多三次了,所以下次要加多3 */




iline_main+=1;

}

setcolor(7);
setlinestyle(0,1,1);












iline_main=180; /* 记得最后要修改啊醒目仔 */

iline_leftt=114; /*左边线*/
iline_leftt2=200;
iline_leftt3=114;
iline_leftt4=198;



iline_left2=113; /*右边线*/
iline_left22=200;

iline_left3=114;
iline_left4=200;


iline_d1=269; /*地面线*/
iline_d11=365;

iline_d2=271;
iline_d22=363;

change_iline_floor=0;
change_iline_floor1=0;

up_newline_1=0;

up_line++; /* 因为运行这个涵数时,就是进行线条最后的一次重合,所以up_line要运行多一次 */

}


}




/**************************************************************************************************************************/















void line_change_floor(void)
{

if(up_line>=975)up_line=0;

if(up_newline_screen>=925)up_newline_screen=0;



if_change_1(); /*第一组线复位*/



/* 开始判断啦 */


if
(

(up_line>=200&&up_line<=380) ||


(up_line>=460&&up_line<=640) ||



(up_line>=780&&up_line<=960)

)
{





/***************************底面线***************************/
setcolor(1);
setlinestyle(0,1,1);

if(finall_count %1==0)iline_d1-=0.97;
if(finall_count %1==0)iline_d11+=0.97;
line
(
iline_d1,/*269*/
200+up_newline_1,
iline_d11,/*365*/
200+up_newline_1
);




setcolor(15);
setlinestyle(0,1,1);
if(finall_count %1==0)iline_d2-=0.98;
if(finall_count %1==0)iline_d22+=0.97;
line
(
iline_d2,/*271*/
198+up_newline_1,
iline_d22,/*363*/
198+up_newline_1
);


/*************************左边线***************************/



setcolor(1);
setlinestyle(0,1,1);
if(finall_count %4==0)iline_leftt-=0.79+wall_change_line_controlL_Y;
if(finall_count %1==0)iline_leftt2+=1;
line
(
265-up_newline_1,
iline_leftt,
265-up_newline_1,
iline_leftt2
);



setcolor(7);
setlinestyle(0,1,1);
if(finall_count %4==0)iline_leftt3-=0.78+wall_change_line_controlL_Y;
if(finall_count %1==0)iline_leftt4+=1;
line
(
267-up_newline_1,
iline_leftt3,
267-up_newline_1,
iline_leftt4
);


wall_change_line_controlL_Y+=0.00030;

if(wall_change_line_controlL_Y>=0.79100)wall_change_line_controlL_Y=0.79100;


/***********************右边线*****************************/

setcolor(1);
setlinestyle(0,1,1);
if(finall_count %4==0)iline_left2-=0.7+wall_change_line_controlY;
if(finall_count %1==0)iline_left22+=1;

line
(
365+up_newline_1,
iline_left2, /*112*/
365+up_newline_1,
iline_left22 /*200*/
);



setcolor(7);
setlinestyle(0,1,1);


if((finall_count<=2)&&(finall_count %4==0))iline_left3-=0.001;
if((finall_count %4 ==0) && (finall_count>=4) )iline_left3-=0.78+wall_change_line_controlY;

if(finall_count %1==0)iline_left4+=1;
line
(
363+up_newline_1,
iline_left3, /*114*/
363+up_newline_1,
iline_left4 /* 200 */
);


up_newline_1++;

wall_change_line_controlY+=0.00048;

if(wall_change_line_controlY>=0.900002)wall_change_line_controlY=0.900002;
}










/**************************************************************************************************************************/

















up_line++;



change_iline_floor+=1;/*地下蓝线*/
change_iline_floor1+=1; /*地下白线*/






}



void door(void)/*******************门**********************/
{




static int idoor[10];

int *num_idoor[10]={&idoor[0],&idoor[1],&idoor[2],&idoor[3],&idoor[4],
&idoor[5],&idoor[6],&idoor[7],&idoor[8],&idoor[9]};

int **p_idoor=num_idoor;



**p_idoor=305;
**(p_idoor+ 1)= 130;


**(p_idoor+ 2)= 305;
**(p_idoor+ 3)= 160;


**(p_idoor+ 4)= 325;
**(p_idoor+ 5)= 160;


**(p_idoor+ 6)= 325;
**(p_idoor+ 7)= 130;


**(p_idoor+ 8)= 305;
**(p_idoor+ 9)= 130;



setcolor(25);
setfillstyle(1,25);
fillpoly(5,idoor);







}


void door_come(void)
{

setcolor(25);
setlinestyle(0,1,1);
rectangle
(
305-fdoor_count,
130-fdoor_count,
325+fdoor_count,
160+fdoor_count
);
/*line(0,140,300,140);*/


fdoor_count+=0.03;
}




void interface_door(void) /*门入口 */
{

static int iinterface_door[10];
static int iinterface_door_under[8];

int *num_iinterface_door[10]=
{
&iinterface_door[0],&iinterface_door[1],&iinterface_door[2],&iinterface_door[3],&iinterface_door[4],
&iinterface_door[5],&iinterface_door[6],&iinterface_door[7],&iinterface_door[8],&iinterface_door[9]};

int *num_iinterface_door_under[8]=
{
&iinterface_door_under[0],&iinterface_door_under[1],&iinterface_door_under[2],
&iinterface_door_under[3],&iinterface_door_under[4],&iinterface_door_under[5],
&iinterface_door_under[6],&iinterface_door_under[7]
};


int **p_door;
int **p_door_under;



p_door=num_iinterface_door;

p_door_under=num_iinterface_door_under;

**p_door=331+interface_door_count;
**(p_door+ 1)= 135-interface_door_count;


**(p_door+ 2)= 341+interface_door_count_fast;
**(p_door+ 3)= 130-interface_door_special; /*重要边界 0.16则会溢出*/


**(p_door+ 4)= 341+interface_door_count_fast;
**(p_door+ 5)= 166+interface_door_count;

**(p_door+ 6)= 331+interface_door_count;
**(p_door+ 7)= 166+interface_door_count;

**(p_door+ 8)= 331+interface_door_count;
**(p_door+ 9)= 135+interface_door_count;

setcolor(8);
setfillstyle(1,8);
fillpoly(5,iinterface_door);




/***************************************门下的三角形*************************************************/


**p_door_under=331+interface_door_count;
**(p_door_under+ 1)= 166+interface_door_count;


**(p_door_under+ 2)= 341+interface_door_count_fast;
**(p_door_under+ 3)= 180+interface_door_count_fast;

**(p_door_under+ 4)= 341+interface_door_count_fast;
**(p_door_under+ 5)= 166+interface_door_count;

**(p_door_under+ 6)= 331+interface_door_count;
**(p_door_under+ 7)= 166+interface_door_count;


setcolor(15);
setfillstyle(1,15);
fillpoly(4,iinterface_door_under);





/*************************************竖线复盖**********************************************************/



setcolor(7);
setlinestyle(0,1,1);
line
(
330+interface_door_count,
136-interface_door_count,
330+interface_door_count,
166+interface_door_count

);



interface_door_count+=0.08;

interface_door_count_fast+=0.16;

if(interface_door_special>=30)
if(interface_door_special>=70)
if(interface_door_special>=90)
{interface_door_special+=0.2;}
else
{interface_door_special+=0.3;}

else

{interface_door_special+=0.159;}

else


interface_door_special+=0.11;


}









void test(void)
{

float left_test=145;
float left_test1=145;
float left_test2=145;
float line_test=145;

float neibu_wall_thing=145;
float neibu_wall_thing_line=145;

/*
int wall_change1=295;
int wall_change2=295;
*/

/**********************************墙边渐变*************************************************/

static int iwall_change[10];
int *num_wall_change[10]={&iwall_change[0],&iwall_change[1],&iwall_change[2],&iwall_change[3],&iwall_change[4],
&iwall_change[5],&iwall_change[6],&iwall_change[7],&iwall_change[8],&iwall_change[9]};


int **wall_change;

int iwall_count=0;
float line_count=0;


wall_change=num_wall_change ; /*墙渐变*/



/********************************************** 最外部循环 **************************************************************/


while(finall_count<=1000)
{

if(finall_count==650)
{


neibu_wall_thing-=3;

if(neibu_wall_thing<=108)neibu_wall_thing=108;




finall_count=0;

iwall_count=finall_count; /*当finall_count运行完一次之后就复位为0传给 iwall_count */






neibu_wall_thing_line-=2.7;
if(neibu_wall_thing_line<=112)neibu_wall_thing_line=112;

line_test=neibu_wall_thing_line;



line_count=0;


left_test1=neibu_wall_thing;
left_test2=neibu_wall_thing;
left_test=neibu_wall_thing;




}




/************** 1 ****************/
**wall_change=270-iwall_count;
**(wall_change+ 1)= left_test1; /* 145 */
if(iwall_count %3==0)
left_test1=**(wall_change+ 1)=left_test1-2;


/************** 2 ****************/
**(wall_change+ 2)= 270-iwall_count;
**(wall_change+ 3)= 150+iwall_count;




/************** 3 ****************/
**(wall_change+ 4)= 265-iwall_count;
**(wall_change+ 5)= 155+iwall_count;



/************** 4 ****************/
**(wall_change+ 6)= 265-iwall_count;
**(wall_change+ 7)=left_test;
if(iwall_count %3==0)
left_test=**(wall_change+ 7)=left_test-2;



/************** 5 ****************/
**(wall_change+ 8)= 270-iwall_count;
**(wall_change+ 9)=left_test2;
if(iwall_count %3==0)
left_test2=**(wall_change+ 9)=left_test2+2;




setcolor(30);
setfillstyle(1,30);
fillpoly(5,iwall_change);




/*********************************线条的覆盖****************************/


setcolor(7);
setlinestyle(0,1,1);


if(iwall_count %3==0)line_test-=1.2;
line(280-line_count,line_test,280-line_count,150+line_count);

line_count+=1;







/********************************变量递增*******************************/

iwall_count+=2;
finall_count+=2;






/*********************************************************************/
/*********************************************************************/
/******************************线性渐变*******************************/

line_change_floor();








/*****************************墙开始渐变******************************/



if( up_line % 30==0)
{

wall_change_line();

wall_change_line_left();



}


if(up_line % 4==0)
{

door_come();
interface_door();
}





/* getch(); */

} /* 循环体内 */



}

/********************************************test******************************************************************/
/********************************************test******************************************************************/
/********************************************test******************************************************************/
/********************************************test******************************************************************/
/********************************************test******************************************************************/
/********************************************test******************************************************************/




void right_wall(void)
{


/*************************************右侧墙*****************************************************/
static int iright_wall[10];

int *num_right_wall[18]={&iright_wall[0],&iright_wall[1],&iright_wall[2],&iright_wall[3],&iright_wall[4],
&iright_wall[5],&iright_wall[6],
&iright_wall[7],&iright_wall[8],&iright_wall[9]
};

int **right_wall;

right_wall=num_right_wall;/*右侧墙*/

/*******************右侧墙********************/
**right_wall=640;
**(right_wall+ 1)= 0;


**(right_wall+ 2)= 326;
**(right_wall+ 3)= 130;

**(right_wall+ 4)= 326;
**(right_wall+ 5)= 160;

**(right_wall+ 6)= 640;/* */
**(right_wall+ 7)= 480;

**(right_wall+ 8)= 640;
**(right_wall+ 9)= 0;






setcolor(7);
setfillstyle(1,7);
fillpoly(5,iright_wall);




}





void terra(void) /* 地面 */
{


/***********************************地面****************************************************/

static int ifloor[10];
int *num_floor[10]={&ifloor[0],&ifloor[1],&ifloor[2],&ifloor[3],&ifloor[4],
&ifloor[5],&ifloor[6],&ifloor[7],&ifloor[8],&ifloor[9]};

int **floor;

floor=num_floor; /*地面*/

cleardevice();
/*******************地面*********************/

**floor=0;
**(floor+ 1)= 480;

**(floor+ 2)= 200;
**(floor+ 3)= 160;


**(floor+ 4)= 340;
**(floor+ 5)= 160;

**(floor+ 6)= 640;
**(floor+ 7)= 480;

**(floor+ 8)= 0;
**(floor+ 9)= 480;

setcolor(15);
setfillstyle(1,15);
fillpoly(5,ifloor);



}
























void start_moive(void)
{



/*******************************大的灯************************************************************/
static int ilight[21];

int *num_light[21]={&ilight[0],&ilight[1],&ilight[2],&ilight[3],&ilight[4],&ilight[5],&ilight[6],
&ilight[7],&ilight[8],&ilight[9],&ilight[10],&ilight[11],&ilight[12],&ilight[13],&ilight[14],
&ilight[15],&ilight[16],&ilight[17],&ilight[18],&ilight[19],&ilight[20]};






/************************************左侧墙****************************************************/
static int ileft_wall[10];

int *num_left_wall[10]={&ileft_wall[0],&ileft_wall[1],&ileft_wall[2],&ileft_wall[3],&ileft_wall[4],
&ileft_wall[5],&ileft_wall[6],&ileft_wall[7],&ileft_wall[8],&ileft_wall[9]};






int iwall_count=0;
float line_count=0;


int **p_light;





int **left_wall;







/********************左侧墙********************/

left_wall=num_left_wall;

**left_wall=0;
**(left_wall+ 1)= 0;


**(left_wall+ 2)= 0;
**(left_wall+ 3)= 480;


**(left_wall+ 4)= 305;
**(left_wall+ 5)= 160;


**(left_wall+ 6)= 305;
**(left_wall+ 7)= 130;


**(left_wall+ 8)= 0;
**(left_wall+ 9)= 0;



setcolor(7);
setfillstyle(1,7);
fillpoly(5,ileft_wall);










/********************灯*******************/
p_light=num_light;



**p_light=310;
**(p_light+1 )=10;


**(p_light+ 2)=310;
**(p_light+ 3)=20;



**(p_light+ 4)=285;
**(p_light+ 5)=20;



**(p_light+ 6)= 265;
**(p_light+ 7)= 50;


**(p_light+ 8)= 265;
**(p_light+ 9)=60;


**(p_light+ 10)=365;
**(p_light+ 11)=60;



**(p_light+ 12)=365;
**(p_light+ 13)=50;


**(p_light+ 14)=345;
**(p_light+ 15)=20;


**(p_light+ 16)=320;
**(p_light+ 17)=20;


**(p_light+ 18)=320;
**(p_light+ 19)=10;


**(p_light+ 20)=310;
**(p_light+ 21)=10;


setcolor(10);
setfillstyle(1,10);
fillpoly(10,ilight);

setcolor(15);
setlinestyle(0,1,1);
arc(315,40,220,320,30);

line(293,60,336,60);

setfillstyle(1,15);
floodfill(316,61,15);


/*在圆弧上画一条线以便可以用floodfill填充来防止颜色溢出*/







































}




main()
{

int gdriver,gmode,i;

gdriver=DETECT;gmode;
registerbgidriver(IBM8514_driver);
initgraph(&gdriver,&gmode,"c://turboc2");
cleardevice();
setbkcolor(8);

/*den_shan();*/



terra(); /*地面 */

start_moive();



right_wall(); /*右侧墙 */




interface_door();/*门入口 */


door();
getch();

test();

}

请问怎样可以实现当门走近时,实现向左转呢?
谢谢
 
#include<graphics.h>
#include<io.h>
#include<stdio.h>
#include<dos.h>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<bios.h>
#include<mem.h>
#include<fcntl.h>
#include<stdlib.h>
#include<conio.h>
#include<process.h>


int finall_count=0;
int ilinex1=265; int change_iline_floor=0; int screen_count=0;



float up_newline_screen=0; /*线行内步增量参数 */
float up_newline_1=0;




int iline2x1=267; int iline2y1=198; int change_iline_floor1=0;

int iline2x2=363,iline2y2=198; int up_line=0;



float iline_d1=269; /*地面线*/
float iline_d11=365;


float iline_d2=271; /*地面线(白)*/
float iline_d22=363;


float interface_door_count=0; /* 门入口线渐变变量 */
float interface_door_count_fast=0;
float interface_door_special=0;



float iline_leftt=114; /*左边线*/
float iline_leftt2=200;
float iline_leftt3=114;
float iline_leftt4=198;



float iline_left2=113; /*右边线*/
float iline_left22=200;
float iline_left3=114;
float iline_left4=200;


int iline_main=180; /*线性之差内部变量*/

/********************************************* 开始线性渐变变量 ********************************************************/

float wall_change_line_control=640; /*右上角线 */
float wall_change_line_controlx=0;


float wall_change_line_control1=0; /*左上角线 */
float wall_change_line_control1x=0;

float wall_change_line_controlY=0; /* 右边竖线 */
float wall_change_line_controlL_Y=0; /* 左边竖线 */


float fdoor_count=0; /* 门口既增量 */


/***********************************************************************************************************************/

void DELAY(int clicks)
{
unsigned int far *clock=(unsigned int far *)0x0000046CL;
unsigned int now;
now=*clock;
while(abs(*clock-now)<clicks){}
}







void wall_change_line(void) /*右边墙上角线渐变 */
{

if (wall_change_line_control>=450)
{
setcolor(7);
setlinestyle(0,1,3);

line
(
326+wall_change_line_controlx,
131-wall_change_line_controlx,
wall_change_line_control,
0
);

if(up_line % 4==0)
wall_change_line_controlx+=0.5;

wall_change_line_control-=2;


}

}




void wall_change_line_left(void) /*左上角线 */
{


if (wall_change_line_control1<=180)
{
setcolor(7);
setlinestyle(0,1,3);

line
(
304-wall_change_line_control1x,
131-wall_change_line_control1x,
wall_change_line_control1,
0
);

if(up_line % 4==0)
wall_change_line_control1x+=0.5;

wall_change_line_control1+=2;

}
}



/***************************************************************************************************************************/





void if_change_1(void) /* 第一组线复位 及 重合*/
{




if (up_newline_1==180)
{

while (iline_main<=183)
{


/**********************底边线变**********************/

setcolor(15);
setlinestyle(0,1,1);
if(finall_count %1==0)iline_d2-=0.97;
if(finall_count %1==0)iline_d22+=0.97;
line
(

iline_d2, /*271*/

198+iline_main,

iline_d22, /*363*/

198+iline_main

);


/********************左边线变***********************/
setcolor(7);
setlinestyle(0,1,1);

if(finall_count %4==0)iline_leftt3-=0.79+wall_change_line_controlL_Y;
if(finall_count %1==0)iline_leftt2+=1;
line(
267-iline_main,
iline_leftt3,

267-iline_main,

iline_leftt4
);



/*********************右边线变**********************/


setcolor(7);
setlinestyle(0,1,1);

if((finall_count<=2)&&(finall_count %4==0))iline_left3-=0.001;
if((finall_count %4 ==0) && (finall_count>=4) )iline_left3-=0.78+wall_change_line_controlY;

if(finall_count %1==0)iline_left4+=1;
line(

363+iline_main,



iline_left3, /*114*/

363+iline_main,

iline_left4
);




/**************************************************************************************************************************/




/*这里就运行多三次了,所以下次要加多3 */




iline_main+=1;

}

setcolor(7);
setlinestyle(0,1,1);












iline_main=180; /* 记得最后要修改啊醒目仔 */

iline_leftt=114; /*左边线*/
iline_leftt2=200;
iline_leftt3=114;
iline_leftt4=198;



iline_left2=113; /*右边线*/
iline_left22=200;

iline_left3=114;
iline_left4=200;


iline_d1=269; /*地面线*/
iline_d11=365;

iline_d2=271;
iline_d22=363;

change_iline_floor=0;
change_iline_floor1=0;

up_newline_1=0;

up_line++; /* 因为运行这个涵数时,就是进行线条最后的一次重合,所以up_line要运行多一次 */

}


}




/**************************************************************************************************************************/















void line_change_floor(void)
{

if(up_line>=975)up_line=0;

if(up_newline_screen>=925)up_newline_screen=0;



if_change_1(); /*第一组线复位*/



/* 开始判断啦 */


if
(

(up_line>=200&&up_line<=380) ||


(up_line>=460&&up_line<=640) ||



(up_line>=780&&up_line<=960)

)
{





/***************************底面线***************************/
setcolor(1);
setlinestyle(0,1,1);

if(finall_count %1==0)iline_d1-=0.97;
if(finall_count %1==0)iline_d11+=0.97;
line
(
iline_d1,/*269*/
200+up_newline_1,
iline_d11,/*365*/
200+up_newline_1
);




setcolor(15);
setlinestyle(0,1,1);
if(finall_count %1==0)iline_d2-=0.98;
if(finall_count %1==0)iline_d22+=0.97;
line
(
iline_d2,/*271*/
198+up_newline_1,
iline_d22,/*363*/
198+up_newline_1
);


/*************************左边线***************************/



setcolor(1);
setlinestyle(0,1,1);
if(finall_count %4==0)iline_leftt-=0.79+wall_change_line_controlL_Y;
if(finall_count %1==0)iline_leftt2+=1;
line
(
265-up_newline_1,
iline_leftt,
265-up_newline_1,
iline_leftt2
);



setcolor(7);
setlinestyle(0,1,1);
if(finall_count %4==0)iline_leftt3-=0.78+wall_change_line_controlL_Y;
if(finall_count %1==0)iline_leftt4+=1;
line
(
267-up_newline_1,
iline_leftt3,
267-up_newline_1,
iline_leftt4
);


wall_change_line_controlL_Y+=0.00030;

if(wall_change_line_controlL_Y>=0.79100)wall_change_line_controlL_Y=0.79100;


/***********************右边线*****************************/

setcolor(1);
setlinestyle(0,1,1);
if(finall_count %4==0)iline_left2-=0.7+wall_change_line_controlY;
if(finall_count %1==0)iline_left22+=1;

line
(
365+up_newline_1,
iline_left2, /*112*/
365+up_newline_1,
iline_left22 /*200*/
);



setcolor(7);
setlinestyle(0,1,1);


if((finall_count<=2)&&(finall_count %4==0))iline_left3-=0.001;
if((finall_count %4 ==0) && (finall_count>=4) )iline_left3-=0.78+wall_change_line_controlY;

if(finall_count %1==0)iline_left4+=1;
line
(
363+up_newline_1,
iline_left3, /*114*/
363+up_newline_1,
iline_left4 /* 200 */
);


up_newline_1++;

wall_change_line_controlY+=0.00048;

if(wall_change_line_controlY>=0.900002)wall_change_line_controlY=0.900002;
}










/**************************************************************************************************************************/

















up_line++;



change_iline_floor+=1;/*地下蓝线*/
change_iline_floor1+=1; /*地下白线*/






}



void door(void)/*******************门**********************/
{




static int idoor[10];

int *num_idoor[10]={&idoor[0],&idoor[1],&idoor[2],&idoor[3],&idoor[4],
&idoor[5],&idoor[6],&idoor[7],&idoor[8],&idoor[9]};

int **p_idoor=num_idoor;



**p_idoor=305;
**(p_idoor+ 1)= 130;


**(p_idoor+ 2)= 305;
**(p_idoor+ 3)= 160;


**(p_idoor+ 4)= 325;
**(p_idoor+ 5)= 160;


**(p_idoor+ 6)= 325;
**(p_idoor+ 7)= 130;


**(p_idoor+ 8)= 305;
**(p_idoor+ 9)= 130;



setcolor(25);
setfillstyle(1,25);
fillpoly(5,idoor);







}


void door_come(void)
{

setcolor(25);
setlinestyle(0,1,1);
rectangle
(
305-fdoor_count,
130-fdoor_count,
325+fdoor_count,
160+fdoor_count
);
/*line(0,140,300,140);*/


fdoor_count+=0.03;
}




void interface_door(void) /*门入口 */
{

static int iinterface_door[10];
static int iinterface_door_under[8];

int *num_iinterface_door[10]=
{
&iinterface_door[0],&iinterface_door[1],&iinterface_door[2],&iinterface_door[3],&iinterface_door[4],
&iinterface_door[5],&iinterface_door[6],&iinterface_door[7],&iinterface_door[8],&iinterface_door[9]};

int *num_iinterface_door_under[8]=
{
&iinterface_door_under[0],&iinterface_door_under[1],&iinterface_door_under[2],
&iinterface_door_under[3],&iinterface_door_under[4],&iinterface_door_under[5],
&iinterface_door_under[6],&iinterface_door_under[7]
};


int **p_door;
int **p_door_under;



p_door=num_iinterface_door;

p_door_under=num_iinterface_door_under;

**p_door=331+interface_door_count;
**(p_door+ 1)= 135-interface_door_count;


**(p_door+ 2)= 341+interface_door_count_fast;
**(p_door+ 3)= 130-interface_door_special; /*重要边界 0.16则会溢出*/


**(p_door+ 4)= 341+interface_door_count_fast;
**(p_door+ 5)= 166+interface_door_count;

**(p_door+ 6)= 331+interface_door_count;
**(p_door+ 7)= 166+interface_door_count;

**(p_door+ 8)= 331+interface_door_count;
**(p_door+ 9)= 135+interface_door_count;

setcolor(8);
setfillstyle(1,8);
fillpoly(5,iinterface_door);




/***************************************门下的三角形*************************************************/


**p_door_under=331+interface_door_count;
**(p_door_under+ 1)= 166+interface_door_count;


**(p_door_under+ 2)= 341+interface_door_count_fast;
**(p_door_under+ 3)= 180+interface_door_count_fast;

**(p_door_under+ 4)= 341+interface_door_count_fast;
**(p_door_under+ 5)= 166+interface_door_count;

**(p_door_under+ 6)= 331+interface_door_count;
**(p_door_under+ 7)= 166+interface_door_count;


setcolor(15);
setfillstyle(1,15);
fillpoly(4,iinterface_door_under);





/*************************************竖线复盖**********************************************************/



setcolor(7);
setlinestyle(0,1,1);
line
(
330+interface_door_count,
136-interface_door_count,
330+interface_door_count,
166+interface_door_count

);



interface_door_count+=0.08;

interface_door_count_fast+=0.16;

if(interface_door_special>=30)
if(interface_door_special>=70)
if(interface_door_special>=90)
{interface_door_special+=0.2;}
else
{interface_door_special+=0.3;}

else

{interface_door_special+=0.159;}

else


interface_door_special+=0.11;


}









void test(void)
{

float left_test=145;
float left_test1=145;
float left_test2=145;
float line_test=145;

float neibu_wall_thing=145;
float neibu_wall_thing_line=145;

/*
int wall_change1=295;
int wall_change2=295;
*/

/**********************************墙边渐变*************************************************/

static int iwall_change[10];
int *num_wall_change[10]={&iwall_change[0],&iwall_change[1],&iwall_change[2],&iwall_change[3],&iwall_change[4],
&iwall_change[5],&iwall_change[6],&iwall_change[7],&iwall_change[8],&iwall_change[9]};


int **wall_change;

int iwall_count=0;
float line_count=0;


wall_change=num_wall_change ; /*墙渐变*/



/********************************************** 最外部循环 **************************************************************/


while(finall_count<=1000)
{

if(finall_count==650)
{


neibu_wall_thing-=3;

if(neibu_wall_thing<=108)neibu_wall_thing=108;




finall_count=0;

iwall_count=finall_count; /*当finall_count运行完一次之后就复位为0传给 iwall_count */






neibu_wall_thing_line-=2.7;
if(neibu_wall_thing_line<=112)neibu_wall_thing_line=112;

line_test=neibu_wall_thing_line;



line_count=0;


left_test1=neibu_wall_thing;
left_test2=neibu_wall_thing;
left_test=neibu_wall_thing;




}




/************** 1 ****************/
**wall_change=270-iwall_count;
**(wall_change+ 1)= left_test1; /* 145 */
if(iwall_count %3==0)
left_test1=**(wall_change+ 1)=left_test1-2;


/************** 2 ****************/
**(wall_change+ 2)= 270-iwall_count;
**(wall_change+ 3)= 150+iwall_count;




/************** 3 ****************/
**(wall_change+ 4)= 265-iwall_count;
**(wall_change+ 5)= 155+iwall_count;



/************** 4 ****************/
**(wall_change+ 6)= 265-iwall_count;
**(wall_change+ 7)=left_test;
if(iwall_count %3==0)
left_test=**(wall_change+ 7)=left_test-2;



/************** 5 ****************/
**(wall_change+ 8)= 270-iwall_count;
**(wall_change+ 9)=left_test2;
if(iwall_count %3==0)
left_test2=**(wall_change+ 9)=left_test2+2;




setcolor(30);
setfillstyle(1,30);
fillpoly(5,iwall_change);




/*********************************线条的覆盖****************************/


setcolor(7);
setlinestyle(0,1,1);


if(iwall_count %3==0)line_test-=1.2;
line(280-line_count,line_test,280-line_count,150+line_count);

line_count+=1;







/********************************变量递增*******************************/

iwall_count+=2;
finall_count+=2;






/*********************************************************************/
/*********************************************************************/
/******************************线性渐变*******************************/

line_change_floor();








/*****************************墙开始渐变******************************/



if( up_line % 30==0)
{

wall_change_line();

wall_change_line_left();



}


if(up_line % 4==0)
{

door_come();
interface_door();
}





/* getch(); */

} /* 循环体内 */



}

/********************************************test******************************************************************/
/********************************************test******************************************************************/
/********************************************test******************************************************************/
/********************************************test******************************************************************/
/********************************************test******************************************************************/
/********************************************test******************************************************************/




void right_wall(void)
{


/*************************************右侧墙*****************************************************/
static int iright_wall[10];

int *num_right_wall[18]={&iright_wall[0],&iright_wall[1],&iright_wall[2],&iright_wall[3],&iright_wall[4],
&iright_wall[5],&iright_wall[6],
&iright_wall[7],&iright_wall[8],&iright_wall[9]
};

int **right_wall;

right_wall=num_right_wall;/*右侧墙*/

/*******************右侧墙********************/
**right_wall=640;
**(right_wall+ 1)= 0;


**(right_wall+ 2)= 326;
**(right_wall+ 3)= 130;

**(right_wall+ 4)= 326;
**(right_wall+ 5)= 160;

**(right_wall+ 6)= 640;/* */
**(right_wall+ 7)= 480;

**(right_wall+ 8)= 640;
**(right_wall+ 9)= 0;






setcolor(7);
setfillstyle(1,7);
fillpoly(5,iright_wall);




}





void terra(void) /* 地面 */
{


/***********************************地面****************************************************/

static int ifloor[10];
int *num_floor[10]={&ifloor[0],&ifloor[1],&ifloor[2],&ifloor[3],&ifloor[4],
&ifloor[5],&ifloor[6],&ifloor[7],&ifloor[8],&ifloor[9]};

int **floor;

floor=num_floor; /*地面*/

cleardevice();
/*******************地面*********************/

**floor=0;
**(floor+ 1)= 480;

**(floor+ 2)= 200;
**(floor+ 3)= 160;


**(floor+ 4)= 340;
**(floor+ 5)= 160;

**(floor+ 6)= 640;
**(floor+ 7)= 480;

**(floor+ 8)= 0;
**(floor+ 9)= 480;

setcolor(15);
setfillstyle(1,15);
fillpoly(5,ifloor);



}
























void start_moive(void)
{



/*******************************大的灯************************************************************/
static int ilight[21];

int *num_light[21]={&ilight[0],&ilight[1],&ilight[2],&ilight[3],&ilight[4],&ilight[5],&ilight[6],
&ilight[7],&ilight[8],&ilight[9],&ilight[10],&ilight[11],&ilight[12],&ilight[13],&ilight[14],
&ilight[15],&ilight[16],&ilight[17],&ilight[18],&ilight[19],&ilight[20]};






/************************************左侧墙****************************************************/
static int ileft_wall[10];

int *num_left_wall[10]={&ileft_wall[0],&ileft_wall[1],&ileft_wall[2],&ileft_wall[3],&ileft_wall[4],
&ileft_wall[5],&ileft_wall[6],&ileft_wall[7],&ileft_wall[8],&ileft_wall[9]};






int iwall_count=0;
float line_count=0;


int **p_light;





int **left_wall;







/********************左侧墙********************/

left_wall=num_left_wall;

**left_wall=0;
**(left_wall+ 1)= 0;


**(left_wall+ 2)= 0;
**(left_wall+ 3)= 480;


**(left_wall+ 4)= 305;
**(left_wall+ 5)= 160;


**(left_wall+ 6)= 305;
**(left_wall+ 7)= 130;


**(left_wall+ 8)= 0;
**(left_wall+ 9)= 0;



setcolor(7);
setfillstyle(1,7);
fillpoly(5,ileft_wall);










/********************灯*******************/
p_light=num_light;



**p_light=310;
**(p_light+1 )=10;


**(p_light+ 2)=310;
**(p_light+ 3)=20;



**(p_light+ 4)=285;
**(p_light+ 5)=20;



**(p_light+ 6)= 265;
**(p_light+ 7)= 50;


**(p_light+ 8)= 265;
**(p_light+ 9)=60;


**(p_light+ 10)=365;
**(p_light+ 11)=60;



**(p_light+ 12)=365;
**(p_light+ 13)=50;


**(p_light+ 14)=345;
**(p_light+ 15)=20;


**(p_light+ 16)=320;
**(p_light+ 17)=20;


**(p_light+ 18)=320;
**(p_light+ 19)=10;


**(p_light+ 20)=310;
**(p_light+ 21)=10;


setcolor(10);
setfillstyle(1,10);
fillpoly(10,ilight);

setcolor(15);
setlinestyle(0,1,1);
arc(315,40,220,320,30);

line(293,60,336,60);

setfillstyle(1,15);
floodfill(316,61,15);


/*在圆弧上画一条线以便可以用floodfill填充来防止颜色溢出*/







































}




main()
{

int gdriver,gmode,i;

gdriver=DETECT;gmode;
registerbgidriver(IBM8514_driver);
initgraph(&gdriver,&gmode,"c://turboc2");
cleardevice();
setbkcolor(8);

/*den_shan();*/



terra(); /*地面 */

start_moive();



right_wall(); /*右侧墙 */




interface_door();/*门入口 */


door();
getch();

test();

}

请问怎样可以实现当门走近时,实现向左转呢?
谢谢
 
大家别怪我将C的问题搬到这里讲,因为想必DELPHI的高手对C一定会很精通的,

请大家运行一下发表一下啊,这只是我做的第一个画面.
难度就在转弯的地方.

这里用了C的<graphics.h> 的多边形,矩形,线....等二维图形,来实现一个三维的动画.
 
请大家帮帮手啊
 
难度就在转弯的地方--具体是?
 
你运行一下就知道了
 
后退
顶部