#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
int allscore=0;
int playtime=0;
string player="wzh";
int main();
void printword(string a){/*打字*/
for(int i=0;i
}
}
void reset(){/*重置界面*/
system("cls");
system("color 0f");
system("title wzh的游戏空间");
}
void rest(){/*暂停*/
system("pause");
}
int random(int a,int b){/*随机数*/
mt19937 rnd(time(NULL));
b-=a;
return (rnd()%b)+a;
}
void all(){/*全屏*/
HWND hwnd=GetForegroundWindow();
int x=GetSystemMetrics(SM_CXSCREEN)+300;
int y=GetSystemMetrics(SM_CYSCREEN)+300;
char setting[30];
sprintf(setting,"mode con:cols=%d lines=%d",x,y);
system(setting);
SetWindowPos(hwnd,HWND_TOPMOST,0,0,x+300,y+300,NULL);
MoveWindow(hwnd,-10,-40,x+300,y+300,1);
}
void hide(){/*隐藏鼠标*/
DWORD dwFlags;
DWORD dx;
DWORD dy;
DWORD dwData;
DWORD dwExtraInfo;
}
void start(){/*开始界面*/
CONSOLE_CURSOR_INFO cursor_info={1,0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cursor_info);
reset();
string a=" ";
string b="===============================================================";
cout<
}
void write(){/*获得存档*/
reset();
string a,b;
vector
int e=allscore;
while(e){
a+=e%10;
e/=10;
}
cout<<"请输入你的游戏昵称:";
string d;
getline(cin,d);
for(int i;i<=d.size();i++){
if(d[i]=='z'){
d[i]='a';
}else if(d[i]>='a'&&d[i]<='z'){
d[i]+=5;
}
}
for(int i=0;i
case('0'):
c.push_back(1111);
break;
case('1'):
c.push_back(1110);
break;
case('2'):
c.push_back(1101);
break;
case('3'):
c.push_back(1100);
break;
case('4'):
c.push_back(1011);
break;
case('5'):
c.push_back(1010);
break;
case('6'):
c.push_back(1001);
break;
case('7'):
c.push_back(1000);
break;
case('8'):
c.push_back(0111);
break;
case('9'):
c.push_back(0110);
break;
}
}
cout<<"创建存档完成,存档码:";
for(int i=0;i
cout<<" "<
main();
}
void read(){/*读取存档*/
reset();
cout<<"请输入存档码:";
char g;
bool e=1;
string a,b;
string s;
getline(cin,s);
for(int i=0;i
e=0;
}
if(e){
a+=s[i];
}else{
b+=s[i];
}
}
int n;
vector
for(int i=0;i
for(int i=0;i<4;i++){
d+=a[i];
}
if(d=="1111"){
c.push_back(0);
n++;
}else if(d=="1110"){
c.push_back(1);
n++;
}else if(d=="1101"){
c.push_back(2);
n++;
}else if(d=="1100"){
c.push_back(3);
n++;
}else if(d=="1011"){
c.push_back(4);
n++;
}else if(d=="1010"){
c.push_back(5);
n++;
}else if(d=="1001"){
c.push_back(6);
n++;
}else if(d=="1000"){
c.push_back(7);
n++;
}else if(d=="0111"){
c.push_back(8);
n++;
}else if(d=="0110"){
c.push_back(9);
n++;
}else{
cout<<"存档开启失败";
main();
}
allscore=0;
}
while(n){
allscore*10+c[n-1];
n-=1;
}
for(int i=b.size()-1;i>=0;i--){
if(b[i]=='a'){
b[i]='z';
}else if(b[i]>='a'&&b[i]<=char('z'+4)){
b[i]-=5;
}
}
player=b;
reset();
cout<<"存档开启成功"<
main();
}
void dbza(){/*躲避障碍*/
reset();
int w=10,a=0,fs=0;
while(1){
int d=random(1,18);
for(int n=0;n<10;n++){
for(int i=0;i<10;i++){
for(int t=0;t<20;t++){
if(i==a&&t==d){
cout<<"v";
}else if(i==9&&t==w||(i==8&&t==w)){
cout<<"^";
}else{
cout<<" ";
}if((i==8||i==9)&&(d==w)){
reset();
cout<<"游戏结束,得分:"<
Sleep(1000);
main();
}
}
cout<
cout<<"A向左,D向右";
a+=1;
if(KEY_DOWN('A')){
w-=1;
}else if(KEY_DOWN('D')){
w+=1;
}
if(w>18){
w=18;
}else if(w<1){
w=1;
}
if(KEY_DOWN('P')){
reset();
rest();
}
Sleep(100);
reset();
}
a=0;
fs+=1;
}
}
void sj(){/*手速射击*/
reset();
int x=0;
cout<<"按K射击";
char map[10][10]={{'\\',' ',' ',' ',' ',' ',' ',' ',' ','/'},
{' ','\\',' ',' ',' ',' ',' ',' ','/',' '},
{' ',' ','\\',' ',' ',' ',' ','/',' ',' '},
{' ',' ',' ','\\',' ',' ','/',' ',' ',' '},
{' ',' ',' ',' ','\\','/',' ',' ',' ',' '},
{' ',' ',' ',' ','/','\\',' ',' ',' ',' '},
{' ',' ',' ','/',' ',' ','\\',' ',' ',' '},
{' ',' ','/',' ',' ',' ',' ','\\',' ',' '},
{' ','/',' ',' ',' ',' ',' ',' ','\\',' '},
{'/',' ',' ',' ',' ',' ',' ',' ',' ','\\'},};
bool cg=0;
Sleep(2000);
Sleep(random(1,10)*100);
reset();
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
cout<
cout<
if(KEY_DOWN('K')){
reset();
cout<<"游戏失败";
Sleep(2000);
main();
}
for(int i=0;i<1000000;i++){
if(KEY_DOWN('K')){
reset();
cout<<"游戏成功,得分:"<<100-i/10000<
Sleep(2000);
cout<<"游戏结束";
Sleep(2000);
cg=1;
break;
}
}
if (cg==0){
reset();
cout<<"游戏失败"<
cout<<"游戏结束";
Sleep(2000);
}
main();
}
void kltyt(){/*恐龙跳一跳*/
reset();
int z=0,d=30,lc=0,lq=0;
Sleep(2000);
while(1){
for(int n=1;n<=30;n++){
reset();
for(int i=1;i<=25;i++){
cout<<" ";
}
printf("%06d", lc);
cout<
cout<<"$";
}
cout<
if(i==1&&z==0){
cout<<"$";
}
if(i==d){
cout<<"^";
}else{
cout<<" ";
}
}
cout<
cout<<"=";
}
cout<
z=1;
lq-=2;
}else{
z=0;
lq+=1;
}
if(KEY_DOWN('P')){
reset();
rest();
}
d-=1;
lc+=1;
if(d==1&&z==0){
reset();
cout<<"游戏失败,路程:"<
Sleep(2000);
cout<<"游戏结束";
Sleep(2000);
main();
}
Sleep(100);
}
d=30;
}
}
void ydxr(){/*移动小人*/
reset();
cout<<"加载中";
int bx,by;
do{
bx=random(1,9);
}while(bx==5);
do{
by=random(1,9);
}while(by==5);
int x=4,y=4;
reset();
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
if(i==by&&j==bx){
cout<<"¥";
}else if(i==y&&j==x){
cout<<"()";
}else{
cout<<"_.";
}
}
cout<
cout<<"输入提示:W上S下A左D右 '()为人' '¥为宝藏'"<
getline(cin,a);
for(int i=0;i
case 'W':
y-=1;
break;
case 'S':
y+=1;
break;
case 'A':
x-=1;
break;
case 'D':
x+=1;
break;
case 'w':
y-=1;
break;
case 's':
y+=1;
break;
case 'a':
x-=1;
break;
case 'd':
x+=1;
break;
}
reset();
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
if(i==by&&j==bx&&i==y&&j==x){
cout<<"(¥)";
}else if(i==by&&j==bx){
cout<<"¥";
}else if(i==y&&j==x){
cout<<"()";
}else{
cout<<"_ ";
}
}
cout<
Sleep(500);
}
if(x==bx&&y==by){
reset();
cout<<"游戏成功,路程:"<
Sleep(2000);
cout<<"游戏结束";
Sleep(2000);
main();
}else{
cout<<"游戏失败"<
cout<<"游戏结束";
Sleep(2000);
main();
}
}
void sl(){/*扫雷*/
reset();
int pl=0,lx,cx,cy,ly;
int sz[100][100]={0},seemap[100][100]={0},dx[8]={-1,-1,0,0,-1,1,-1,1},dy[8]={0,0,-1,1,1,-1,-1,1},sum=0;
for(int i=1;i<=10;i++){
reset();
cout<<"加载中,已加载雷数量:"< lx=random(1,10);
ly=random(1,10);
while(sz[lx][ly]==9){
lx=random(1,10);
ly=random(1,10);
}
sz[lx][ly]=9;
for(int o=0;o<8;o++){
if(sz[lx+dx[o]][ly+dy[o]]!=9){
sz[lx+dx[o]][ly+dy[o]]+=1;
}
}
}
reset();
cout<<"加载完成";
while(1){
reset();
cout<<" ";
for(int i=1;i<=10;i++){
printf("%3.d ",i);
}
cout<
for(int j=-1;j<=9;j++){
if(j==-1){
printf("%2.d ",i+1);
continue;
}
if(seemap[i][j]==1){
cout<<" "<
cout<<" __ ";
}
}
cout<
Sleep(1000);
if(sum>=90){
reset();
cout<<"游戏成功"<
Sleep(2000);
cout<<"游戏结束";
Sleep(2000);
main();
}
cout<<"请输入需要排查的地方在第几列:";
cin>>cx;
cout<
while(cx<1||cx>10){
cout<
}
while(cy<1||cy>10){
cout<
}
cy-=1;
sum+=1;
cx-=1;
swap(cy,cx);
int ch=sz[cx][cy];
if(ch==9){
reset();
cout<<"游戏失败"<
cout<<"游戏结束";
Sleep(2000);
main();
}
queue
x.push(cx);
y.push(cy);
seemap[cx][cy]=1;
while(!(x.empty()&&y.empty())){
int nx=x.front();
int ny=y.front();
x.pop();
y.pop();
for(int i=0;i<4;i++){
int tx=nx+dx[i];
int ty=ny+dy[i];
if(0<=tx&&tx<10&&0<=ty&&ty<10&&((sz[tx][ty]==ch)||(sz[tx][ty]!=8&&sz[tx][ty]==char(ch+1)))&&seemap[tx][ty]==0){
x.push(tx);
y.push(ty);
seemap[tx][ty]=1;
sum+=1;
}
}
}
}
}
void tcs(){/*贪吃蛇*/
reset();
int nx=4,ny=4,score=0,abcd,sp=0,ax,ay,ox=3,oy=3;
char zf;
abcd%=4;
ax=random(1,9);
ay=random(1,9);
queue
x.push(4);
y.push(4);
while(1){
reset();
cout<<"分数:"<
for(int j=0;j<10;j++){
bool c=1;
for(int d=0;d
zf='*';
c=0;
}
x.push(x.front());
y.push(y.front());
x.pop();
y.pop();
}
if(j==x.front()&&i==y.front()){
if(j==ax&&i==ay){
score+=1;
x.push(ox);
y.push(oy);
for(int d=0;d
y.push(y.front());
x.pop();
y.pop();
}
ax=random(1,9);
ay=random(1,9);
}
switch(abcd){
case 1:
zf='^';
break;
case 2:
zf='V';
break;
case 3:
zf='<';
break;
case 4:
zf='>';
break;
}
c=0;
}
if(i==ax&&j==ay){
zf='X';
c=0;
}
x.push(x.front());
y.push(y.front());
ox=x.front();
oy=y.front();
x.pop();
y.pop();
if(c){
cout<<"_ ";
}else{
cout<
}
cout<
cout<<"W上S下A左D右 'O为蛇头' 'X为苹果'";
if(KEY_DOWN('W')){
abcd=1;
}
if(KEY_DOWN('S')){
abcd=2;
}
if(KEY_DOWN('A')){
abcd=3;
}
if(KEY_DOWN('D')){
abcd=4;
}
if(KEY_DOWN('P')){
reset();
rest();
}
if(nx>=10||ny>=10||nx<0||ny<0){
reset();
cout<<"游戏失败,分数:"<
Sleep(2000);
cout<<"游戏结束";
Sleep(2000);
main();
}
if(sp%3==0){
switch(abcd){
case 1:
ny-=1;
break;
case 2:
ny+=1;
break;
case 3:
nx-=1;
break;
case 4:
nx+=1;
break;
}
x.pop();
y.pop();
x.push(nx);
y.push(ny);
}
sp+=1;
Sleep(100);
}
}
int main(){
reset();
string yx;
start();
cout<<"请选择游戏,游戏编号:";
getline(cin,yx);
while(1){
switch(yx[yx.size()-1]){
case 'a':
exit(0);
break;
case 'b':
all();
break;
case 'c':
hide();
break;
case 'd':
write();
break;
case 'e':
read();
break;
case 'A':
exit(0);
break;
case 'B':
all();
break;
case 'C':
hide();
break;
case 'D':
write();
break;
case 'E':
read();
break;
case '1':
dbza();
break;
case '2':
sj();
break;
case '3':
kltyt();
break;
case '4':
ydxr();
break;
case '5':
sl();
break;
case '6':
tcs();
break;
default:
start();
cout<<"没有找到这个游戏,请重新选择游戏,游戏编号:";
getline(cin,yx);
}
}
}