void confirmComplete(double x1, double y1, double x2, double y2)//确认完成按钮函数 { MovePen(x1,y1); DrawLine(x2-x1,0); DrawLine(0,y2-y1); DrawLine(x1-x2,0); DrawLine(0,y1-y2); double distance1; double distance2; double X,Y; SetPenColor(RED); distance1=(x2-x1-GetStringWidth("输入完成"))/2; distance2=(y1-y2-GetStringWidth("输"))/2; MovePen(x1+distance1,y1-distance2); DrawString("输入完成"); SetPenColor(BLACK); while(1) { while(!(WaitForEvent()==KEYDOWN)){} if(GetStruckKey() == VK_LBUTTON) { X = GetMouseX(); Y = GetMouseY(); if((X >= x1 && X <= x2) && (Y >= y2 && Y <= y1))//鼠标点击在所规定的范围内 { EatEgg();//吃掉完成键和信息输入框的蛋 break; } } } }
void isDefault(double x1, double y1, double x2, double y2)//是否使用默认配置函数 { LayEgg();//是否的蛋 int i; double parameter; double distance1; double distance2; MovePen(x1+235,y1+20); DrawString("是否使用默认配置"); MovePen(x1,y1); DrawLine(x2-x1,0); DrawLine(0,y2-y1); DrawLine(x1-x2,0); DrawLine(0,y1-y2); MovePen(x1+(x2-x1)/2,y1); DrawLine(0,y2-y1); distance1=((x2-x1)/2-GetStringWidth("是"))/2; distance2=(y1-y2-GetStringWidth("是"))/2; MovePen(x1+distance1,y1-distance2); DrawString("是"); MovePen(x1+(x2-x1)/2+distance1,y1-distance2); DrawString("否"); double X,Y; while(1) { while(!(WaitForEvent()==KEYDOWN)){} if(GetStruckKey() == VK_LBUTTON) { X = GetMouseX(); Y = GetMouseY(); if((X >= x1 && X <= x1+(x2-x1)/2) && (Y >= y2 && Y <= y1))//鼠标点击在所规定的范围内 { printf("使用默认配置\n"); EatEgg(); break; } else if((X > x1+(x2-x1)/2 && X <= x2) && (Y >= y2 && Y <= y1)) { printf("不使用默认配置\n\n"); printf("本输入框使用方法如下:\n"); printf("1. 在输入时应一项一项一次输入。\n"); printf("2. 点击鼠标左键为输入模式,键盘Backspace为清除模式,鼠标右键为确认模式。\n"); printf("3. 进入输入模式,输入相应的数字后,点击ESC键可退出输入模式,此时,在相应区域点击Backspace键则可清除相应数字,\n 再次输入如上。点击鼠标右键完成输入后则可进入下一项的输入。\n"); printf("4. 在全部信息输入完成后,会出现完成按钮,点击则最终完成信息输入。\n"); EatEgg(); LayEgg(); createInputFrame(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE);//建立输入信息框 printf("\n下面开始输入A火车信息:\n"); for(i=1;i<=7;i++)//进行A火车信息的配置 { //parameter=0,省略了 switch(i) { case 1:trainA.type = (int)showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车类型(1表示快车,2表示慢车):",i);break; case 2:trainA.speed = showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车速度(m/s)(0到10):",i);break; case 3:trainA.direction = (int)showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"方向(顺时针为1,逆时针为-1):",i);break; case 4:trainA.trackLen = showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"轨道长度(m)(0到100):",i);break; case 5:trainA.position = showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"初始位置(0至轨道长度):",i);break; case 6:trainA.time = showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"启动时间(从程序开始运行起/s):",i);break; case 7:trainA.restTime = showDeleteInput(INPUT_LEFT_UP_X, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"公共轨道停留时间:",i);break; } } printf("A火车信息已经输入完成。\n"); printf("下面开始输入B火车信息:\n"); for(i=1;i<=7;i++)//进行B火车信息的配置 { parameter=(INPUT_RIGHT_DOWN_X-INPUT_LEFT_UP_X)/4; switch(i) { case 1:trainB.type = (int)showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车类型(1表示快车,2表示慢车):",i);break; case 2:trainB.speed = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车速度(m/s)(0到10):",i);break; case 3:trainB.direction = (int)showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"方向(顺时针为1,逆时针为-1):",i);break; case 4:trainB.trackLen = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"轨道长度(m)(0到100):",i);break; case 5:trainB.position = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"初始位置(0至轨道长度):",i);break; case 6:trainB.time = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"启动时间(从程序开始运行起/s):",i);break; case 7:trainB.restTime = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"公共轨道停留时间:",i);break; } } printf("B火车信息已经输入完成。\n"); printf("下面开始输入C火车信息:\n"); for(i=1;i<=7;i++)//进行C火车信息的配置 { parameter=(INPUT_RIGHT_DOWN_X-INPUT_LEFT_UP_X)*2/4; switch(i) { case 1:trainC.type = (int)showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车类型(1表示快车,2表示慢车):",i);break; case 2:trainC.speed = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"火车速度(m/s)(0到10):",i);break; case 3:trainC.direction = (int)showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"方向(顺时针为1,逆时针为-1):",i);break; case 4:trainC.trackLen = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"轨道长度(m)(0到100):",i);break; case 5:trainC.position = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"初始位置(0至轨道长度):",i);break; case 6:trainC.time = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"启动时间(从程序开始运行起/s):",i);break; case 7:trainC.restTime = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"公共轨道停留时间:",i);break; } } printf("C火车信息已经输入完成。\n"); printf("下面开始输入探测点信息:\n"); for(i=1;i<=8;i++)//进行探测点信息的配置 { parameter=(INPUT_RIGHT_DOWN_X-INPUT_LEFT_UP_X)*3/4; switch(i) { case 1:a1_in = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、B车公轨A车的入口探测点:",i);break; case 2:a1_out = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、B车公轨A车的出口探测点:",i);break; case 3:b_in = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、B车公轨B车的入口探测点:",i);break; case 4:b_out = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、B车公轨B车的出口探测点:",i);break; case 5:a2_in = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、C车公轨A车的入口探测点:",i);break; case 6:a2_out = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、C车公轨A车的出口探测点:",i);break; case 7:c_in = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、C车公轨C车的入口探测点:",i);break; case 8:c_out = showDeleteInput(INPUT_LEFT_UP_X+parameter, INPUT_LEFT_UP_Y, INPUT_RIGHT_DOWN_X, INPUT_RIGHT_DOWN_Y, DISTANCE,"A车、C车公轨C车的出口探测点:",i);break; } } printf("探测点信息输入完成:\n"); printf("请点击面板上的完成键"); confirmComplete(320, 400, 900, 250); EatEgg(); break; } } } }
int egg_tips()//打印egg库版本的初始化提示信息 { HEGG first_egg;//打印初始信息的egg char infor1[]="欢迎来到黄金梅里号~~"; char infor2[]="为了使您“旅途愉快”,请先进行一下电梯参数的参数配置:"; int situ,i/*counter*/; int mouseX,mouseY; int dealwith_click(int num); first_egg=LayEgg(); DrawBitmap("bitmap//开始.bmp"); MovePen(200,670); SetPenColor(BLUE); act_string(infor1,70); MovePen(200,650); SetPenColor(DARK_MAGENTA); act_string(infor2,60); //initialization MovePen(200,590); DrawBitmap("bitmap//scale.bmp"); if(delay==DEFAULT_DELAY && ratio==DEFAULT_RATIO && strategy==DEFAULT_STRATEGY) { MovePen(click[0].leftup_x,click[0].leftup_y); DrawBitmap(click[0].bitmap_R); } switch(delay) { case 500: MovePen(click[3].leftup_x,click[3].leftup_y); DrawBitmap(click[3].bitmap_R); break; case 1000: MovePen(click[4].leftup_x,click[4].leftup_y); DrawBitmap(click[4].bitmap_R); break; case 1500: MovePen(click[5].leftup_x,click[5].leftup_y); DrawBitmap(click[5].bitmap_R); break; case 2000: MovePen(click[6].leftup_x,click[6].leftup_y); DrawBitmap(click[6].bitmap_R); break; case 3000: MovePen(click[7].leftup_x,click[7].leftup_y); DrawBitmap(click[7].bitmap_R); break; } MovePen(click[7+ratio].leftup_x,click[7+ratio].leftup_y); DrawBitmap(click[7+ratio].bitmap_R); MovePen(click[12+strategy].leftup_x,click[12+strategy].leftup_y); DrawBitmap(click[12+strategy].bitmap_R); while((situ=WaitForEvent())!=0) { mouseX=(int)GetMouseX(); mouseY=(int)GetMouseY(); if(situ==KEYDOWN) { for(i=0;i<19;i++) { if(click[i].leftup_x<=mouseX && click[i].leftup_y>=mouseY && click[i].rightdown_x>=mouseX && click[i].rightdown_y<=mouseY) { int r; if((r=dealwith_click(i))==1) { EatEgg(); return 1; } else if(r==-1) { EatEgg(); return -1; } break; } } } } EatEgg(); return 0; }