diff --git a/Greedy Snake.dev b/Greedy Snake.dev new file mode 100644 index 0000000..e717fa2 --- /dev/null +++ b/Greedy Snake.dev @@ -0,0 +1,72 @@ +[Project] +FileName=Greedy Snake.dev +Name=Greedy Snake +Type=1 +Ver=2 +ObjFiles= +Includes= +Libs= +PrivateResource=Greedy_Snake_private.rc +ResourceIncludes= +MakeIncludes= +Compiler= +CppCompiler= +Linker= +IsCpp=1 +Icon=Greedy Snake.ico +ExeOutput= +ObjectOutput= +LogOutput= +LogOutputEnabled=0 +OverrideOutput=0 +OverrideOutputName=Greedy Snake.exe +HostApplication= +UseCustomMakefile=0 +CustomMakefile= +CommandLine= +Folders= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=3 +CompilerSettings=0000000000000000000000000 +UnitCount=2 + +[VersionInfo] +Major=1 +Minor=0 +Release=0 +Build=0 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion=1.0.0.0 +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +AutoIncBuildNr=0 +SyncProduct=1 + +[Unit1] +FileName=main.cpp +CompileCpp=1 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=screen.h +CompileCpp=1 +Folder= +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/Greedy Snake.exe b/Greedy Snake.exe new file mode 100644 index 0000000..516d1b6 Binary files /dev/null and b/Greedy Snake.exe differ diff --git a/Greedy Snake.ico b/Greedy Snake.ico new file mode 100644 index 0000000..a453b98 Binary files /dev/null and b/Greedy Snake.ico differ diff --git a/Greedy Snake.layout b/Greedy Snake.layout new file mode 100644 index 0000000..d7149e3 --- /dev/null +++ b/Greedy Snake.layout @@ -0,0 +1,13 @@ +[Editors] +Order=0 +Focused=0 +[Editor_0] +CursorCol=26 +CursorRow=823 +TopLine=1 +LeftChar=1 +[Editor_1] +CursorCol=7 +CursorRow=107 +TopLine=28 +LeftChar=1 diff --git a/Greedy_Snake_private.h b/Greedy_Snake_private.h new file mode 100644 index 0000000..4ad210b --- /dev/null +++ b/Greedy_Snake_private.h @@ -0,0 +1,23 @@ +/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ +/* DO NOT EDIT ! */ + +#ifndef GREEDY_SNAKE_PRIVATE_H +#define GREEDY_SNAKE_PRIVATE_H + +/* VERSION DEFINITIONS */ +#define VER_STRING "1.0.0.0" +#define VER_MAJOR 1 +#define VER_MINOR 0 +#define VER_RELEASE 0 +#define VER_BUILD 0 +#define COMPANY_NAME "" +#define FILE_VERSION "1.0.0.0" +#define FILE_DESCRIPTION "Developed using the Dev-C++ IDE" +#define INTERNAL_NAME "" +#define LEGAL_COPYRIGHT "" +#define LEGAL_TRADEMARKS "" +#define ORIGINAL_FILENAME "" +#define PRODUCT_NAME "" +#define PRODUCT_VERSION "1.0.0.0" + +#endif /*GREEDY_SNAKE_PRIVATE_H*/ diff --git a/Greedy_Snake_private.rc b/Greedy_Snake_private.rc new file mode 100644 index 0000000..3f2b246 --- /dev/null +++ b/Greedy_Snake_private.rc @@ -0,0 +1,5 @@ +/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ +/* DO NOT EDIT! */ + + +A ICON "Greedy Snake.ico" diff --git a/Greedy_Snake_private.res b/Greedy_Snake_private.res new file mode 100644 index 0000000..a1481f4 Binary files /dev/null and b/Greedy_Snake_private.res differ diff --git a/Makefile.win b/Makefile.win new file mode 100644 index 0000000..1f4a2d9 --- /dev/null +++ b/Makefile.win @@ -0,0 +1,33 @@ +# Project: Greedy Snake +# Makefile created by Dev-C++ 5.11 + +CPP = g++.exe +CC = gcc.exe +WINDRES = windres.exe +RES = Greedy_Snake_private.res +OBJ = main.o $(RES) +LINKOBJ = main.o $(RES) +LIBS = -L"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib32" -static-libgcc +INCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" +CXXINCS = -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++" +BIN = "Greedy Snake.exe" +CXXFLAGS = $(CXXINCS) -Dlocal +CFLAGS = $(INCS) -Dlocal +RM = rm.exe -f + +.PHONY: all all-before all-after clean clean-custom + +all: all-before $(BIN) all-after + +clean: clean-custom + ${RM} $(OBJ) $(BIN) + +$(BIN): $(OBJ) + $(CPP) $(LINKOBJ) -o $(BIN) $(LIBS) + +main.o: main.cpp + $(CPP) -c main.cpp -o main.o $(CXXFLAGS) + +Greedy_Snake_private.res: Greedy_Snake_private.rc + $(WINDRES) -i Greedy_Snake_private.rc --input-format=rc -o Greedy_Snake_private.res -O coff + diff --git a/README.md b/README.md index f651cfd..ebaf2d3 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ -Greedy Snake +# Greedy Snake +这是一个c++写的控制台贪吃蛇游戏,由于年代太久远了~~其实也就1年~~作者也忘了怎么写得了。本项目放弃版权,欢迎fork走自行研究! \ No newline at end of file diff --git a/SetColor.png b/SetColor.png new file mode 100644 index 0000000..daa3ad9 Binary files /dev/null and b/SetColor.png differ diff --git a/Thumbs.db b/Thumbs.db new file mode 100644 index 0000000..8bd6b01 Binary files /dev/null and b/Thumbs.db differ diff --git a/files/1.txt b/files/1.txt new file mode 100644 index 0000000..6964dcf --- /dev/null +++ b/files/1.txt @@ -0,0 +1,22 @@ +0 0 0 0 0 0 0 0 0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+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 diff --git a/history/Greedy Snake v1.00.cpp b/history/Greedy Snake v1.00.cpp new file mode 100644 index 0000000..9fe9fdc --- /dev/null +++ b/history/Greedy Snake v1.00.cpp @@ -0,0 +1,683 @@ +//ע͡ ---dz +//ԴԴδ֪ +//ӹׯԣF +//v1.00 +#include +#include +#include +#include +#include "conio.h"//DZ׼⺯ + +using namespace std; + + +const int UP=72;// +const int DOWN=80;// +const int LEFT=75;// +const int RIGHT=77;// + +int n=4;//n¼,ʼΪ2 +int guan;//¼ؿ +int T;//¼ߵƶٶ +int t1,t2,t3=0;//¼ʱ +int HP=5;//¼ߵֵ,ʼΪ6 +int food=0;//¼Եʳ +int x=12,y=12;//¼ʳڵ + +struct snake +{ + int x;//ں + int y;// + int direction;//߷ +}p[81]; + + +struct map +{ + int food;//map[x][y]ǷʳеĻfoodΪ1 + int star;//map[x][y]ǷǵĻֵΪ1 + int barrier;//map[x][y]ǷϰеĻֵΪ1 +}map[26][22]; + + +inline void c(int k)//ıɫ +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), k); +} + +inline int time()//ʱ +{ + clock_t t=clock()/CLOCKS_PER_SEC;//¼ǰʱ + return t; +} + +inline void gotoxy(int x,int y) //ƶ +{ + COORD coord; + coord.X=x; + coord.Y=y; + SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord ); +} + +inline int random()//ֵ +{ + srand(t1+rand());//ӳʼ + return rand();// +} + +void ycgb(int);//ع +void start();//Լǽ +void guanka();//ѡؿݹؿߵƶٶ +void data();//¼Ϸĸ״̬ +int game();//Ϸ +void show();//ϰԼʳҩˮԼжϷĸֲСǷԵǷײǽ +void key();//ûǷ +void qp();//Ļ + + +void SetTitle(char *str) +{ + SetConsoleTitle(str); +} +int main() +{ + SetTitle("̰"); + ycgb(0);//ع + start();//Լǽ + while(1) + { + guanka();//ѡؿݹؿߵƶٶ + ycgb(0);//ع + if(!game()) break;//Ϸ + } +} + +void ycgb(int k)//ع +{ + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_CURSOR_INFO cci; + GetConsoleCursorInfo(hOut,&cci); + cci.bVisible=0;//1Ϊʾ0Ϊ + SetConsoleCursorInfo(hOut,&cci); +} + +void SetScreenSize(int x,int y) +{ + char str[50]; + sprintf(str,"mode con cols=%d lines=%d",x,y); + system(str); +} + +void start()//ǽ/Լǽ +{ + SetScreenSize(100,36); + int i,j,z; + for(i=0;i<25;i++) + { + cout<<" "; + } + c(14);//ɺɫ + for(z=0;z<20;z++) + { + if(z>=0) + { + gotoxy(12,z); + cout<<" ~--______-~ ~-___-~\" "; + } + if(z>=1) + { + gotoxy(12,z-1); + cout<<" ~-_ _-~ ~-_ _-~ "; + } + if(z>=2) + { + gotoxy(12,z-2); + cout<<" \\ ~-____-~ _-~ ~-_ ~-_-~ / "; + } + if(z>=3) + { + gotoxy(12,z-3); + cout<<" ( ( _-~ _--_ ~-_ _/ | "; + } + if(z>=4) + { + gotoxy(12,z-4); + cout<<" / / _-~ ~-_ | | "; + } + if(z>=5) + { + gotoxy(12,z-5); + cout<<" / / _----_ \\ \\ "; + } + if(z>=6) + { + gotoxy(12,z-6); + cout<<" / / \\ \\ "; + } + if(z>=7) + { + gotoxy(12,z-7); + cout<<" / / \\\\ "; + } + if(z>=8) + { + gotoxy(12,z-8); + cout<<" / / \\\\ "; + } + if(z>=9) + { + gotoxy(12,z-9); + cout<<" / / \\ "; + } + if(z>=10) + { + gotoxy(12,z-10); + cout<<" | | \\ "; + } + if(z>=11) + { + gotoxy(12,z-11); + cout<<" \\ \\ "; + } + if(z>=12) + { + gotoxy(12,z-12); + cout<<" \\_______ \\ "; + } + if(z>=13) + { + gotoxy(12,z-13); + cout<<" \\____|__________/ \\ "; + } + if(z>=14) + { + gotoxy(12,z-14); + cout<<"\\/ /~ \\_/ \\ "; + } + if(z>=15) + { + gotoxy(12,z-15); + cout<<" _|__| O| "; + } + for(int k=15;k20) + { + gotoxy(2*(j-21),0); + cout<<"";//һ + } + if(i<40) + { + gotoxy(2*i,23); + cout<<"";// һ + } + if(j>22&&j<45) + { + gotoxy(78,j-22); + cout<<"~";//ұ + } + if(j>22&&j<45) + { + gotoxy(0,i-15); + cout<<"~";//һ + } + if(i>37&&i<60) + { + gotoxy(54,i-37); + Sleep(10); + cout<<"~";//м + } + Sleep(30); + } + gotoxy(56,11); + cout<<""; //56 + gotoxy(19,0); + c(14);//ɫ + cout<<"| | |̰ | | |";// + + gotoxy(56,2); + cout<<"ʱ䣺"; + gotoxy(75,2); + cout<<""; + gotoxy(56,4); + cout<<"ֵ"; + gotoxy(56,6); + cout<<"ǰȣ"; + gotoxy(56,8); + cout<<"ѳʳ"; + gotoxy(56,10); + cout<<" "; + gotoxy(64,12); + cout<<"ʾ"; + gotoxy(56,13); + cout<<"ϣ ϣ"; + gotoxy(56,14); + cout<<"£ ң"; + gotoxy(56,15); + cout<<"ͣ/ʼȷ "; + gotoxy(56,16); + cout<<"ѡ Esc"; + gotoxy(64,18); + cout<<"ע⣡"; + gotoxy(56,19); + cout<<"1:ײϰǽ"; + gotoxy(56,20); + cout<<" ֵһ "; + gotoxy(56,21); + cout<<"2:ԵСֵһ"; +} +void guanka()//ѡؿݹؿߵƶٶ +{ + ycgb(1);//ʾ + n=4;//n¼,ʼΪ3 + HP=6;//¼ߵֵ,ʼΪ6 + p[0].x=6; // + p[0].y=10; // + p[0].direction=RIGHT; // + p[1].x=4; // + p[1].y=10; // ʼλúƶ + p[1].direction=RIGHT; // + p[2].x=2; // + p[2].y=10; // + p[2].direction=RIGHT; // + p[3].x=4;//////////////// + p[3].y=4;///////////////¼βϢ + p[3].direction=RIGHT;//// + while(1) + { + char t; + gotoxy(15,3); + cout<<"(1-6)"; + t=getch(); + guan=t-'0'; + if(guan==0) //жǷ + { + gotoxy(15,3); + c(12);//ɺɫ + cout<<" к̣"; + gotoxy(15,5); + c(14);//ɻɫ + cout<<"Ҫߵֵ"; + cin>>HP; + cin.get(); + gotoxy(15,3); + cout<<" "; + gotoxy(15,5); + cout<<" "; + continue;//ѡش + } + if(guan<7&&guan>0) break;//жϹǷ + gotoxy(15,5); + cout<<""; + gotoxy(32,3); + cout<<" "; + + } + gotoxy(15,3); + cout<<" "; + switch (guan) + { + case 1:{T=600;break;}// + case 2:{T=400;break;}// + case 3:{T=200;break;}// ݹ趨ߵƶٶ + case 4:{T=150;break;}// + case 5:{T=100;break;}// + case 6:{T=60;break;}// + } + qp();//Ļ +} +void data()//¼жϷĸ״̬ +{ + gotoxy(66,2); + c(12);//ɺɫ + cout<0&&t1%12==0&&t1>t3&&map[(p[0].x-1)/2][p[0].y-1].food==0&&map[(p[0].x-1)/2][p[0].y-1].star==0) + { + while(1) + { + e=random()%26;// + f=random()%22;// + if(map[e][f].food==0&&map[e][f].star==0) break;//˴ԪDzЧ + } + gotoxy(2*(e+1),f+1);//λϰֵλ + map[e][f].barrier=1;//ϰ + c(12);//ɻɫ + cout<<"~";//ӡϰ + t3=t1;//ϰ + if(HP<7) + { + gotoxy(18,24); + c(15);//ɰɫ + cout<<"ܰʾѡصʱ0Կģʽ"; + } + } + if(t1/25>0&&t1%15==0&&t1>t3&&map[(p[0].x-1)/2][p[0].y-1].food==0&&map[(p[0].x-1)/2][p[0].y-1].barrier==0)//dzֵļ + { + while(1) + { + a=random()%26;// + b=random()%22;// + if(map[a][b].barrier==0&&map[a][b].food==0) break;//˴ԪDzЧ + } + map[a][b].star=1;//СǣԵdzȼ1 + gotoxy(2*(a+1),b+1);//λdzֵλãԵdzȼ1 + c(14);//ɻɫ + cout<<"";//ӡǣԵdzȼ1 + t3=t1;//ϰ + if(HP<7) + { + gotoxy(18,24); + cout<<" "; + } + } + for(int i=0;i0;i--) p[i]=p[i-1];//ƶ + key();//ûǷ + switch (p[0].direction) + { + case UP:{p[0].y-=1;break;}//ıͷ꣬ƶͷ + case DOWN:{p[0].y+=1;break;}//ıͷ꣬ƶͷ + case LEFT:{p[0].x-=2;break;}//ıͷ꣬ƶͷ + case RIGHT:{p[0].x+=2;break;}//ıͷ꣬ƶͷ + } + if(p[0].x==0)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].x=52;//䴩ǽ + } + if(p[0].x==54)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].x=2;//䴩ǽ + } + if(p[0].y==0)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].y=22;//䴩ǽ + } + if(p[0].y==23)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].y=1;//䴩ǽ + } + for(i=1;i=n)//ײԼ + { + cout<<"\a"; + HP=0;// + } + if(map[(p[0].x-1)/2][p[0].y-1].barrier==1)//ϰʱ + { + cout<<"\a"; + --HP;//ֵһ + map[(p[0].x-1)/2][p[0].y-1].barrier=0; + } + if(HP==0) + { + gotoxy(25,5); + c(15);//ɰɫ + cout<<"\a\a\aϷ"; + Sleep(3000);//ʱ + return 1; + break; + } + if(n==56) + { + gotoxy(25,5); + c(15);//ɰɫ + cout<<"\a\a\aϲأ"; + Sleep(3000);//ʱ + return 1; + break; + } + show();//ϰԼʳҩˮԼжϷĸֲСǷԵǷײǽ) + } + return 0; +} diff --git a/history/Greedy Snake v1.10.cpp b/history/Greedy Snake v1.10.cpp new file mode 100644 index 0000000..06c9b5b --- /dev/null +++ b/history/Greedy Snake v1.10.cpp @@ -0,0 +1,750 @@ +/* + * Greedy Snake + * ԴԴδ֪ + * ע: dz + * ӹׯԣF + * v1.10 + * 1.¿һֺʱʾ + * 2.޸˲˵ + * 3.˲˵뷨 + * 4.ֵʾbug + */ +#include +#include +#include +#include +#include"conio.h"//DZ׼⺯ +using namespace std; + + +const int UP=72;// +const int DOWN=80;// +const int LEFT=75;// +const int RIGHT=77;// + +int n=4;//n¼,ʼΪ2 +int guan;//¼ؿ +int T;//¼ߵƶٶ +int t1,t2,t3=0;//¼ʱ +int HP=5;//¼ߵֵ,ʼΪ6 +int food=0;//¼Եʳ +int x=12,y=12;//¼ʳڵ + +struct snake +{ + int x;//ں + int y;// + int direction;//߷ +}p[81]; + + +struct map +{ + int food;//map[x][y]ǷʳеĻfoodΪ1 + int star;//map[x][y]ǷǵĻֵΪ1 + int barrier;//map[x][y]ǷϰеĻֵΪ1 +}map[26][22]; + +void SetColor(bool fred,bool fgreen,bool fblue,bool bred,bool bgreen,bool bblue) +{ + SetConsoleTextAttribute( + GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_INTENSITY + |FOREGROUND_RED*fred + |FOREGROUND_GREEN*fgreen + |FOREGROUND_BLUE*fblue + |BACKGROUND_RED*bred + |BACKGROUND_GREEN*bgreen + |BACKGROUND_BLUE*bblue + ); +} +inline void c(int k)//ıɫ +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), k); +} + +inline int time()//ʱ +{ + clock_t t=clock()/CLOCKS_PER_SEC;//¼ǰʱ + return t; +} + +inline void gotoxy(int x,int y) //ƶ +{ + COORD coord; + coord.X=x; + coord.Y=y; + SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord ); +} + +inline int random()//ֵ +{ + srand(t1+rand());//ӳʼ + return rand();// +} + +void ycgb(int);//ع +void start();//Լǽ +void guanka();//ѡؿݹؿߵƶٶ +void data();//¼Ϸĸ״̬ +int game();//Ϸ +void show();//ϰԼʳҩˮԼжϷĸֲСǷԵǷײǽ +void key();//ûǷ +void qp();//Ļ + + +void SetTitle(char *str) +{ + SetConsoleTitle(str); +} +int main() +{ + SetTitle("̰"); + ycgb(0);//ع + start();//Լǽ + while(1) + { + guanka();//ѡؿݹؿߵƶٶ + ycgb(0);//ع + if(!game()) break;//Ϸ + } +} + +void ycgb(int k)//ع +{ + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_CURSOR_INFO cci; + GetConsoleCursorInfo(hOut,&cci); + cci.bVisible=0;//1Ϊʾ0Ϊ + SetConsoleCursorInfo(hOut,&cci); +} + +void SetScreenSize(int x,int y) +{ + char str[50]; + sprintf(str,"mode con cols=%d lines=%d",x,y); + system(str); +} + +void start()//ǽ/Լǽ +{ + SetScreenSize(100,36); + int i,j,z; + for(i=0;i<25;i++) + { + cout<<" "; + } + c(14);//ɻɫ + for(z=0;z<20;z++) + { + if(z>=0) + { + gotoxy(12,z); + cout<<" ~--______-~ ~-___-~\" "; + } + if(z>=1) + { + gotoxy(12,z-1); + cout<<" ~-_ _-~ ~-_ _-~ "; + } + if(z>=2) + { + gotoxy(12,z-2); + cout<<" \\ ~-____-~ _-~ ~-_ ~-_-~ / "; + } + if(z>=3) + { + gotoxy(12,z-3); + cout<<" ( ( _-~ _--_ ~-_ _/ | "; + } + if(z>=4) + { + gotoxy(12,z-4); + cout<<" / / _-~ ~-_ | | "; + } + if(z>=5) + { + gotoxy(12,z-5); + cout<<" / / _----_ \\ \\ "; + } + if(z>=6) + { + gotoxy(12,z-6); + cout<<" / / \\ \\ "; + } + if(z>=7) + { + gotoxy(12,z-7); + cout<<" / / \\\\ "; + } + if(z>=8) + { + gotoxy(12,z-8); + cout<<" / / \\\\ "; + } + if(z>=9) + { + gotoxy(12,z-9); + cout<<" / / \\ "; + } + if(z>=10) + { + gotoxy(12,z-10); + cout<<" | | \\ "; + } + if(z>=11) + { + gotoxy(12,z-11); + cout<<" \\ \\ "; + } + if(z>=12) + { + gotoxy(12,z-12); + cout<<" \\_______ \\ "; + } + if(z>=13) + { + gotoxy(12,z-13); + cout<<" \\____|__________/ \\ "; + } + if(z>=14) + { + gotoxy(12,z-14); + cout<<"\\/ /~ \\_/ \\ "; + } + if(z>=15) + { + gotoxy(12,z-15); + cout<<" _|__| O| "; + } + for(int k=15;k20) + { + gotoxy(2*(j-21),0); + cout<<"";//һ + } + if(i<40) + { + gotoxy(2*i,23); + cout<<"";// һ + } + if(j>22&&j<45) + { + gotoxy(78,j-22); + cout<<"~";//ұ + } + if(j>22&&j<45) + { + gotoxy(0,i-15); + cout<<"~";//һ + } + if(i>37&&i<60) + { + gotoxy(54,i-37); + Sleep(10); + cout<<"~";//м + } + Sleep(30); + } + gotoxy(56,11); + cout<<""; //56 + gotoxy(19,0); + c(14);//ɫ + cout<<"| | |̰ | | |";// + + gotoxy(56,2); + cout<<"ʱ䣺"; + gotoxy(75,2); + cout<<""; + gotoxy(56,4); + cout<<"ֵ"; + gotoxy(56,6); + cout<<"ǰȣ"; + gotoxy(56,8); + cout<<"ѳʳ"; + gotoxy(56,10); + cout<<" "; + gotoxy(64,12); + cout<<"ʾ"; + gotoxy(56,13); + cout<<"ϣ ϣ"; + gotoxy(56,14); + cout<<"£ ң"; + gotoxy(56,15); + cout<<"ͣ/ʼȷ "; + gotoxy(56,16); + cout<<"ѡ Esc"; + gotoxy(64,18); + cout<<"ע⣡"; + gotoxy(56,19); + cout<<"1:ײϰǽ"; + gotoxy(56,20); + cout<<" ֵһ "; + gotoxy(56,21); + cout<<"2:ԵСֵһ"; +} +void guanka()//ѡؿݹؿߵƶٶ +{ + qp(); + ycgb(1);//ʾ + n=4;//n¼,ʼΪ3 + HP=6;//¼ߵֵ,ʼΪ6 + p[0].x=6; // + p[0].y=10; // + p[0].direction=RIGHT; // + p[1].x=4; // + p[1].y=10; // ʼλúƶ + p[1].direction=RIGHT; // + p[2].x=2; // + p[2].y=10; // + p[2].direction=RIGHT; // + p[3].x=4;//////////////// + p[3].y=4;///////////////¼βϢ + p[3].direction=RIGHT;//// + while(1) + { + char t; + gotoxy(15,3); + c(14); + cout<<"(1-6) "; + t=getch(); + guan=t-'0'; + if(guan==0) //жǷ + { + gotoxy(15,3); + c(12);//ɺɫ + cout<<" к̣"; + Sleep(500); + gotoxy(15,3); + cout<<" "; + HP=-1; + continue;//ѡش + } + if(guan<7&&guan>0) break;//жϹǷ + gotoxy(15,5); + cout<<""; + Sleep(800); + gotoxy(15,5); + cout<<" "; + } + gotoxy(15,3); + cout<<" "; + switch (guan) + { + case 1:{T=600;break;}// + case 2:{T=400;break;}// + case 3:{T=200;break;}// ݹ趨ߵƶٶ + case 4:{T=150;break;}// + case 5:{T=100;break;}// + case 6:{T=60;break;}// + } + qp();//Ļ +} +void data()//¼жϷĸ״̬ +{ + gotoxy(66,2); + cout<<" "; + gotoxy(66,2); + c(12);//ɺɫ + cout<0&&t1%12==0&&t1>t3&&map[(p[0].x-1)/2][p[0].y-1].food==0&&map[(p[0].x-1)/2][p[0].y-1].star==0) + { + while(1) + { + e=random()%26;// + f=random()%22;// + if(map[e][f].food==0&&map[e][f].star==0) break;//˴ԪDzЧ + } + gotoxy(2*(e+1),f+1);//λϰֵλ + map[e][f].barrier=1;//ϰ + c(12);//ɻɫ + cout<<"~";//ӡϰ + t3=t1;//ϰ + if(HP<7) + { + gotoxy(18,24); + c(15);//ɰɫ + cout<<"ܰʾѡصʱ0Կģʽ"; + } + } + if(t1/25>0&&t1%15==0&&t1>t3&&map[(p[0].x-1)/2][p[0].y-1].food==0&&map[(p[0].x-1)/2][p[0].y-1].barrier==0)//dzֵļ + { + while(1) + { + a=random()%26;// + b=random()%22;// + if(map[a][b].barrier==0&&map[a][b].food==0) break;//˴ԪDzЧ + } + map[a][b].star=1;//СǣԵdzȼ1 + gotoxy(2*(a+1),b+1);//λdzֵλãԵdzȼ1 + c(14);//ɻɫ + cout<<"";//ӡǣԵdzȼ1 + t3=t1;//ϰ + if(HP<7) + { + gotoxy(18,24); + cout<<" "; + } + } + for(int i=0;i0;i--) p[i]=p[i-1];//ƶ + key();//ûǷ + switch (p[0].direction) + { + case UP:{p[0].y-=1;break;}//ıͷ꣬ƶͷ + case DOWN:{p[0].y+=1;break;}//ıͷ꣬ƶͷ + case LEFT:{p[0].x-=2;break;}//ıͷ꣬ƶͷ + case RIGHT:{p[0].x+=2;break;}//ıͷ꣬ƶͷ + } + if(p[0].x==0)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].x=52;//䴩ǽ + } + if(p[0].x==54)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].x=2;//䴩ǽ + } + if(p[0].y==0)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].y=22;//䴩ǽ + } + if(p[0].y==23)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].y=1;//䴩ǽ + } + for(i=1;i=n)//ײԼ + { + cout<<"\a"; + HP=0;// + } + if(map[(p[0].x-1)/2][p[0].y-1].barrier==1)//ϰʱ + { + cout<<"\a"; + --HP;//ֵһ + map[(p[0].x-1)/2][p[0].y-1].barrier=0; + } + if(HP==0) + { + gotoxy(65,4); + c(12);//ɺɫ + cout<<"xyz|}~"; + gotoxy(23,3); + c(9); + cout<<""; + gotoxy(23,4); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,5); + c(9);cout<<"";c(11);cout<<""; + c(12);cout<<""; + c(15);//ɰɫ + cout<<"Ϸ"; + c(11);cout<<"";c(9);cout<<""; + gotoxy(23,6); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,7); + c(9); + cout<<""; + Sleep(3000);//ʱ + gotoxy(25,5); + return 1; + break; + } + if(n==50) + { + gotoxy(23,3); + c(9); + cout<<""; + gotoxy(23,4); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,5); + c(9);cout<<"";c(11);cout<<""; + c(15);//ɰɫ + cout<<"ϲأ"; + c(11);cout<<"";c(9);cout<<""; + gotoxy(23,6); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,7); + c(9); + cout<<""; + Sleep(3000);//ʱ + gotoxy(25,5); + return 1; + break; + } + show();//ϰԼʳҩˮԼжϷĸֲСǷԵǷײǽ) + } + return 0; +} diff --git a/history/Greedy Snake v1.20.cpp b/history/Greedy Snake v1.20.cpp new file mode 100644 index 0000000..60ddb7d --- /dev/null +++ b/history/Greedy Snake v1.20.cpp @@ -0,0 +1,739 @@ +/* + * Greedy Snake + * ԴԴδ֪ + * ע: dz + * ӹׯԣF + * v1.10 + * 1.¿һֺʱʾ + * 2.޸˲˵ + * 3.˲˵뷨 + * 4.ֵʾbug + * v1.20 + * 1.ȫע + * 2.Ż˳ + */ +#include +#include +#include +#include +#include"conio.h"//DZ׼⺯ +using namespace std; + + +const int UP=72;// +const int DOWN=80;// +const int LEFT=75;// +const int RIGHT=77;// + +int n=4;//n¼,ʼΪ2 +int guan;//¼ؿ +int T;//¼ߵƶٶ +int t1,t2,t3=0;//¼ʱ +int HP=5;//¼ߵֵ,ʼΪ6 +int food=0;//¼Եʳ +int x=12,y=12;//¼ʳڵ + +struct snake +{ + int x;//ں + int y;// + int direction;//߷ +}p[81]; + + +struct map +{ + int food;//map[x][y]ǷʳеĻfoodΪ1 + int star;//map[x][y]ǷǵĻֵΪ1 + int barrier;//map[x][y]ǷϰеĻֵΪ1 +}map[26][22]; + +inline void c(int k)//ıɫ +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), k); +} + +inline int time()//ʱ +{ + return clock()/CLOCKS_PER_SEC; +} + +inline void gotoxy(int x,int y) //ƶ +{ + static COORD coord; + coord.X=x; + coord.Y=y; + SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), coord ); +} + +inline int random()//ֵ +{ + srand(t1+rand());//ӳʼ + return rand();// +} + +void ycgb();//ع +void start();//Լǽ +void guanka();//ѡؿݹؿߵƶٶ +void data();//¼Ϸĸ״̬ +int game();//Ϸ +void show();//ϰԼʳҩˮԼжϷĸֲСǷԵǷײǽ +void key();//û +void qp();//Ļ + + +inline void SetTitle(char *str) +{ + SetConsoleTitle(str); +} +int main() +{ + SetTitle("̰"); + ycgb();//ع + start();//Լǽ + while(1) + { + guanka();//ѡؿݹؿߵƶٶ + if(!game()) break;//Ϸ + } +} + +inline void ycgb()//ع +{ + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_CURSOR_INFO cci; + GetConsoleCursorInfo(hOut,&cci); + cci.bVisible=0;//1Ϊʾ0Ϊ + SetConsoleCursorInfo(hOut,&cci); +} + +inline void SetScreenSize(int x,int y) +{ + char str[50]; + sprintf(str,"mode con cols=%d lines=%d",x,y); + system(str); +} + +inline void start()//ǽ/Լǽ +{ + SetScreenSize(100,36); + int i,j,z; + for(i=0;i<25;i++) + { + cout<<" "; + } + c(14);//ɻɫ + for(z=0;z<20;z++) + { + if(z>=0) + { + gotoxy(12,z); + cout<<" ~--______-~ ~-___-~\" "; + } + if(z>=1) + { + gotoxy(12,z-1); + cout<<" ~-_ _-~ ~-_ _-~ "; + } + if(z>=2) + { + gotoxy(12,z-2); + cout<<" \\ ~-____-~ _-~ ~-_ ~-_-~ / "; + } + if(z>=3) + { + gotoxy(12,z-3); + cout<<" ( ( _-~ _--_ ~-_ _/ | "; + } + if(z>=4) + { + gotoxy(12,z-4); + cout<<" / / _-~ ~-_ | | "; + } + if(z>=5) + { + gotoxy(12,z-5); + cout<<" / / _----_ \\ \\ "; + } + if(z>=6) + { + gotoxy(12,z-6); + cout<<" / / \\ \\ "; + } + if(z>=7) + { + gotoxy(12,z-7); + cout<<" / / \\\\ "; + } + if(z>=8) + { + gotoxy(12,z-8); + cout<<" / / \\\\ "; + } + if(z>=9) + { + gotoxy(12,z-9); + cout<<" / / \\ "; + } + if(z>=10) + { + gotoxy(12,z-10); + cout<<" | | \\ "; + } + if(z>=11) + { + gotoxy(12,z-11); + cout<<" \\ \\ "; + } + if(z>=12) + { + gotoxy(12,z-12); + cout<<" \\_______ \\ "; + } + if(z>=13) + { + gotoxy(12,z-13); + cout<<" \\____|__________/ \\ "; + } + if(z>=14) + { + gotoxy(12,z-14); + cout<<"\\/ /~ \\_/ \\ "; + } + if(z>=15) + { + gotoxy(12,z-15); + cout<<" _|__| O| "; + } + for(int k=15;k20) + { + gotoxy(2*(j-21),0); + cout<<"";//һ + } + if(i<40) + { + gotoxy(2*i,23); + cout<<"";// һ + } + if(j>22&&j<45) + { + gotoxy(78,j-22); + cout<<"~";//ұ + } + if(j>22&&j<45) + { + gotoxy(0,i-15); + cout<<"~";//һ + } + if(i>37&&i<60) + { + gotoxy(54,i-37); + Sleep(10); + cout<<"~";//м + } + Sleep(30); + } + gotoxy(56,11); + cout<<""; //56 + gotoxy(19,0); + c(14);//ɫ + cout<<"| | |̰ | | |";// + + gotoxy(56,2); + cout<<"ʱ䣺"; + gotoxy(75,2); + cout<<""; + gotoxy(56,4); + cout<<"ֵ"; + gotoxy(56,6); + cout<<"ǰȣ"; + gotoxy(56,8); + cout<<"ѳʳ"; + gotoxy(56,10); + cout<<" "; + gotoxy(64,12); + cout<<"ʾ"; + gotoxy(56,13); + cout<<"ϣ ϣ"; + gotoxy(56,14); + cout<<"£ ң"; + gotoxy(56,15); + cout<<"ͣ/ʼȷ "; + gotoxy(56,16); + cout<<"ѡ Esc"; + gotoxy(64,18); + cout<<"ע⣡"; + gotoxy(56,19); + cout<<"1:ײϰǽ"; + gotoxy(56,20); + cout<<" ֵһ "; + gotoxy(56,21); + cout<<"2:ԵСֵһ"; +} +inline void guanka()//ѡؿݹؿߵƶٶ +{ + qp(); + n=4;//n¼,ʼΪ3 + HP=6;//¼ߵֵ,ʼΪ6 + p[0].x=6; // + p[0].y=10; // + p[0].direction=RIGHT; // + p[1].x=4; // + p[1].y=10; // ʼλúƶ + p[1].direction=RIGHT; // + p[2].x=2; // + p[2].y=10; // + p[2].direction=RIGHT; // + p[3].x=4;//////////////// + p[3].y=4;///////////////¼βϢ + p[3].direction=RIGHT;//// + static char t; + while(1) + { + gotoxy(15,3); + c(14); + cout<<"(1-6) "; + t=getch(); + guan=t-'0'; + if(guan==0) //жǷ + { + gotoxy(15,3); + c(12);//ɺɫ + cout<<" к̣"; + Sleep(500); + gotoxy(15,3); + cout<<" "; + HP=-1; + continue;//ѡش + } + if(guan<7&&guan>0) break;//жϹǷ + gotoxy(15,5); + cout<<""; + Sleep(800); + gotoxy(15,5); + cout<<" "; + } + gotoxy(15,3); + cout<<" "; + switch (guan) + { + case 1:{T=600;break;}// + case 2:{T=400;break;}// + case 3:{T=200;break;}// ݹ趨ߵƶٶ + case 4:{T=150;break;}// + case 5:{T=100;break;}// + case 6:{T=60;break;}// + } + qp();//Ļ +} +inline void data()//¼жϷĸ״̬ +{ + gotoxy(66,2); + cout<<" "; + gotoxy(66,2); + c(12);//ɺɫ + cout<0&&t1%12==0&&t1>t3&&map[(p[0].x-1)/2][p[0].y-1].food==0&&map[(p[0].x-1)/2][p[0].y-1].star==0) + { + while(1) + { + e=random()%26;// + f=random()%22;// + if(map[e][f].food==0&&map[e][f].star==0) break;//˴ԪDzЧ + } + gotoxy(2*(e+1),f+1);//λϰֵλ + map[e][f].barrier=1;//ϰ + c(12);//ɻɫ + cout<<"~";//ӡϰ + t3=t1;//ϰ + if(HP<7) + { + gotoxy(18,24); + c(15);//ɰɫ + cout<<"ܰʾѡصʱ0Կģʽ"; + } + } + if(t1/25>0&&t1%15==0&&t1>t3&&map[(p[0].x-1)/2][p[0].y-1].food==0&&map[(p[0].x-1)/2][p[0].y-1].barrier==0)//dzֵļ + { + while(1) + { + a=random()%26;// + b=random()%22;// + if(map[a][b].barrier==0&&map[a][b].food==0) break;//˴ԪDzЧ + } + map[a][b].star=1;//СǣԵdzȼ1 + gotoxy(2*(a+1),b+1);//λdzֵλãԵdzȼ1 + c(14);//ɻɫ + cout<<"";//ӡǣԵdzȼ1 + t3=t1;//ϰ + if(HP<7) + { + gotoxy(18,24); + cout<<" "; + } + } + for(i=0;i0;i--) p[i]=p[i-1];//ƶ + key();//ûǷ + switch (p[0].direction) + { + case UP:{p[0].y-=1;break;}//ıͷ꣬ƶͷ + case DOWN:{p[0].y+=1;break;}//ıͷ꣬ƶͷ + case LEFT:{p[0].x-=2;break;}//ıͷ꣬ƶͷ + case RIGHT:{p[0].x+=2;break;}//ıͷ꣬ƶͷ + } + if(p[0].x==0)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].x=52;//䴩ǽ + } + if(p[0].x==54)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].x=2;//䴩ǽ + } + if(p[0].y==0)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].y=22;//䴩ǽ + } + if(p[0].y==23)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].y=1;//䴩ǽ + } + for(i=1;i=n)//ײԼ + { + cout<<"\a"; + HP=0;// + } + if(map[(p[0].x-1)/2][p[0].y-1].barrier==1)//ϰʱ + { + cout<<"\a"; + --HP;//ֵһ + map[(p[0].x-1)/2][p[0].y-1].barrier=0; + } + if(HP==0) + { + gotoxy(65,4); + c(12);//ɺɫ + cout<<"xyz|}~";//ˢֵ + gotoxy(23,3); + c(9); + cout<<""; + gotoxy(23,4); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,5); + c(9);cout<<"";c(11);cout<<""; + c(12);cout<<""; + c(15);//ɰɫ + cout<<"Ϸ"; + c(11);cout<<"";c(9);cout<<""; + gotoxy(23,6); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,7); + c(9); + cout<<""; + Sleep(3000);//ʱ + gotoxy(25,5); + return 1; + break; + } + if(n==50) + { + gotoxy(23,3); + c(9); + cout<<""; + gotoxy(23,4); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,5); + c(9);cout<<"";c(11);cout<<""; + c(15);//ɰɫ + cout<<"ϲأ"; + c(11);cout<<"";c(9);cout<<""; + gotoxy(23,6); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,7); + c(9); + cout<<""; + Sleep(3000);//ʱ + gotoxy(25,5); + return 1; + break; + } + show();//ϰԼʳҩˮԼжϷĸֲСǷԵǷײǽ) + } + return 0; +} diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..25e4c91 --- /dev/null +++ b/main.cpp @@ -0,0 +1,841 @@ +/* + * Greedy Snake + * ԴԴδ֪ + * ע: dz + * ӹׯԣF + * v1.10 + * 1.¿һֺʱʾ + * 2.޸˲˵ + * 3.˲˵뷨 + * 4.ֵʾbug + * v1.20 + * 1.ȫע + * 2.Ż˳ + * v1.30 + * 1.˵ȴ + * v2.00 + * 1.ѡء־ + */ +#include +#include +#include +#include +#include//DZ׼⺯ +#include +#include +#include"screen.h" +using namespace std; + +inline int min(int a,int b){return a score; + +struct screen_information +{ + int food;//screen_information[x][y]ǷʳеĻfoodΪ1 + int star;//screen_information[x][y]ǷǵĻֵΪ1 + int barrier;//screen_information[x][y]ǷϰеĻֵΪ1 +}screen_information[26][22]; + +inline void c(int k)//ıɫ +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), k); +} + +inline int time()//ʱ +{ + return clock()/CLOCKS_PER_SEC; +} + +inline int random()//ֵ +{ + srand(t1+rand());//ӳʼ + return rand();// +} + +void start();//Լǽ +void guanka();//ѡؿݹؿߵƶٶ +void data();//¼Ϸĸ״̬ +int game();//Ϸ +void show();//ϰԼʳҩˮԼжϷĸֲСǷԵǷײǽ +void key();//û +void qp();//Ļ +int input();//ѡҳ +void load_file(int id)//ļؿ +{ + n=4;//n¼,ʼΪ3 + if(HP!=-1) HP=6;//¼ߵֵ,ʼΪ6 + p[0].x=6; // + p[0].y=11; // + p[0].direction=RIGHT; // + p[1].x=4; // + p[1].y=11; // ʼλúƶ + p[1].direction=RIGHT; // + p[2].x=2; // + p[2].y=11; // + p[2].direction=RIGHT; // + char add[30]; + sprintf(add,"files/%d.txt",id); + FILE *f=fopen(add,"r"); + static int t; + for(int i=0;i<22;i++) + for(int j=0;j<26;j++) + { + fscanf(f,"%d",&t); + switch(t) + { + case 1:screen_information[j][i].barrier=1; + gotoxy(2*(j+1),i+1); + SetColor(12);cout<<""; + break; + case 2:screen_information[j][i].food=1; + gotoxy(2*(j+1),i+1); + SetColor(11);cout<<""; + break; + case 3:screen_information[j][i].star=1; + gotoxy(2*(j+1),i+1); + SetColor(14);cout<<""; + break; + } + } + shb=score[id].shb; + fclose(f); +} + +int main() +{ + SetLetter(936); + SetTitle("̰"); + hm();//ع + start();//Լǽ + while(1) + { + guanka();//ѡؿݹؿߵƶٶ + game();//Ϸ + score[gid].now=n; + if(n==score[gid].shb) + { + if(gid+1=0) + { + gotoxy(12,z); + cout<<" ~--______-~ ~-___-~\" "; + } + if(z>=1) + { + gotoxy(12,z-1); + cout<<" ~-_ _-~ ~-_ _-~ "; + } + if(z>=2) + { + gotoxy(12,z-2); + cout<<" \\ ~-____-~ _-~ ~-_ ~-_-~ / "; + } + if(z>=3) + { + gotoxy(12,z-3); + cout<<" ( ( _-~ _--_ ~-_ _/ | "; + } + if(z>=4) + { + gotoxy(12,z-4); + cout<<" / / _-~ ~-_ | | "; + } + if(z>=5) + { + gotoxy(12,z-5); + cout<<" / / _----_ \\ \\ "; + } + if(z>=6) + { + gotoxy(12,z-6); + cout<<" / / \\ \\ "; + } + if(z>=7) + { + gotoxy(12,z-7); + cout<<" / / \\\\ "; + } + if(z>=8) + { + gotoxy(12,z-8); + cout<<" / / \\\\ "; + } + if(z>=9) + { + gotoxy(12,z-9); + cout<<" / / \\ "; + } + if(z>=10) + { + gotoxy(12,z-10); + cout<<" | | \\ "; + } + if(z>=11) + { + gotoxy(12,z-11); + cout<<" \\ \\ "; + } + if(z>=12) + { + gotoxy(12,z-12); + cout<<" \\_______ \\ "; + } + if(z>=13) + { + gotoxy(12,z-13); + cout<<" \\____|__________/ \\ "; + } + if(z>=14) + { + gotoxy(12,z-14); + cout<<"\\/ /~ \\_/ \\ "; + } + if(z>=15) + { + gotoxy(12,z-15); + cout<<" _|__| O| "; + } + for(int k=15;k20) + { + gotoxy(2*(j-21),0); + cout<<"";//һ + } + if(i<40) + { + gotoxy(2*i,23); + cout<<"";// һ + } + if(j>22&&j<45) + { + gotoxy(78,j-22); + cout<<"~";//ұ + } + if(j>22&&j<45) + { + gotoxy(0,i-15); + cout<<"~";//һ + } + if(i>37&&i<60) + { + gotoxy(54,i-37); + Sleep(10*wait); + cout<<"~";//м + } + Sleep(30*wait); + } + gotoxy(56,11); + cout<<""; //56 + gotoxy(19,0); + c(14);//ɫ + cout<<"| | |̰ | | |";// + + gotoxy(56,2); + cout<<"ʱ䣺"; + gotoxy(75,2); + cout<<""; + gotoxy(56,4); + cout<<"ֵ"; + gotoxy(56,6); + cout<<"ǰȣ"; + gotoxy(56,8); + cout<<"ѳʳ"; + gotoxy(56,10); + cout<<" "; + gotoxy(64,12); + cout<<"ʾ"; + gotoxy(56,13); + cout<<"ϣ ϣ"; + gotoxy(56,14); + cout<<"£ ң"; + gotoxy(56,15); + cout<<"ͣ/ʼȷ "; + gotoxy(56,16); + cout<<"ѡ Esc"; + gotoxy(64,18); + cout<<"ע⣡"; + gotoxy(56,19); + cout<<"1:ײϰǽ"; + gotoxy(56,20); + cout<<" ֵһ "; + gotoxy(56,21); + cout<<"2:ԵСֵһ"; +} +int input() +{ + vector can; + FILE *f=fopen("snake.his","r"); + int n,now,a,b,c,passed=0; + fscanf(f,"%d",&n); + maxg=n; + for(int i=0;i=0&&c=b) passed++; + } + if(passed==n) + { + gotoxy(2,24); + SetColor(14); + printf("ͨйؿ\n"); + printf("http://download.csdn.net/download/alphago_zero/10223607عؿ\n"); + printf("ӣ[Y/N] "); + char c=getch(); + if(c=='y'||c=='Y') + { + system("start http://download.csdn.net/download/alphago_zero/10223607"); + while(1); + } + else exit(0); + } + int now_page=0,i; + now=0; + SetColor(10); + gotoxy(2,24);//+25 + cout<<"ѡ"; + for(i=0;i<5&&now_page*5+i0) + { + now--; + now_page=now/5; + } + break; + case DOWN: + if(now=5) + { + now-=5; + now_page=now/5; + } + break; + case RIGHT: + if(now0) break;//жٶǷ + gotoxy(15,5); + cout<<""; + Sleep(800); + gotoxy(15,5); + cout<<" "; + } + gotoxy(15,3); + cout<<" "; + switch(guan) + { + case 1:{T=600;break;}// + case 2:{T=400;break;}// + case 3:{T=200;break;}// ٶ趨ߵƶٶ + case 4:{T=150;break;}// + case 5:{T=100;break;}// + case 6:{T=60;break;}// + } + qp();//Ļ + load_file(input()); +} +inline void data()//¼жϷĸ״̬ +{ + gotoxy(66,2); + cout<<" "; + gotoxy(66,2); + c(12);//ɺɫ + cout<0&&t1%12==0&&t1>t3&&screen_information[(p[0].x-1)/2][p[0].y-1].food==0&&screen_information[(p[0].x-1)/2][p[0].y-1].star==0) + { + while(1) + { + e=random()%26;// + f=random()%22;// + if(screen_information[e][f].food==0&&screen_information[e][f].star==0) break;//˴ԪDzЧ + } + gotoxy(2*(e+1),f+1);//λϰֵλ + screen_information[e][f].barrier=1;//ϰ + c(12);//ɻɫ + cout<<"~";//ӡϰ + t3=t1;//ϰ + if(HP<7) + { + gotoxy(18,24); + c(15);//ɰɫ + cout<<"ܰʾѡٶȵʱ0Կģʽ"; + } + } + if(t1/25>0&&t1%15==0&&t1>t3&&screen_information[(p[0].x-1)/2][p[0].y-1].food==0&&screen_information[(p[0].x-1)/2][p[0].y-1].barrier==0)//dzֵļ + { + while(1) + { + a=random()%26;// + b=random()%22;// + if(screen_information[a][b].barrier==0&&screen_information[a][b].food==0) break;//˴ԪDzЧ + } + screen_information[a][b].star=1;//СǣԵdzȼ1 + gotoxy(2*(a+1),b+1);//λdzֵλãԵdzȼ1 + c(14);//ɻɫ + cout<<"";//ӡǣԵdzȼ1 + t3=t1;//ϰ + if(HP<7) + { + gotoxy(18,24); + cout<<" "; + } + } + for(i=0;i0;i--) p[i]=p[i-1];//ƶ + key();//ûǷ + switch (p[0].direction) + { + case UP:{p[0].y-=1;break;}//ıͷ꣬ƶͷ + case DOWN:{p[0].y+=1;break;}//ıͷ꣬ƶͷ + case LEFT:{p[0].x-=2;break;}//ıͷ꣬ƶͷ + case RIGHT:{p[0].x+=2;break;}//ıͷ꣬ƶͷ + } + if(p[0].x==0)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].x=52;//䴩ǽ + } + if(p[0].x==54)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].x=2;//䴩ǽ + } + if(p[0].y==0)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].y=22;//䴩ǽ + } + if(p[0].y==23)//ײǽʱ + { + cout<<"\a"; + --HP;//ֵһ + p[0].y=1;//䴩ǽ + } + for(i=1;i=n)//ײԼ + { + cout<<"\a"; + HP=0;// + } + if(screen_information[(p[0].x-1)/2][p[0].y-1].barrier==1)//ϰʱ + { + cout<<"\a"; + --HP;//ֵһ + screen_information[(p[0].x-1)/2][p[0].y-1].barrier=0; + } + if(HP==0) + { + gotoxy(65,4); + c(12);//ɺɫ + cout<<"xyz|}~";//ˢֵ + gotoxy(23,3); + c(9); + cout<<""; + gotoxy(23,4); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,5); + c(9);cout<<"";c(11);cout<<""; + c(12);cout<<""; + c(15);//ɰɫ + cout<<"Ϸ"; + c(11);cout<<"";c(9);cout<<""; + gotoxy(23,6); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,7); + c(9); + cout<<""; + Sleep(3000);//ʱ + gotoxy(25,5); + return 1; + } + if(n==shb) + { + gotoxy(23,3); + c(9); + cout<<""; + gotoxy(23,4); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,5); + c(9);cout<<"";c(11);cout<<""; + c(15);//ɰɫ + cout<<"ϲأ"; + c(11);cout<<"";c(9);cout<<""; + gotoxy(23,6); + c(9); + cout<<""; + c(11); + cout<<""; + c(9); + cout<<""; + gotoxy(23,7); + c(9); + cout<<""; + Sleep(3000);//ʱ + gotoxy(25,5); + return 1; + } + show();//ϰԼʳҩˮԼжϷĸֲСǷԵǷײǽ) + } + return 0; +} diff --git a/main.o b/main.o new file mode 100644 index 0000000..0000454 Binary files /dev/null and b/main.o differ diff --git a/screen.h b/screen.h new file mode 100644 index 0000000..8654161 --- /dev/null +++ b/screen.h @@ -0,0 +1,107 @@ +#ifndef SCREEN +#define SCREEN +#include +#include +#include +inline void SetLetter(int n) +{ + SetConsoleOutputCP(n); +} +HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); +HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE); +CONSOLE_SCREEN_BUFFER_INFO bInfo; + INPUT_RECORD mouseRec; + DWORD res; + COORD crPos, crHome = {0, 0}; +void gotoxy(int x,int y) +{ + COORD c; + c.X=x; + c.Y=y; + SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c); +} +void SetScreenSize(int x,int y) +{ + char str[50]; + sprintf(str,"mode con cols=%d lines=%d",x,y); + system(str); +} +void SetColor(int c) +{ + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c); +} +void SetColor(bool fred,bool fgreen,bool fblue,bool bred,bool bgreen,bool bblue) +{ + SetConsoleTextAttribute( + GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_INTENSITY + |FOREGROUND_RED*fred + |FOREGROUND_GREEN*fgreen + |FOREGROUND_BLUE*fblue + |BACKGROUND_RED*bred + |BACKGROUND_GREEN*bgreen + |BACKGROUND_BLUE*bblue + ); +} +void SetTitle(char *str) +{ + SetConsoleTitle(str); +} +//keyhited:kbhit() + +bool double_click() +{ + ReadConsoleInput(hIn, &mouseRec, 1, &res); + return ( + mouseRec.EventType == MOUSE_EVENT + &&mouseRec.Event.MouseEvent.dwButtonState==FROM_LEFT_1ST_BUTTON_PRESSED + &&mouseRec.Event.MouseEvent.dwEventFlags == DOUBLE_CLICK); +} +bool left_click() +{ + return ( + mouseRec.EventType == MOUSE_EVENT + &&mouseRec.Event.MouseEvent.dwButtonState==FROM_LEFT_1ST_BUTTON_PRESSED); +} +bool right_click() +{ + return ( + mouseRec.EventType == MOUSE_EVENT + &&mouseRec.Event.MouseEvent.dwButtonState==RIGHTMOST_BUTTON_PRESSED); +} +int mpX() +{ + ReadConsoleInput(hIn, &mouseRec, 1, &res); + crPos = mouseRec.Event.MouseEvent.dwMousePosition; + GetConsoleScreenBufferInfo(hOut, &bInfo); + return crPos.X; +} +int mpY() +{ + ReadConsoleInput(hIn, &mouseRec, 1, &res); + crPos = mouseRec.Event.MouseEvent.dwMousePosition; + GetConsoleScreenBufferInfo(hOut, &bInfo); + return crPos.Y; +} +void finish_handle() +{ + CloseHandle(hOut); + CloseHandle(hIn); +} +void hm() +{ + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_CURSOR_INFO cci; + GetConsoleCursorInfo(hOut,&cci); + cci.bVisible=0;//1Ϊʾ0Ϊ + SetConsoleCursorInfo(hOut,&cci); +} +void sm() +{ + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_CURSOR_INFO cci; + GetConsoleCursorInfo(hOut,&cci); + cci.bVisible=1;//1Ϊʾ0Ϊ + SetConsoleCursorInfo(hOut,&cci); +} +#endif diff --git a/snake.his b/snake.his new file mode 100644 index 0000000..ee3ddf5 --- /dev/null +++ b/snake.his @@ -0,0 +1,11 @@ +10 +1 15 0 +2 16 -1 +3 17 -1 +4 16 -1 +5 19 -1 +6 20 -1 +7 25 -1 +8 25 -1 +9 25 -1 +10 35 -1 diff --git a/关卡生成器.cpp b/关卡生成器.cpp new file mode 100644 index 0000000..fa208b4 --- /dev/null +++ b/关卡生成器.cpp @@ -0,0 +1,63 @@ +#include +#include"screen.h" +int a[26][22]; +/* +1 wall +2 food +3 star +*/ +int main() +{ + int now=1,x,y; + char add[30],str[30]; + a[0][10]=-1; + a[1][10]=-1; + a[2][10]=-1; + scanf("%s",str); + sprintf(add,"files/%s.txt",str); + gotoxy(0,0); + printf("[Cursor Position] X: %2lu Y: %2lu \n", 0, 0); + hm(); + while(1) + { + gotoxy(0,0); + SetColor(15); + printf("[Cursor Position] X: %2lu Y: %2lu \n",mpX(),mpY()-1); + if(double_click()) + { + if(mpY()==0) break; + now++; + if(now==4) now=1; + } + if(left_click()) + { + x=mpX();y=mpY(); + if(x/2<0||x/2>=26||y-1<0||y-1>=22) goto end; + if(a[x/2][y-1]==-1) goto end; + a[x/2][y-1]=now; + gotoxy(x/2*2,y); + switch(now) + { + case 1:SetColor(12);printf("");break; + case 2:SetColor(11);printf("");break; + case 3:SetColor(14);printf("");break; + } + } + if(right_click()) + { + x=mpX();y=mpY(); + if(x/2<0||x/2>=26||y-1<0||y-1>=22) goto end; + a[x/2][y-1]=0; + gotoxy(x/2*2,y); + printf(" "); + } + end:; + } + FILE *f=fopen(add,"w"); + for(int i=0;i<22;i++) + { + for(int j=0;j<26;j++) fprintf(f,"%d ",a[j][i]); + fprintf(f,"\n"); + } + return 0; +} diff --git a/关卡生成器.exe b/关卡生成器.exe new file mode 100644 index 0000000..936f68b Binary files /dev/null and b/关卡生成器.exe differ