diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dd08e0b044341f8882e45b1b0b4c13866eda01c4 --- /dev/null +++ b/main.cpp @@ -0,0 +1,156 @@ +#include +#include +#include +#include +using namespace std; +void over() +{ + system("cls"); + system("color A4"); + cout<<"你撑死了!"<>z; + if(z==1) + { + break; + } + else if(z==2) + { + system("pause"); + return 0; + } + else if(z==3) + { + system("start https://www.bilibili.com/video/BV1hq4y1s7VH/?"); + } + } + system("cls"); + system("color 09"); + for(int i=0; i<=25; i++) + puts(a[i]); + char ch; + int dmax=0; + int x=1,y=1; + while(1) + { + ch=_getch(); + //w上 a左 s下 d右 q放豆($) f放方块(#) + if(dmax==25) + { + break; + } + if(ch=='q') + { + a[x][y]='$'; + if(a[x][y-1]=='#') + y++; + else if(a[x+1][y]=='#') + x--; + else if(a[x-1][y]=='#') + x++; + else if(a[x][y+1]=='#') + y--; + else + x++; + a[x][y]='A'; + dmax++; + } + if(ch=='f') + { + a[x][y]='#'; + if(a[x][y-1]=='#') + y++; + else if(a[x+1][y]=='#') + x--; + else if(a[x-1][y]=='#') + x++; + else if(a[x][y+1]=='#') + y--; + else + x++; + a[x][y]='A'; + } + if(ch=='a') + { + if(a[x][y-1]!='#') + { + a[x][y]=' '; + y--;//往左 + a[x][y]='A'; + } + } + if(ch=='s') + { + if(a[x+1][y]!='#') + { + a[x][y]=' '; + x++;//往下 + a[x][y]='A'; + } + } + if(ch=='d') + { + if(a[x][y+1]!='#') + { + a[x][y]=' '; + y++;//往右 + a[x][y]='A'; + } + } + if(ch=='w') + { + if(a[x-1][y]!='#') + { + a[x][y]=' '; + x--;//往上 + a[x][y]='A'; + } + + } + system("cls"); + for(int i=0; i<=25; i++) + puts(a[i]); + } + over(); + return 0; +}