-
个人简介
只有适合自己的 才是最好的
附赠腐朽代码
本人不玩//打怪游戏 #include<iostream> using namespace std; unsigned long long shengmingli=2000,gongjili=150,fangyuli=200,money=1e9; bool guoguan; void wuqidian(),yaodian(),guaiwu1(),guaiwu2(); int main(){ cout<<"欢迎你开始玩打怪物小游戏!\n小镇\n一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店和一家武器店。\n1.去武器店\n2.去药品店\n3.去打小怪物\n4.去打大怪物\n5.退出游戏\n6.显示你的状态\n\n"; int xiaozhen; cin>>xiaozhen; while(xiaozhen!=5){ if(shengmingli<=0){ cout<<"你死啦!"<<endl; return 0; } if(guoguan){ cout<<"恭喜通关!"<<endl; return 0; } if(xiaozhen==6){ cout<<"你的生命力:"<<shengmingli<<endl; cout<<"你的攻击力:"<<gongjili<<endl; cout<<"你的防御力:"<<fangyuli<<endl; cout<<"你拥有的钱:"<<money<<endl; } else switch(xiaozhen){ case 1:wuqidian();break; case 2:yaodian();break; case 3:guaiwu1();break; case 4:guaiwu2();break; default:cout<<"请不要乱选!"<<endl; break; } cin>>xiaozhen; } if(xiaozhen==5)cout<<"正在退出游戏……"<<endl; cin.get(); cin.get(); } void wuqidian(){ cout<<"欢迎来到武器店!"<<endl; cout<<"1、买小刀(1M加2攻击力)"<<endl; cout<<"2、买短剑(2M加20攻击力)"<<endl; cout<<"3、买大砍刀(5M加40攻击力)"<<endl; cout<<"4、买双节棍(7M加60攻击力)"<<endl; cout<<"5、买盾牌(2M加30防御力)"<<endl; cout<<"6、买铠甲(5M加60防御力)"<<endl; cout<<"7、最强的茅,却败给了盾(200000000M加2e9攻击力)"<<endl; cout<<"8、最强的盾,却败给了茅(300000000M加2e9攻击力)"<<endl; cout<<"9、离开武器店"<<endl; int wuqidian; cin>>wuqidian; while(wuqidian!=9){ switch(wuqidian){ case 1: if(money<1)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; gongjili+=2; money-=1; break; } case 2: if(money<2)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; gongjili+=20; money-=80; break; } case 3: if(money<5)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; gongjili+=40; money-=140; break; } case 4: if(money<7)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; gongjili+=60; money-=200; break; } case 5: if(money<2)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; fangyuli+=30; money-=60; break; } case 6: if(money<5)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; fangyuli+=60; money-=100; break; } case 7: if(money<200000000)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; gongjili+=2e9; money-=200000000; break; } case 8: if(money<300000000)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; fangyuli+=2e9; money-=300000000; break; } default:cout<<"无"<<endl; break; } cin>>wuqidian; } if(wuqidian==9)cout<<"欢迎下次再来!\n欢迎你开始玩打怪物小游戏!\n小镇\n一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店和一家武器店。\n1.去武器店\n2.去药品店\n3.去打小怪物\n4.去打大怪物\n5.退出游戏\n6.显示你的状态\n\n"; } void yaodian(){ cout<<"欢迎来到药品店!"<<endl; cout<<"1、买1号补血药(10M加200生命)"<<endl; cout<<"2、买2号补血药(50M加1000生命力)"<<endl; cout<<"3、买3号补血药(100M加2200生命力)"<<endl; cout<<"4、买4号补血药(500M加15000生命力)"<<endl; cout<<"5、买5号超级补血药(200000000M加2e9生命力)"<<endl; cout<<"6、离开武器店"<<endl; int yaodian; cin>>yaodian; while(yaodian!=6){ switch(yaodian){ case 1: if(money<10)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; shengmingli+=200; money-=10; break; } case 2: if(money<50)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; shengmingli+=1000; money-=50; break; } case 3: if(money<100)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; shengmingli+=2200; money-=100; break; } case 4: if(money<500)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; shengmingli+=15000; money-=500; break; } case 5: if(money<200000000)cout<<"你的钱不够"<<endl; else{ cout<<"购买成功!"<<endl; shengmingli+=2e9; money-=200000000; break; } default:cout<<"无"<<endl; break; } cin>>yaodian; } if(yaodian==6)cout<<"欢迎下次再来!\n欢迎你开始玩打怪物小游戏!\n小镇\n一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店和一家武器店。\n1.去武器店\n2.去药品店\n3.去打小怪物\n4.去打大怪物\n5.退出游戏\n6.显示你的状态\n\n"; } void guaiwu1(){ cout<<"开始与小怪物战斗!!!"<<endl; double* g_shengmingli=new double; int* g_gongjili=new int; int* g_fangyuli=new int; int* g_money=new int; *g_shengmingli=100; *g_gongjili=5; *g_fangyuli=3; *g_money=5; double* tongji1=new double; double* tongji2=new double; *tongji1=0; *tongji2=0; int* huihe=new int; *huihe=1; cout<<"你开始对小怪物进行攻击!"<<endl; int* xuanze=new int; while((*g_shengmingli)>0&&shengmingli>0&&(*xuanze)!=2){ cout<<"现在是"<<"第"<<*huihe<<"回合!"<<endl; cout<<"请选择你的动作:\n"; cout<<"1、攻击\n2、逃跑\n"; cin>>*xuanze; switch((*xuanze)){ case 1: cout<<"你对小怪物发动了攻击!"<<endl<<endl; *g_shengmingli-=gongjili*2-(*g_fangyuli); *tongji1=gongjili*2-(*g_fangyuli); cout<<"你打掉了小怪物"<<*tongji1<<"的生命!"<<endl<<endl; cout<<"小怪物还剩"<<(*g_shengmingli)-(*tongji1)<<"点生命"<<endl<<endl; shengmingli-=(*g_gongjili)*2-fangyuli; *tongji2=(*g_gongjili)*2-fangyuli; cout<<"小怪物对你发动了攻击!"<<endl<<endl; cout<<"小怪物打掉了你"<<*tongji2<<"的生命!"<<endl<<endl; cout<<"你还剩"<<shengmingli-(*tongji2)<<"点生命"<<endl<<endl; break; case 2: cout<<"你决定逃跑!"<<endl<<endl; cout<<"逃跑成功!"<<endl<<endl; continue; default:cout<<"请不要乱选!"<<endl; } (*huihe)++; } if((*g_shengmingli)<=0){ money+=(*g_money); cout<<"小怪物被你杀死了!你真厉害!!!\n欢迎你开始玩打怪物小游戏!\n小镇\n一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店和一家武器店。\n1.去武器店\n2.去药品店\n3.去打小怪物\n4.去打大怪物\n5.退出游戏\n6.显示你的状态\n\n"; }else{ if(shengmingli<=0)cout<<"你被小怪物杀死了!游戏结束!!!"<<endl; else if((*xuanze)==2)cout<<"你逃回了小镇!\n欢迎下次再来!\n欢迎你开始玩打怪物小游戏!\n小镇\n一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店和一家武器店。\n1.去武器店\n2.去药品店\n3.去打小怪物\n4.去打大怪物\n5.退出游戏\n6.显示你的状态\n\n"; } delete g_shengmingli; delete g_gongjili; delete g_fangyuli; delete g_money; delete tongji1; delete tongji2; } void guaiwu2(){ cout<<"开始与大怪物战斗!!!"<<endl; double* g_shengmingli=new double; int* g_gongjili=new int; int* g_fangyuli=new int; *g_shengmingli=3600; *g_gongjili=500; *g_fangyuli=500; double* tongji1=new double; double* tongji2=new double; *tongji1=0; *tongji2=0; int* huihe=new int; *huihe=1; cout<<"你开始对大怪物进行攻击!"<<endl; int* xuanze=new int; while((*g_shengmingli)>0 && shengmingli>0 && (*xuanze)!=2){ cout<<"现在是"<<"第"<<*huihe<<"回合!"<<endl; cout<<"请选择你的动作:\n"; cout<<"1、攻击\n2、逃跑\n"; cin>>*xuanze; switch((*xuanze)){ case 1: cout<<"你对大怪物发动了攻击!"<<endl<<endl; *g_shengmingli-=gongjili*2-(*g_fangyuli); *tongji1=gongjili*2-(*g_fangyuli); cout<<"你打掉了大怪物"<<*tongji1<<"的生命!"<<endl<<endl; cout<<"大怪物还剩"<<(*g_shengmingli)-(*tongji1)<<"点生命"<<endl<<endl; shengmingli-=(*g_gongjili)*2-fangyuli; *tongji2=(*g_gongjili)*2-fangyuli; cout<<"大怪物对你发动了攻击!"<<endl<<endl; cout<<"大怪物打掉了你"<<*tongji2<<"的生命!"<<endl<<endl; cout<<"你还剩"<<shengmingli-(*tongji2)<<"点生命"<<endl<<endl; break; case 2: cout<<"你决定逃跑!"<<endl<<endl; cout<<"逃跑成功!"<<endl<<endl; continue; default:cout<<"请不要乱选!"<<endl; } (*huihe)++; } if((*g_shengmingli)<=0){ guoguan=true; cout<<"大怪物被你杀死了!你真厉害!!!\n欢迎你开始玩打怪物小游戏!\n小镇\n一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店和一家武器店。\n1.去武器店\n2.去药品店\n3.去打小怪物\n4.去打大怪物\n5.退出游戏\n6.显示你的状态\n"; } if(shengmingli<=0)cout<<"你被大怪物杀死了!游戏结束!!!"<<endl; if((*xuanze)==2)cout<<"你逃回了小镇!\n欢迎你开始玩打怪物小游戏!\n小镇\n一个1000年的小镇。周围有一条河,有一片树林,很多房子和很多人。\n有一家药店和一家武器店。\n1.去武器店\n2.去药品店\n3.去打小怪物\n4.去打大怪物\n5.退出游戏\n6.显示你的状态\n"; }
//Game2048 #include <iostream> #include <vector> #include <ctime> #include <cstdlib> using namespace std; // 游戏状态类 class Game2048 { private: vector<vector<int>> board; int score; // 在随机位置生成一个新数字(2或4) void generateNewNumber() { vector<pair<int, int>> emptyCells; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (board[i][j] == 0) { emptyCells.push_back({i, j}); } } } if (!emptyCells.empty()) { int randomIndex = rand() % emptyCells.size(); int value = (rand() % 2 + 1) * 2; board[emptyCells[randomIndex].first][emptyCells[randomIndex].second] = value; } } // 向左移动 void moveLeft() { bool moved = false; for (int i = 0; i < 4; ++i) { int writeIndex = 0; for (int j = 0; j < 4; ++j) { if (board[i][j]!= 0) { if (writeIndex!= j) { board[i][writeIndex] = board[i][j]; board[i][j] = 0; moved = true; } writeIndex++; } } for (int j = 0; j < 3; ++j) { if (board[i][j] == board[i][j + 1] && board[i][j]!= 0) { board[i][j] *= 2; score += board[i][j]; board[i][j + 1] = 0; moved = true; } } int writeIndex2 = 0; for (int j = 0; j < 4; ++j) { if (board[i][j]!= 0) { if (writeIndex2!= j) { board[i][writeIndex2] = board[i][j]; board[i][j] = 0; moved = true; } writeIndex2++; } } } if (moved) { generateNewNumber(); } } // 向右移动 void moveRight() { bool moved = false; for (int i = 0; i < 4; ++i) { int writeIndex = 3; for (int j = 3; j >= 0; --j) { if (board[i][j]!= 0) { if (writeIndex!= j) { board[i][writeIndex] = board[i][j]; board[i][j] = 0; moved = true; } writeIndex--; } } for (int j = 3; j > 0; --j) { if (board[i][j] == board[i][j - 1] && board[i][j]!= 0) { board[i][j] *= 2; score += board[i][j]; board[i][j - 1] = 0; moved = true; } } int writeIndex2 = 3; for (int j = 3; j >= 0; --j) { if (board[i][j]!= 0) { if (writeIndex2!= j) { board[i][writeIndex2] = board[i][j]; board[i][j] = 0; moved = true; } writeIndex2--; } } } if (moved) { generateNewNumber(); } } // 向上移动 void moveUp() { bool moved = false; for (int j = 0; j < 4; ++j) { int writeIndex = 0; for (int i = 0; i < 4; ++i) { if (board[i][j]!= 0) { if (writeIndex!= i) { board[writeIndex][j] = board[i][j]; board[i][j] = 0; moved = true; } writeIndex++; } } for (int i = 0; i < 3; ++i) { if (board[i][j] == board[i + 1][j] && board[i][j]!= 0) { board[i][j] *= 2; score += board[i][j]; board[i + 1][j] = 0; moved = true; } } int writeIndex2 = 0; for (int i = 0; i < 4; ++i) { if (board[i][j]!= 0) { if (writeIndex2!= i) { board[writeIndex2][j] = board[i][j]; board[i][j] = 0; moved = true; } writeIndex2++; } } } if (moved) { generateNewNumber(); } } // 向下移动 void moveDown() { bool moved = false; for (int j = 0; j < 4; ++j) { int writeIndex = 3; for (int i = 3; i >= 0; --i) { if (board[i][j]!= 0) { if (writeIndex!= i) { board[writeIndex][j] = board[i][j]; board[i][j] = 0; moved = true; } writeIndex--; } } for (int i = 3; i > 0; --i) { if (board[i][j] == board[i - 1][j] && board[i][j]!= 0) { board[i][j] *= 2; score += board[i][j]; board[i - 1][j] = 0; moved = true; } } int writeIndex2 = 3; for (int i = 3; i >= 0; --i) { if (board[i][j]!= 0) { if (writeIndex2!= i) { board[writeIndex2][j] = board[i][j]; board[i][j] = 0; moved = true; } writeIndex2--; } } } if (moved) { generateNewNumber(); } } public: Game2048() { board.resize(4, vector<int>(4, 0)); score = 0; srand(static_cast<unsigned int>(time(nullptr))); generateNewNumber(); generateNewNumber(); } // 打印游戏界面 void printBoard() { for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { cout << board[i][j] << "\t"; } cout << endl; } cout << "Score: " << score << endl; } // 处理玩家输入并移动 void play() { char move; while (true) { printBoard(); cout << "Enter direction (w/a/s/d): "; cin >> move; switch (move) { case 'w': moveUp(); break; case 'a': moveLeft(); break; case's': moveDown(); break; case 'd': moveRight(); break; default: cout << "Invalid input. Try again." << endl; continue; } bool gameOver = true; for (int i = 0; i < 4; ++i) { for (int j = 0; j < 4; ++j) { if (board[i][j] == 0) { gameOver = false; break; } } if (!gameOver) { break; } } if (gameOver) { cout << "Game Over!" << endl; break; } } } }; int main() { Game2048 game; game.play(); return 0; }
//别踩白块 #include<bits/stdc++.h> #include<windows.h> #include<conio.h> using namespace std; int X,Y,dx,dy,tX,zX,zY,Sstar,Sboom,Win,Ee,Fen,RR,Slep,K,S,Er,Ice,Fang,Can,Ta,Zha,Bai,Yin,Su,U,T T,Ty,sy,m[10001][21]={{-1,0,0,0,0,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},{-1,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{- 1,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{-1,19,0,0,0,0,0,1,1,1,0,0,12,0,0,0,0,0,0,0,0}, {-1,13,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0},{- 1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,4,0,0,0,0},{-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{- 1,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1},{-1,0,0,0,2,2,0,0,3,3,0,0,6,6,0,0,0,0,0,0,0}, {-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0},{- 1,15,0,0,0,0,0,0,0,0,0,0,0,0,20,0,0,0,0,0,0},{- 1,0,0,0,0,0,0,0,0,0,0,0,0,16,17,0,0,0,0,0,0},{-1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}, {-1,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0},{- 1,0,0,0,1,1,0,0,2,2,0,0,0,1,1,1,0,0,0,0,0},}; void Color(int a){ a+=Bai*20; if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY| FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY| FOREGROUND_GREEN|FOREGROUND_BLUE); if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY| FOREGROUND_GREEN); if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY| FOREGROUND_RED|FOREGROUND_BLUE); if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY| FOREGROUND_RED); if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY| FOREGROUND_RED|FOREGROUND_GREEN); if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY| FOREGROUND_BLUE); if(a==7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED| FOREGROUND_GREEN|FOREGROUND_BLUE); if(a==8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_GREEN| BACKGROUND_BLUE|FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_BLUE); if(a%20==9) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED| FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN); if(a==10) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED); else if(a>20) SetConsoleTextAttribute(GetStdHandle (STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE); } void SetPos(int x,int y){ COORD pos; pos.X=y*2-1,pos.Y=26-x; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); } void Star(); void Wo(int x){ SetPos(X-K,Y),cout<<" "; if(Can!=0) {SetPos(X-K,Y),Color(10),cout<<"●";int R=rand()%5;if(R==0&&Y<20) Y++;if (R==1&&Y>1) Y--;} if((m[X][Y]==1||m[X][Y]==7)&&Ta==0) X++; if(X<=0) X=dx,Y=dy; if(X-K>23) tX=0,X=K+23; if(tX!=0&&Ta==0) tX--,X+=2; if(Ta!=0) {tX=0;if(m[X-1][Y]==0||m[X-1][Y]==4||m[X-1][Y]==5||(m[X-1][Y]>=9&&m[X-1][Y] <=18)) m[X-1][Y]=7;} if(m[X][Y]==6) X--; if(m[X+1][Y]==6){tX=0;m[X+1][Y]=7;if(m[X+1][Y-1]==6) m[X+1][Y-1]=7;if(m[X+1][Y+1]==6) m [X+1][Y+1]=7;Fen+=2;} if(m[X-1][Y]==6){tX=0;m[X-1][Y]=7;if(m[X-1][Y-1]==6) m[X-1][Y-1]=7;if(m[X-1][Y+1]==6) m [X+1][Y+1]=7;Fen+=2;} if(m[X][Y+1]==6){tX=0;m[X][Y+1]=m[X][Y+2]=7;Fen+=2;} if(m[X][Y-1]==6){tX=0;m[X][Y-1]=m [X][Y-2]=7;Fen+=2;} if(m[X-1][Y]==0||m[X-1][Y]==4||m[X-1][Y]==5||(m[X-1][Y]>=9&&m[X-1][Y]<=20)) {X--;} if(m[X][Y]==4) Fen+=5,m[X][Y]=5,dx=X,dy=Y; if(m[X][Y]==16) m[X][Y]=0,Sstar++,Star(),SetPos(X-K,Y),cout<<" ";if(m[X+1][Y]==16) m[X +1][Y]=0,Sstar++,Star(),SetPos(X-K+1,Y),cout<<" "; if(m[X-1][Y]==1||m[X-1][Y]==2||m[X-1][Y]==3||m[X-1][Y]==7) tX=Er=0; if(m[X-1][Y]==2||m[X][Y]==2||Ta!=0) tX+=5; if(m[X-1][Y]==10) m[X-1][Y]=3,Sboom++;if(m[X][Y]==10) m[X][Y]=3,X++,Sboom++; if(m[X-1][Y]==3||m[X][Y]==3){ if(Zha==0){ Zha++; SetPos(X+1-K,Y-1),Color(5),cout<<"■";SetPos(X+1-K,Y+1),Color (5),cout<<"■";SetPos(X+1-K,Y),Color(5),cout<<"■";SetPos(X-1-K,Y-1),Color(5),cout<<"■"; SetPos(X-1-K,Y+1),Color(5),cout<<"■";SetPos(X-1-K,Y),Color (5),cout<<"■";SetPos(X-K,Y-1),Color(5),cout<<"■";SetPos(X-K,Y+1),Color(5),cout<<"■"; SetPos(X-K,Y),Color(5),cout<<"■";Sleep(300);SetPos(X+1-K,Y-1),Color(5),cout<<" "; SetPos(X+1-K,Y+1),Color(5),cout<<" ";SetPos(X+1-K,Y),Color(5),cout<<" ";SetPos(X-1-K,Y-1),Color(5),cout<<" ";SetPos(X-1-K,Y+1),Color(5),cout<<" "; SetPos(X-1-K,Y),Color(5),cout<<" ";SetPos(X-K,Y-1),Color(5),cout<<" ";SetPos (X-K,Y+1),Color(5),cout<<" ";SetPos(X-K,Y),Color(5),cout<<" "; //动画 }if(m[X][Y]==3) X++; if(Fang==0) X=dx,Y=dy,Fen+=100; }else Zha=0; if(x==3) {int U=rand()%10;SetPos(X-K,Y);if(U==0) Color(6),cout<<"●";} else if(Fang!=0) SetPos(X-K,Y),Color(2),cout<<"●"; else if(Can!=0) SetPos(X-K,Y),Color(4),cout<<"●"; else if(x==2) SetPos(X-K,Y),Color(5),cout<<"●"; else if(x==1) SetPos(X-K,Y),Color(1),cout<<"●"; } void Cout(int i,int j,int a){ if(m[i][j]==1) SetPos(i-K,j),Color(0),cout<<"■"; if(m[i][j]==2) SetPos(i-K,j),Color(5),cout<<"■"; if(m[i][j]==3) SetPos(i-K,j),Color(4),cout<<"■"; if(m[i][j]==4) SetPos(i-K,j),Color(3),cout<<"▋"; if(m[i][j]==5&&(i!=X||j!=Y)) SetPos(i-K,j),Color(2),cout<<"▋"; if(m[i][j]==6&&a==1) SetPos(i-K,j),Color(7),cout<<"■",m[i][j]=7,Fen++; if(m[i][j]==7&&a==4) SetPos(i-K,j),cout<<" ",m[i][j]=0; if(m[i][j]==7&&a!=4) SetPos(i-K,j),Color(7),cout<<"■"; if(m[i][j]==9) SetPos(i-K,j),Color(0),cout<<"←→左右移动"; if(m[i][j]==11&&Ee==0) SetPos(i-K,j),Color(0),cout<<"弹跳块 炸弹块 隐形块"; if(m[i][j]==11&&Ee==1) SetPos(i-K,j),Color(0),cout<<"弹跳块 ",Color(4),cout<<"隐形炸弹块 ",Color(0),cout<<" 隐形块"; if(m[i][j]==12&&Ee==0) SetPos(i-K,j),Color(0),cout<<" 激活复活点"; if(m[i][j]==12&&Ee==1) SetPos(i-K,j),Color(0),cout<<"出复活点",Color(3),cout<<"几率已增 加"; if(m[i][j]==13) SetPos(i-K,j),Color(0),cout<<"按↑跳跃,可二段跳"; if(m[i][j]==14) SetPos(i-K,j),Color(0),cout<<"从现在开始随机出图啦"; if(m[i][j]==15&&Ee==0) SetPos(i-K,j),Color(5),cout<<"1000分通关!",Color(0),cout<<"空格 暂停"; if(m[i][j]==15&&Ee==1) SetPos(i-K,j),Color(5),cout<<"探到40个通关!",Color(0),cout<<"空 格暂停"; if(m[i][j]==15&&Ee==2) SetPos(i-K,j),Color(5),cout<<"捉到20个通关!",Color(0),cout<<"空 格暂停"; if(m[i][j]==16) SetPos(i-K,j),Color(5),cout<<"★"; if(m[i][j]==17&&Ee==0) SetPos(i-K,j),Color(0),cout<<"里有神秘物品!"; if(m[i][j]==17&&Ee==1) SetPos(i-K,j),Color(0),cout<<"里有",Color(2),cout<<"防爆护 罩!",Color(0); if(m[i][j]==17&&Ee==2) SetPos(i-K,j),Color(2),cout<<"它会动啦!",Color(0); if(m[i][j]==18) SetPos(i-K,j),Color(0),cout<<"不要让你的角色掉到视线以下!"; if(m[i][j]==19) SetPos(i-K,j),Color(0),cout<<"按↓下降"; if(m[i][j]==20&&Ee==2) SetPos(i-K,j),Color(3),cout<<"出现几率已增加",Color(0); Color(0); } void Map(int x1,int x2,int a){ SetPos(25,2);if(Bai!=0||Yin!=0||Can!=0) Color(9);else Color(1); if(Ee==0) cout<<"分数:"<<Fen<<" ",Color(0);if(Ee==1) cout<<"已探测 :"<<Sboom<<" ",Color(0);if(Ee==2) cout<<"已收集:"<<Sstar<<" ",Color(0); SetPos(24,2);if(Ice!=0) Color(8);else Color(1);cout<<"速度:"<<Slep<<" ",Color(0); bool Yan=0; for(register int i=x1;i>=x2;i--) for(register int j=1;j<=20;j++) Cout(i,j,a); if(Yin!=0) Wo(3); else if(Ta!=0) Wo(2); else if(a==0) Wo(1); else if(a==2) SetPos(X-K,Y),Color(1),cout<<"▲"; } void MoveStar(int x1,int x2){ int n[30][21];memset(n,0,sizeof(n)); for(register int i=x1;i>=x2;i--) for(register int j=1;j<=20;j++){ if(m[i][j]==16&&n[i-K][j]==0){ int kl=rand()%4; if(kl==0&&i-K<22&&m[i+1][j]==0) m[i][j]=0,m[i+1][j]=16,n[i+1-K][j]=1,SetPos(i- K,j),cout<<" ",SetPos(i+1-K,j),cout<<"★"; if(kl==1&&i-1>K&&m[i-1][j]==0) m[i][j]=0,m[i-1][j]=16,n[i-1-K][j]=1,SetPos(i- K,j),cout<<" ",SetPos(i-1-K,j),cout<<"★"; if(kl==2&&j+1<20&&m[i][j+1]==0) m[i][j]=0,m[i][j+1]=16,n[i-K][j+1]=1,SetPos(i- K,j),cout<<" ",SetPos(i-K,j+1),cout<<"★"; if(kl==3&&j-1>1&&m[i][j-1]==0) m[i][j]=0,m[i][j-1]=16,n[i-K][j-1]=1,SetPos(i- K,j),cout<<" ",SetPos(i-K,j-1),cout<<"★"; } } } void Sheng(){ RR++; if(K<-8) RR=5; if(K==-8) RR=0; if(RR==3) {int r=rand()%2;if(r==0) RR=0;} if(RR==4) RR=0; if(RR==0){ Ax: int Bx=0; for(int i=1;i<=20;i++) m[K+22][0]=0; for(int i=1;i<=20;i++){ int R=rand()%50; if(R<=10) {int S=rand()%3+1; for(int j=i;j<=i+S;j++) if(j<=20) m[K+22][j]=1;i +=S+1;Bx=1;continue;} if(R>10&&R<=12) {for(int j=i;j<=i+1;j++) if(j<=20) m[K+22][j]=2; i +=2;Bx=1;continue;} if(R>12&&R<=14) {for(int j=i;j<=i+1;j++) if(j<=20) m[K+22][j]=3; i+=2;continue;} if(R>14&&R<=16) {for(int j=i;j<=i+1;j++) if(j<=20) m[K+22][j]=6; i+=2;continue;} if(R==17) {m[K+22][i]=m[K+22][i+1]=m[K+22][i+2]=1; m[K+23][i+1]=4; i +=2;continue;} if(R>17&&R<=20&&Ee==1) {m[K+22][i]=m[K+22][i+1]=m[K+22][i+2]=1; m[K+23][i+1]=4; i+=2;continue;} if(R>20&&R<=30&&Ee==1) m[K+22][i]=10; i++; }if(Bx==0) goto Ax; } int Q=rand()%30; if(Q==0) {int QQ=rand()%20+1; if(m[K+22][QQ]==0) m[K+22][QQ]=16;} else if(Q<=2&&Ee==2) {int QQ=rand()%20+1; if(m[K+22][QQ]==0) m[K+22][QQ]=16;} } void Star(){ int W=rand()%10;if(K<20) W=rand()%7;if(Ee==1) W=3; if(W==0) {Color(5);cout<<"火箭!";Sleep(1000);tX=0;for(int i=1;i<=15;i++) {if(X-K<20) X +=2; else X++; Sheng(),K++,Fen++,Map(K+22,K-3,2),system("cls");}m[X-2][Y]=m[X-2][Y-1] =6,S=1;Sleep(10);} if(W==1) {Color(5);cout<<"透视眼!";Sleep(1000);system("color 3F");Sleep(100);if(X>2) m [X-2][Y]=m[X-2][Y-1]=6;Map(K+22,K-3,1);system("color 0F");} if(W==2) {Color(5);cout<<"减速!";Sleep(1000);system("color 1F");Map(K+22,K- 3,3);Ice=10;system("color 0F");if(X>2&&K>10) m[X-2][Y]=m[X-2][Y-1]=6;} if(W==3) {Color(5);cout<<"防爆护罩!";Sleep(1000);Fang=15;if(X>2&&K>10) m[X-2][Y]=m[X- 2][Y-1]=6;} if(W==4) {Color(5);cout<<"白内障!";Sleep(1000);system("color 5F");Map(K+22,K- 3,0);Bai=15;system("color 0F");if(X>2&&K>10) m[X-2][Y]=m[X-2][Y-1]=6;} if(W==5) {Color(5);cout<<"隐身!";Sleep(1000);system("color 2F");Yin=15;if(X>2) m[X-2] [Y]=m[X-2][Y-1]=6;Map(K+22,K-3,0);system("color 0F");} if(W==6) {Color(5);cout<<"兴奋剂!";Sleep(1000);system("color 4F");Sleep(100);Can=15;if (X>2) m[X-2][Y]=m[X-2][Y-1]=6;Map(K+22,K-3,1);system("color 0F");} if(W==7) {Color(5);cout<<"踏云靴!";Sleep(1000);system("color 6F");Sleep(100);Ta=10;} if(W==8) {Color(5);cout<<"平台!";Sleep(1000);system("color 7F");Sleep(100);for(int i=1;i<=20;i++) m[X-1][i]=1;Map(K+22,K-3,1);system("color 0F");} if(W==9) {Color(5);cout<<"炸弹陷阱!";Sleep(1000);system("color 4F");for(int i=0;i<=5;i ++){int kX=rand()%9-4;int kY=rand()%9-4;if(Y+kY>0&&Y+kY<=20) m[X+kX][Y+kY]=3;}tX=0;if(X>1) m[X-1][Y]=6;Map(K+22,K-3,0);system("color 0F");} } void Start(){ Color(5); SetPos(25,2);cout<<" ■■■ ■ "; SetPos(24,2);cout<<" ■ ■ ■ "; SetPos(23,2);cout<<" ■■■ ■ ■ "; SetPos(22,2);cout<<" ■ ■ ■■■■■ 注意!"; SetPos(21,2);cout<<" ■ ■ "; SetPos(20,2);cout<<" ■■■ ■■■■ 按键模式已修改!"; SetPos(19,2);cout<<" ■ ■ ■ ■ "; SetPos(18,2);cout<<" ■ ■ ■ ■ 现在需要同时按才"; SetPos(17,2);cout<<"■■ ■ ■■■■ 可左右跳!"; SetPos(14,2);cout<<" ■ ■ "; SetPos(13,2);cout<<" ■ ■ "; SetPos(12,2);cout<<" ■■■ ■■■■■"; SetPos(11,2);cout<<" ■ ■ ■ ■"; SetPos(10,2);cout<<" ■ ■■■■■"; SetPos(9,2); cout<<" ■ ■■ ■ ■ ■"; SetPos(8,2); cout<<" ■ ■ ■ ■■■■■"; SetPos(7,2); cout<<" ■ ■ "; SetPos(6,2); cout<<" ■ ■ "; SetPos(5,2); cout<<" ■ ■ 之 路"; SetPos(3,2);Color(0);cout<<"按 y 确定!";SetPos(3,10);Color(9);cout<<" 开始游戏! ";SetPos(2,10);Color(0);cout<<" 炸弹风暴! ";SetPos(1,10);Color(0);cout<<" 夺星之战 ! "; SetPos(-1,1);Color(3);cout<<"注意!这里 绝对不能是拼音输入法!"; SetPos(-2,5);Color(3);cout<<"↓";Color(0); char tt;Ee=0; while(tt!='y'){ tt=_getch(); if(tt==72&&Ee!=0) Ee--; if(tt==80&&Ee!=2) Ee++; SetPos(3,10);if(Ee==0) Color(9);else Color(0);cout<<" 开始游戏! ";Color(0); SetPos(2,10);if(Ee==1) Color(9);else Color(0);cout<<" 炸弹风暴! ";Color(0); SetPos(1,10);if(Ee==2) Color(9);else Color(0);cout<<" 夺星之战! ";Color(0); }system("cls"); if(Ee==1) m[9][8]=m[9][9]=m[9][10]=m[9][11]=m[9][12]=10,m[9][14]=m[9][15]=6; } void Return(){ for(int i=0;i<=5;i++){ system("color 1A");Sleep(10); system("color 2B");Sleep(10); system("color 3C");Sleep(10); system("color 4D");Sleep(10); system("color 5D");Sleep(10); system("color 6E");Sleep(10); system("color 7F");Sleep(10); }system("color 0F");Map(K+22,K-3,4);system("cls"); while(K>-6) {for(int i=0;i<=20;i++) m[K+21][i]=0;K--;} m[6][16]=4;m[12][13]=16; m[9][12]=m[9][13]=6;system("cls"); } int main(){ system("mode con cols=42 lines=30"); CONSOLE_CURSOR_INFO cursor_info={1,0}; SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info); srand((unsigned)time(NULL)); Start(); ST: X=3,Y=2,dx=3,dy=2,K=-7,tX=Fen=RR=S=Er=Sstar=Sboom=Win=0,Ta=Fang=Ice=Bai=Yin=Can=0; Map(K+22,K-3,0); while(X>K-3||dx>K-3){ S++,U++; if(Fen<0) Fen=0; if(Ee==0&&Fen>1000) {Win=1;break;}if(Ee==1&&Sboom>=40) {Win=1;break;}if (Ee==2&&Sstar>=20) {Win=1;break;} if(K<=5) Slep=20;if(K>5&&K<=10) Slep=15;if(K>10&&K<=20) Slep=10;if(K>20&&K<=30) Slep=8;if(K>30&&K<=70) Slep=7;if(K>70&&K<=150) Slep=6;if(K>150&&K<=250) Slep=5;if (K>250&&K<=400) Slep=4;if(K>400&&K<=600) Slep=3;if(K>600) Slep=2; if(Sstar<=5) Su=5;if(Sstar>5&&Sstar<=10) Su=4;if(Sstar>10&&Sstar<=15) Su=3;if (Sstar>15&&Sstar<=20) Su=2;if(Sstar>20&&Sstar<=30) Su=1; if(Ice!=0) Slep=20; if(X<=K-3&&dx>K-3) X=dx,Y=dy; if(S==Slep){ K++,S=0; if(Bai!=0||Yin!=0||Can!=0) Fen+=2;else Fen++; if(Ta>0) Ta--;if(Fang>0) Fang--;if(Bai>0) Bai--;if(Ice>0) Ice--;if(Yin>0) Yin--;if(Can>0) Can--; if(Ta<0) Ta=0;if(Fang<0) Fang=0;if(Bai<0) Bai=0;if(Ice<0) Ice=0;if(Yin<0) Yin=0;if(Can<0) Can=0; system("cls"),Sheng(); } if(GetAsyncKeyState(VK_UP)&0x8000&&TT==0&&Ta==0&&Er<2) TT++,tX+=4,Er++; else if(GetAsyncKeyState(VK_UP)&0x8000&&TT==0&&Can!=0) TT++,tX+=7,Er++; else if(GetAsyncKeyState(VK_UP)&0x8000&&TT==0&&Ta!=0) SetPos(X-K,Y),cout<<" ",X+ +,tX=Er=0; if(GetAsyncKeyState(VK_DOWN)&0x8000&&Ty==0) Ty++,SetPos(X-K,Y),cout<<" ",tX=0,X-=2; if((GetAsyncKeyState(VK_UP) & 0x8000) ?0:1) TT=0; if((GetAsyncKeyState(VK_DOWN) & 0x8000) ?0:1) Ty=0; if(GetAsyncKeyState(VK_LEFT)&0x8000&&Y>1) SetPos(X-K,Y),cout<<" ",Y--; if(GetAsyncKeyState(VK_RIGHT)&0x8000&&Y<20) SetPos(X-K,Y),cout<<" ",Y++; if(kbhit()) {char g=_getch();if(g==' ') Sleep(100),SetPos(24,8),sy++,Color (0),system("pause");} if(sy>=1) SetPos(24,8),cout<<" ",sy=0; if(U>=Su) {U=0;if(Ee==2) MoveStar(K+22,K-3);} Map(K+22,K-3,0); Sleep(50); } if(Win==0)SetPos(25,8),system("color 7F"),Color(4),cout<<"You! Die!!!",Sleep(1000); else SetPos(25,8),system("color 6E"),Color(3),cout<<"You! Win!!!",Sleep(1000); SetPos(24,5),cout<<"Please point 'y' to Play AGain.";Color(0); A:char e=_getch(); if(e=='y') Return(); else goto A; goto ST; }
//超级迷宫 #include <bits/stdc++.h> #include <windows.h> #include <conio.h> using namespace std; void Color(int a) { if (a == 0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN |FOREGROUND_BLUE); if (a == 1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE); if (a == 2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_GREEN); if (a == 3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE); if (a == 4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED); if (a == 5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN); if (a == 7) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_RED |FOREGROUND_BLUE | FOREGROUND_GREEN); if (a == 8) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_RED); } void Setpos(int x,int y) { COORD pos; pos.X = y * 2,pos.Y = x; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos); } int R[5]; void SlowDisplay(int x,char *p) { while (1) { if (*p != 0) { printf("%c",*p++); } else { break; } Sleep(x); } } struct xg { int xgx,xgy; bool fx,sw = 0; }xg[21]; int ys = 0,hd = 0,sj = 0,sl = 0,mg = 0,hp = 0,hss = 0,hsx = 0,jt = 0,s = 0; char ch[35][35]; char ch1[35][35] = {"", " ##### ##### ########"," #&## ### ### "," #### # ## #### #### "," ### ## # ####! ## "," ###& ### +## ###### ####"," ######&############! ##"," # *# ! ######### ###-##"," # ### ##### # "," # ###*# ############### ### "," # ###&### ####"," # # # ##-############## "," ###### #####! "," #+ # ###### ############ ", " ##&########## ### ### ### ## "," # ! ! #"," ############################"," # ! # ! # #"," # ! # ! #### "," #&########################### "," ) ",}; char ch2[35][35] = {""," ##############################"," #* #"," ########&###################-#"," # # #"," # # ################&#####-# #"," # # # ! +# # #"," # # # ##&############### # # #"," # # # # # # # #"," # # # # ###########&## # # # #"," # # # # #)- ! # # # & #"," # # # # ### ! # # # # #", " # # # ##########&####### # # #"," # # # ! # #"," # # ##################&##### #"," # # ! *# #"," # #####&####### ############ #"," # ! # # ! #"," # ############# ########### #"," # ! #"," ##############################", }; char ch3[31][33] = {""," ##############################"," #. + .#"," # ! #"," # + ! #"," # #"," # ! + #"," # ! + ! #"," # + #"," # + ! #", " # + ! #"," # ! + #"," #+ _____ #"," # |_ _ _| + #"," # + |_|||_| #"," # + |MMMMM| !#"," # |WWWWW| #"," #! |_____| #"," # ! #"," #. + .#"," ##############################", }; char ch4[35][35] = {""," ###*### ########"," ###! # ##### # *#"," ###&#+####### # # # # ######"," # !# # #-# # # # #"," ###&####### # # # # ## #"," ####### ##### # ## #"," ####&### ! ! !# ## #"," # ################ ## #"," ### !! ## "," #### ##&##################### "," # ! !# "," #-############&######### #&## "," #-#ooooooooooo o # #*## "," o ooo o o o o ooo # #### "," o o o o oo o o # "," ooo o ooooooo oo ooo o #######"," ooo o o o oo o #"," ooo o o o*oooooooooooooooo-#"," ooooooo o oo o o o o #"," ) o o o o o #",}; char ch5[35][35] = {""," oooo oooooooooooooooooooo"," ooo o oo+oo o o"," ooooooo*oooo ! o ! o o o"," o o o o o o o"," oooooooooo ooooooooooooooooo o"," o ! ! o"," oooooooo ooooooooooooooooooooo"," oooooooo ooooooooooooooooooooo", " o ! o"," o^^^^^^^^^^^^^^^^^^^^^^^^^^^^o"," o ! ! ! ! ! o"," o^^^^^^^^^^^^^^^^^^^^^^^^^^^^o"," o^*^! !^! !^! ^^! +^! !^! *^o"," o^^^^^^^^^^^^^^^^^^^^^^^^^^^^o"," o ! ! ! ! ! o"," #^^^^^^^^^^^^^^^^^^^^^^^^^^^^#"," # ! #"," ####oooooooooo--oooooooooooo##"," ########oooooo--ooooooo#######"," ###########ooo))oooo##########", }; char ch6[35][35] = {""," oooooooooooooo .oooooooooooooo"," o+oooooooooooo oooooooooooo+o"," ooooooooooooo# #ooooooooooooo"," oooooooooooo#^^^^#oooooooooooo"," oooo*oooooo#^ ^#oooooo*oooo"," oooooooooo# ^ ^ #oooooooooo"," ooooooooo# ^ ^ #ooooooooo"," oooooooo#^^^^^^^^^^^^#oooooooo"," ooooooo#^ ^#--#^ ^#ooooooo"," . ^ ^-NO-^ ^ "," ^ ^-IP-^ ^ ."," ooooooo#^ ^#--#^ ^#ooooooo"," oooooooo#^^^^^^^^^^^^#oooooooo"," ooooooooo# ^ ^ #ooooooooo"," oooooooooo# ^ ^ #oooooooooo"," oooo*oooooo#^ ^#oooooo*oooo"," oooooooooooo#^^^^#oooooooooooo"," ooooooooooooo# #ooooooooooooo"," o+oooooooooooo oooooooooooo+o"," oooooooooooooo. oooooooooooooo",}; void map1(int x,int y,int k) { for (int i = 1;i <= 20;++i) for (int j = 1;j <= 30;++j) { bool f = 1; for (int l = 1;l <= k;++l) if (xg[l].xgx == i && xg[l].xgy == j && xg[l].sw == 0) { Setpos(i,j); Color(4),cout << "▼";f = 0; break; } if (f == 1) { Setpos(i,j); if (i == x && j == y) Color(1),cout << "●"; else if (ch[i][j] == '#' || ch[i][j] == '&') Color(7),cout << "■"; else if (ch[i][j] == ')') Color(5),cout << "☆"; else if (ch[i][j] == '*') Color(5),cout << "♂"; else if (ch[i][j] == '-') Color(3),cout << "▋"; else if (ch[i][j] == '+') Color(2),cout << "◆"; else if (ch[i][j] == '.') Color(1),cout << "◆"; else if (ch[i][j] == 'o') Color(8),cout << "~ "; else if (ch[i][j] == '_') Color(3),cout << "▁"; else if (ch[i][j] == '^') Color(3),cout << "▲"; else if (ch[i][j] == '|') Color(3),cout << "|"; else if (ch[i][j] == 'M') Color(3),cout << 'M' << 'M'; else if (ch[i][j] == 'W') Color(3),cout << 'W' << 'W'; else if (ch[i][j] == 'N') Color(2),cout << "NO"; else if (ch[i][j] == 'I') Color(2),cout << ".."; else if (ch[i][j] == 'O') Color(2),cout << "I!"; else if (ch[i][j] == 'P') Color(2),cout << ".P"; else Color(0),cout << " "; } } Setpos(21,3); Color(5),cout << "[" << ys << " ♂] ",Color(2),cout << "[" << hd << " ◆]"; } int yx(int a) { int k = 0,T = 0,x,y,boss = 0,win = 0;ys = 0,hd = 0,sj = 0; system("cls"); if(a==1) {for(int i=0;i<35;i++)for(int j=0;j<35;j++) ch[i][j]=ch1[i][j];x=1,y=1;} if(a==2) {for(int i=0;i<35;i++)for(int j=0;j<35;j++) ch[i][j]=ch2[i][j];x=2,y=29;} if(a==3) {for(int i=0;i<35;i++)for(int j=0;j<35;j++) ch[i][j]=ch3[i][j];x=10,y=15;boss=1;} if(a==4) {for(int i=0;i<35;i++)for(int j=0;j<35;j++) ch[i][j]=ch4[i][j];x=1,y=1;} if(a==5) {for(int i=0;i<35;i++)for(int j=0;j<35;j++) ch[i][j]=ch5[i][j];x=1,y=1;} if(a==6) {for(int i=0;i<35;i++)for(int j=0;j<35;j++) ch[i][j]=ch6[i][j];x=1,y=15;boss=2;} if(boss==1){for (int i=1;i<=200;++i) {int xx=rand()%21,yy=rand()%31;if ((xx!=x||yy!=y)&&ch[xx][yy]!='_'&&ch[xx][yy]!='W'&&ch[xx][yy]!='|'&&ch[xx][yy]!='M'&&ch[xx][yy]!='.') ch[xx][yy]='o';}map1(x,y,k);} for(int i=1;i<35;++i)for(int j=1;j<35;++j) if (ch[i][j]=='!')k++,xg[k].xgx=i,xg[k].xgy=j,ch[i][j]=' '; map1(x,y,k); while (1) { T++; Setpos(x,y),cout<<" "; if(GetAsyncKeyState(VK_UP)&0x8000&&x!=1&&ch[x-1][y]!='#') x--; else if(GetAsyncKeyState(VK_DOWN)&0x8000&&x!=20&&ch[x+1][y]!='#') x++; else if(GetAsyncKeyState(VK_LEFT)&0x8000&&y!=1&&ch[x][y-1]!='#') y--; else if(GetAsyncKeyState(VK_RIGHT)&0x8000&&y!=30&&ch[x][y+1]!='#') y++; Setpos(x,y),Color(1),cout<<"●"; if(boss!=0&&T%20==5){ for (int i=1;i<=20;++i)for (int j=1;j<=30;++j)if (ch[i][j]=='o') ch[i][j]=' '; for (int i=1;i<=200*boss;++i) {int xx=rand()%21,yy=rand()%31;if ((xx!=x||yy!=y)&&ch[xx][yy]==' ') ch[xx][yy]='o';} map1(x,y,k);} if(T%20==0) map1(x,y,k);if(T%20==10){for(int i=1;i<35;++i)for(int j=1;j<35;++j) if(ch[i][j]=='^')Setpos(i,j),cout<<" ";} if(T%4==0&&k!=0) for (int i=1;i<=k;i++){ if (xg[i].fx==0&&(ch[xg[i].xgx][xg[i].xgy+1]==' '||(ch[xg[i].xgx][xg[i].xgy-1]=='^'&&T%20>=10))&&xg[i].xgy!=30) Setpos(xg[i].xgx,xg[i].xgy),cout<<" ",xg[i].xgy++,Setpos(xg[i].xgx,xg[i].xgy),Color(4),cout<<"▼"; else if (xg[i].fx==1&&(ch[xg[i].xgx][xg[i].xgy-1]==' '||(ch[xg[i].xgx][xg[i].xgy-1]=='^'&&T%20>=10))&&xg[i].xgy!=1) Setpos(xg[i].xgx,xg[i].xgy),cout<<" ",xg[i].xgy--,Setpos(xg[i].xgx,xg[i].xgy),Color(4),cout<<"▼"; else if (xg[i].fx==1) xg[i].fx=0;else xg[i].fx=1;} for (int i=1;i<=k;i++){ if (xg[i].xgx==x&&xg[i].xgy==y&&xg[i].sw==0&&hd==0) {system("cls");cout<<"怪物啊!!!";Sleep(2000);system("cls");return 0;} else if (xg[i].xgx==x&&xg[i].xgy==y&&hd>0&&xg[i].sw==0) {system("cls");cout<<"护盾保护了你!";Sleep(1000);system("cls");map1(x,y,k);hd--;xg[i].sw=1;}} if (ch[x][y]==')') {system("cls");cout<<"You Win!";Sleep(2000);system("cls");win=1;} if (ch[x][y]=='*') {system("cls");cout<<"你找到了钥匙!";ys++;Sleep(1000);system("cls");map1(x,y,k);ch[x][y]=' ';} if (ch[x][y]=='.') {system("cls");cout<<"你破坏了水晶!";sj++;Sleep(1000);system("cls");map1(x,y,k);ch[x][y]=' ';} if (ch[x][y]=='-'&&ys>0) {system("cls");cout<<"门开了!";ys--;Sleep(1000);system("cls");map1(x,y,k);ch[x][y]=' ';}else if (ch[x][y]=='-') {system("cls");cout<<"你没有钥匙!";--x;Sleep(3000);system("cls");map1(x,y,k);} if (ch[x][y]=='+') {system("cls");cout<<"你找到了护盾!";hd++;Sleep(1000);system("cls");map1(x,y,k);ch[x][y]=' ';} if (ch[x][y]=='o'&&hd==0) {system("cls");cout<<"烫死啦!!!";Sleep(2000);return 0;} else if (hd>0&&ch[x][y]=='o') {system("cls");cout<<"护盾保护了你!";ch[x][y]=' ';hd--;Sleep(1000);system("cls");map1(x,y,k);} if (ch[x][y]=='^'&&T%20<10&&hd==0) {system("cls");cout<<"被刺穿啦!!!";Sleep(2000);return 0;} else if (hd>0&&ch[x][y]=='^'&&T%20<10) {system("cls");cout<<"护盾保护了你!";ch[x][y]=' ';hd--;Sleep(1000);system("cls");map1(x,y,k);} if ((a==3||a==6)&&sj==4) {system("cls");cout<<"你過關! 你过关!";Sleep(2000);system("cls");win=1;} for (int i=1;i<=k;i++) if (xg[i].xgx==x&&xg[i].xgy==y&&xg[i].sw==0&&hd==0) {system("cls");cout<<"怪物啊!!!";Sleep(1000);system("cls");return 0;} else if (xg[i].xgx==x&&xg[i].xgy==y&&hd>0&&xg[i].sw==0) {system("cls");cout<<"护盾保护了你!";Sleep(1000);system("cls");map1(x,y,k);map1(x,y,k);hd--;xg[i].sw=1;} if(win==1){if(a==1)sl=1;if(a==2)mg=1;if(a==3)hp=1;if(a==4)hss=1;if(a==5)hsx=1;return 0;} Sleep(100); } } void ml(){while(1){ system("cls");Color(0); cout<<"1、迷雾森林 ";cout<<endl; if (sl==0) cout<<"2、 ? ? ? ? ";else cout<<"2、巨石迷宫(图中如果走可穿透墙,能避开所有的怪) "; cout<<endl; if (mg==0) cout<<"3、 ? ? ? ? ";else cout<<"3、熔岩喷泉(BOSS,图中随机出现熔岩) ";cout<<endl; if (hp==0) cout<<"4、 ? ? ? ? ";else cout<<"4、火山口(上) ";cout<<endl; if (hss==0) cout<<"5、 ? ? ? ? ";else cout<<"5、火山口(下) ";cout<<endl; if (hsx==0) cout<<"6、 ? ? ? ? ";else cout<<"6、火山祭坛(BOSS)";cout<<endl; cout<<"选择关卡(序号)"<<endl;cout<<"退出输入0"<<endl; int a;cin>>a; if (a==1) {yx(1);}if (a==2&&sl==1){yx(2);}if (a==3&&mg==1) {yx(3);}if (a==4&&hp==1) {yx(4);}if (a==5&&hss==1){yx(5);}if (a==6&&hsx==1){yx(6);}if (a==0) cout << "再见!" << endl;return; }} void gz() { system("cls"); cout<<"由上下左右键控制"<<endl; cout<<"●是你"<<endl; cout<<"■是墙"<<endl; cout<<"☆是终点"<<endl; cout<<"▼是小怪(只会左右移动)"<<endl; cout<<"▋是门"<<endl; cout<<"♂是钥匙"<<endl; cout<<"◆是护盾(不可杀怪)"<<endl; cout<<"■是可穿透墙(每一关几乎都有)"<<endl; cout<<"◆是水晶(BOSS关破坏所有水晶通关)"<<endl; cout<<"~ 是熔岩"<<endl; cout<<"▁是尖刺(未升起)"<<endl; cout<<"▲是尖刺(升起)"<<endl; cout<<"输入1开始!"<<endl; int a; cin>>a; if (a==1) ml(); else gz(); } int main(){ CONSOLE_CURSOR_INFO cursor_info={1,0};SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);srand((unsigned)time(NULL)); cout<<"欢迎来到超级迷宫!"<<endl;cout<<"1、开始!"<<endl;cout<<"2、规则..."<<endl; int a;cin>>a;if (a==1){system("cls");ml();}else if (a==2){gz();} return 0; }
//俄罗斯转盘 #include<bits./stdc++.h> using namespace std; int luen=1/*第几轮*/,ye/*谁先*/,sh=1/*伤害*/,xl[2]/*第一和第二个人的血量*/,\ m=0,bns,a,ans,yi[3][5];bool b[101]/*弹夹的顺序*/; bool dj(int a,int y,int s){ if(yi[y][a]==100){ cout<<"您已用过了"<<endl; return 0; } if(yi[y][a]==1){ xl[y-1]++; yi[y][a]=100; } if(yi[y][a]==2){ if(b[s]==1)cout<<"真弹"<<endl; else cout<<"假弹"<<endl;yi[y][a]=100; } if(yi[y][a]==3 ) { sh++;yi[y][a]=100; } if(yi[y][a]==4)ye++;yi[y][a]=100; return 1; } int main(){ srand(time(0)); string x[5]={" ","中华","放大镜","小刀","手铐"}; //给一号分配道具 cout<<"1号:"; for(int i=1;i<=4;i++){ a=rand()%4+1; yi[1][i]=a; cout<<' '<<x[a]; } //给二号分配道具 cout<<endl<<"2号:"; for(int i=1;i<=4;i++){ a=rand()%4+1; yi[2][i]=a; cout<<' '<<x[a]; } //随机弹夹 for(int i=1;i<=100;i++){ a=rand()%2; b[i]=(bool)a; } //告诉大家有几个实弹和几个假弹 bns=ans=2; a=rand()%10+1; for(long long i=1;i<=a;i++){ if(b[i]==1)ans++; else bns++; } cout<<endl<<"实弹"<<ans<<"颗"<<endl; cout<<"空弹"<<bns<<"颗"<<endl; //开始游戏回合 ye=1; xl[1]=xl[0]=3; while(true){ sh=1; cout<<"到"<<ye++<<"号"<<endl<<"要使用第几个道具?(不使用按0,只能使用一个)"; bns=ye-1; if(ye==1)ye=2; else ye=1; cin>>ans; if(dj(ans,ye,luen)==0){ continue; } cout<<"朝第几号打"; cin>>m; if(b[luen]==1){ xl[m-1]-=sh; cout<<"打中了它"<<endl; }else cout<<"没打中它"<<endl; cout<<xl[0]<<endl<<xl[1]<<endl<<endl; luen++; if(m==ye)ye++; if(ye==1)ye=2; else ye=1; if(xl[1]<=0){ cout<<"二号死了"; break; } if(xl[0]<=0){ cout<<"一号死了"; break; } } }
//黑客帝国 #include<windows.h> LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); typedef struct tagCharChain{ struct tagCharChain *prev; TCHAR ch; struct tagCharChain *next; }CharChain,*pCharChain; typedef struct tagCharColumn{ CharChain *head,*current,*point; int x,y,iStrLen; int iStopTimes,iMustStopTimes; }CharColumn,*pCharColumn; int main(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow){ static TCHAR szAppName[]=TEXT("matrix"); HWND hwnd; MSG msg; WNDCLASS wndclass; wndclass.style=CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc=WndProc; wndclass.cbClsExtra=0; wndclass.cbWndExtra=0; wndclass.hInstance=hInstance; wndclass.hIcon=LoadIcon(NULL,IDI_APPLICATION); wndclass.hCursor=LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH); wndclass.lpszMenuName=NULL; wndclass.lpszClassName=szAppName; if (!RegisterClass(&wndclass)){ MessageBox(NULL,TEXT("此程序必须运行在Windows下!"),szAppName,MB_ICONERROR); return 0; } hwnd=CreateWindow(szAppName,NULL,WS_DLGFRAME | WS_THICKFRAME | WS_POPUP,0,0,GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),NULL,NULL,hInstance,NULL); ShowWindow(hwnd,SW_SHOWMAXIMIZED); UpdateWindow(hwnd); ShowCursor(FALSE); srand((int)GetCurrentTime()); while (GetMessage(&msg,NULL,0,0)){ TranslateMessage(&msg); DispatchMessage(&msg); } ShowCursor(TRUE); return msg.wParam; } TCHAR randomChar() { return (TCHAR)(rand()%93+33); } int init(CharColumn *cc,int cyScreen,int x){ int j; cc->iStrLen=rand()%17+8; cc->x=x+3; cc->y=rand()%3 ? rand()%cyScreen : 0; cc->iMustStopTimes=rand()%6; cc->iStopTimes=0; cc->head=cc->current =(pCharChain)calloc(cc->iStrLen,sizeof(CharChain)); for (j=0; j < cc->iStrLen - 1; j++){ cc->current->prev=cc->point; cc->current->ch='\0'; cc->current->next=cc->current+1; cc->point=cc->current++; } cc->current->prev=cc->point; cc->current->ch='\0'; cc->current->next=cc->head; cc->head->prev=cc->current; cc->current=cc->point=cc->head; cc->head->ch=randomChar(); return 0; } LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){ HDC hdc; int i,j,temp,ctn; static HDC hdcMem; HFONT hFont; static HBITMAP hBitmap; static int cxScreen,cyScreen; static int iFontWidth=10,iFontHeight=15,iColumnCount; static CharColumn *ccChain; switch (message){ case WM_CREATE: cxScreen=GetSystemMetrics(SM_CXSCREEN); cyScreen=GetSystemMetrics(SM_CYSCREEN); SetTimer(hwnd,1,10,NULL); hdc=GetDC(hwnd); hdcMem=CreateCompatibleDC(hdc); hBitmap=CreateCompatibleBitmap(hdc,cxScreen,cyScreen); SelectObject(hdcMem,hBitmap); ReleaseDC(hwnd,hdc); hFont=CreateFont(iFontHeight,iFontWidth - 5,0,0,FW_BOLD,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DRAFT_QUALITY,FIXED_PITCH | FF_SWISS,TEXT("Fixedsys")); SelectObject(hdcMem,hFont); DeleteObject(hFont); SetBkMode(hdcMem,TRANSPARENT); iColumnCount=cxScreen / (iFontWidth * 3 / 2); ccChain=(pCharColumn)calloc(iColumnCount,sizeof(CharColumn)); for (i=0; i < iColumnCount; i++)init(ccChain+i,cyScreen,(iFontWidth * 3 / 2)*i); return 0; case WM_TIMER: hdc=GetDC(hwnd); PatBlt(hdcMem,0,0,cxScreen,cyScreen,BLACKNESS); for (i=0; i < iColumnCount; i++){ ctn=(ccChain+i)->iStopTimes++ > (ccChain+i)->iMustStopTimes; (ccChain+i)->point=(ccChain+i)->head; SetTextColor(hdcMem,RGB(255,255,255)); TextOut(hdcMem,(ccChain+i)->x,(ccChain+i)->y,&((ccChain+i)->point->ch),1); j=(ccChain+i)->y; (ccChain+i)->point=(ccChain+i)->point->next; temp=0; while((ccChain+i)->point!=(ccChain+i)->head&&(ccChain+i)->point->ch){ SetTextColor(hdcMem,RGB(0,255-(255*(temp++)/(ccChain+i)->iStrLen),0)); TextOut(hdcMem,(ccChain+i)->x,j-=iFontHeight,&((ccChain+i)->point->ch),1); (ccChain+i)->point=(ccChain+i)->point->next; } if(ctn)(ccChain+i)->iStopTimes=0; else continue; (ccChain+i)->y += iFontHeight; if((ccChain+i)->y - (ccChain+i)->iStrLen*iFontHeight > cyScreen){ free((ccChain+i)->current); init(ccChain+i,cyScreen,(iFontWidth * 3 / 2)*i); } (ccChain+i)->head=(ccChain+i)->head->prev; (ccChain+i)->head->ch=randomChar(); } BitBlt(hdc,0,0,cxScreen,cyScreen,hdcMem,0,0,SRCCOPY); ReleaseDC(hwnd,hdc); return 0; case WM_RBUTTONDOWN: KillTimer(hwnd,1); return 0; case WM_RBUTTONUP: SetTimer(hwnd,1,10,NULL); return 0; case WM_KEYDOWN: case WM_LBUTTONDOWN: case WM_DESTROY: KillTimer(hwnd,1); DeleteObject(hBitmap); DeleteDC(hdcMem); for(i=0;i<iColumnCount;i++)free((ccChain+i)->current); free(ccChain); PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,message,wParam,lParam); }
mythware_super_password
-
最近活动
- 铁外信息学C班6月份作业 作业
- 铁外C班信息学五月份作业 作业
- D班--第九周周中习题 作业
- 第四届 TYCPC 程序设计大赛(重现补题赛) IOI
- 铁外初级组四月份作业 作业
- D班-第六周周末练习题 作业
- D班——倍增算法 作业
- D班——动规加强(区间环形DP/多维DP/差值DP) 作业
- D班-第三周周末练习题 作业
- 铁外初级组二、三月份 作业
- D班——区间DP之区间合并 作业
- D班——区间DP之区间分割 作业
- D班——搜索算法作业题 作业
- 2024预备班复活赛 OI
- 【oiClass公益赛】2025CSP-J模拟赛#16 OI
- 【oiClass公益赛】2025CSP-J模拟赛#15 OI
- 【oiClass公益赛】2025CSP-J模拟赛#14 OI
- 【oiClass公益赛】2025CSP-J模拟赛#13 OI
- 【oiClass公益赛】2025CSP-J模拟赛#12 OI
- 【oiClass公益赛】2025CSP-J模拟赛#11 OI
- 【oiClass公益赛】2025CSP-J模拟赛#10 OI
- 【oiClass公益赛】2025CSP-J模拟赛#09 OI
- 【oiClass公益赛】2025CSP-J模拟赛#08 OI
- 【oiClass公益赛】2025CSP-J模拟赛#07 OI
- 【oiClass公益赛】2025CSP-J模拟赛#06 OI
- 【oiClass公益赛】2025CSP-J模拟赛#05 OI
- 【oiClass公益赛】2025CSP-J模拟赛#04 OI
- 【oiClass公益赛】2025CSP-J模拟赛#03 OI
- 【oiClass公益赛】2025CSP-J模拟赛#02 OI
- 【oiClass公益赛】2025CSP-J模拟赛#01 OI
- 结营测试改题 IOI
- D班——背包动态规划2 作业
- D班——背包动态规划1 作业
- D班——二维动规之最长公共子序列 作业
- D班——二维线性动态规划规 作业
- 2024小六冬令营——二维线性动态规划规 作业
- D班——线性动规之子序列问题 作业
- D班——线性动态规划基础 作业
- D班——二分搜索 作业
- D班——二分算法 作业
- D班——队列 作业
- D班——广度优先搜索 作业
- 2024小六冬令营《队列》 作业
- 铁外信息学作业-CD班(25年1月-循环结构、数组) 作业
- 2024预备——期末测试改题 IOI
- 2024预备--深度优先搜索算法2 作业
- 2024预备--深度优先搜索算法 作业
- 2024预备--递归算法加强 作业
- 2024预备--递归算法入门 作业
- 第三届TYCPC重现赛 ACM/ICPC
- 铁外初级组十二月份 作业
- 2024预备班--阶段测试5 OI
- 2024预备--第13周周中练习 作业
- 2024预备班11月阶段测试(订正) IOI
- 2024预备--栈 作业
- 2024预备--差分前缀和 作业
- CSP-X2024 山东小学组二轮试题(下半场) 作业
- CSP-X2024 山东小学组二轮试题(上半场) 作业
- 2024预备--贪心算法 作业
- 2024预备--枚举算法 作业
- 2024预备--模拟算法 作业
- 铁外初级组十一月份(一) 作业
- 2024预备--阶段测试3(预备班”想想前三名将获取什么奖品“杯小赛一场) OI
- 2024预备--第八周加练题单 作业
- 2024预备--指针&结构体&排序 作业
- 铁外初级组十月份(一) 作业
- 2024预备班10月阶段测试 OI
- 2024预备--位运算 作业
- 2024预备--进制转换 作业
- 2024预备--函数 作业
- 2024预备--第四周周中习题 作业
- 2024预备班阶段测试1 OI
- D班——差值DP/双指针 作业
- 2024预备--字符、字符串加强练习 作业
- 2024预备--习题订正 作业
- 2024预备--二维数组基础 作业
- 2024oiClass入门组周赛计划#18 IOI
- 2024oiClass入门组周赛计划#17 IOI
- 2024oiClass入门组周赛计划#16 IOI
- 2024oiClass入门组周赛计划#15 IOI
- 2024oiClass入门组周赛计划#14 IOI
- 2024oiClass入门组周赛计划#13 IOI
- 2024oiClass入门组周赛计划#12 IOI
- 2024oiClass入门组周赛计划#11 IOI
- 2024oiClass入门组周赛计划#10 IOI
- 2024oiClass入门组周赛计划#09 IOI
- 2024oiClass入门组周赛计划#08 IOI
- 2024新苗-递推算法基础 作业
- 2024新苗--排序算法基础 作业
- 2024新苗--字符、字符数组、字符串 作业
- 2024新苗--数组标记的应用 作业
- 2024新苗--一维数组基础 作业
- 2024新苗--多重循环 作业
- 2024新苗班阶段测试2 OI
- 2024新苗--while2 作业
- 2024新苗--循环语句(while语句1) 作业
- 2024新苗--数据的在线处理 作业
- 2024新苗班阶段测试一(下午班) OI
- 2024新苗--枚举和筛选 作业
- 2024新苗--循环语句(for语句1) 作业
- 2024新苗--选择结构 作业
- 2024新苗--表达式 作业
- 2024新苗--C++程序结构 作业
-
Stat
-
Rating