某白的记忆吧 关注:9贴子:658
  • 0回复贴,共1

你说这货是推箱子?!

取消只看楼主收藏回复

#include "graphics.h"
#include"math.h"
main( )
{
int driver,mode;
int x1,y1,x2,y2,a;
driver=DETECT;
initgraph(&driver,&mode," ");
setbkcolor(WHITE);
setcolor(RED);
rectangle(54,50,580,450);
rectangle(120,120,204,200); /*1hao*/
rectangle(426,120,510,200); /*2hao*/
rectangle(120,300,204,380); /*3hao*/
rectangle(426,300,510,380); /*4hao*/
x1=310,y1=330,x2=350,y2=370;
while(1)
{
setcolor(BLUE);
rectangle(x1,y1,x2,y2);
a=bioskey(0);
switch(a)
{ /* 1hao 2hao 3hao 4hao*/
case 18432:if(y1<60||y1==205&&x1>75&&x1<210||y1==205&&x1>380&&x1<515||y1==385&&x1>75&&x1<210||y1==385&&x1>380&&x1<515)continue;
y1=y1-5,y2=y2-5;setcolor(WHITE);rectangle(x1,y1+5,x2,y2+5);break; /*up*/ case 20480:if(y1>400||y1==75&&x1>75&&x1<210||y1==75 &&x1>380&&x1<515||y1==255&&x1>75&&x1<210||y1==255&&x1>380&&x1<515)continue;
y1=y1+5,y2=y2+5;setcolor(WHITE);rectangle(x1,y1-5,x2,y2-5);break; /*down*/ case 19200:if(x1<65||x1==210&&y1>75&&y1<205||x1==515&&y1>75&&y1<205||x1==210&&y1>255&&y1<385||x1==515&&y1>255&&y1<385)continue;
x1=x1-5,x2=x2-5;setcolor(WHITE);rectangle(x1+5,y1,x2+5,y2);break; /*left*/ case 19712:if(x1>530||x1==75&&y1>75&&y1<205||x1==380&&y1>75&&y1<205||x1==75&&y1>255&&y1<385||x1==380&&y1>255&&y1<385)continue;
x1=x1+5,x2=x2+5;setcolor(WHITE);rectangle(x1-5,y1,x2-5,y2);break; /*right*/ case 283:exit(-1);break; /*exit*/
}
}
getch( );
closegraph( );
}


IP属地:云南1楼2013-07-04 15:31回复