【游戏】心房
Dimly_dust · · 个人记录
瞎搞的作品,感觉现阶段跟 chaser-games 没什么区别,加了点彩蛋吧。(文案将就看)
这只是开始,后阶段还未开始施工。。。。
#include <bits/stdc++.h>
#include <windows.h>
#include <conio.h>
using namespace std;
struct node
{
int x,y;
} point[1000];
bool flag[50][50];
int chNum=100,Pass=1,Stops=false;
const int _oC = 277, _oD = 311, _oF = 370, _oG = 415, _oA = 466;
const int _C = 262, _D = 294, _E = 330, _F = 349, _G = 392, _A = 440, _B = 494;
const int oC = 554, oD = 622, oF = 740, oG = 831, oA = 932;
const int C = 523, D = 578, E = 659, F = 698, G = 784, A = 880, B = 988;
const int C_ = 1047, D_ = 1175, E_ = 1319, F_ = 1397, G_ = 1568, A_ = 1760, B_ = 1976;
const int oC_ = 1109, oD_ = 1245, oF_ = 1480, oG_ = 1661, oA_ = 1865;
const int T = 400; //一拍的长度
const int Stop = 800; //一拍休止符的长度
void print()
{
for(int i=1; i<=38; i++)
{
for(int j=1; j<=45; j++)
if(i==1||i==38||j==1||j==45) cout<<"▉";
else cout<<" ";
}
}
void go(int x,int y)
{
COORD pos;
pos.X=2*x;
pos.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void color(int colour)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),colour);
}
void win_sound()
{
Beep(oC,T);
Beep(oD_,T);
Beep(E,T);
Beep(A,T);
Beep(C,T);
Beep(oG,T);
}
void common_sound()
{
for(;;)
{
Beep(D,T);
Beep(B,T);
Beep(A,T);
Beep(C,T);
Beep(B,T);
Beep(C,T);
Beep(F,T);
Beep(G,T);
if(rand()%2==0)
{
Beep(C,T*0.5);
Beep(E,T*2);
Beep(C,T);
Beep(F,T*2);
Beep(C,T);
Beep(D,T*1.5);
Beep(C,T*0.5);
}
Beep(A,T);
Beep(B,T);
Beep(E,T);
Beep(D,T);
Beep(C,T);
Beep(B,T);
Beep(A,T);
Beep(D,T);
if(rand()%3==0)
{
Beep(C,T*0.5);
Beep(E,T*2);
Beep(C,T);
Beep(F,T*2);
Beep(C,T);
Beep(D,T*1.5);
Beep(C,T*0.5);
}
Beep(D,T);
}
}
void Begins()
{
string str="\n\n\t\tDavid's Diary\n\n\t\t1987.10.21\t\t\t\t\tSun.\n\n\t\tI was fitted with an artificial heart in a car accident.\n\n\t\tThe doctor said, \"it's a miracle that you survived.\"\n\n\t\tMy wife said, \"how do you support your life now?\"\n\n\t\tI looked at the child and didn't speak.\n\n\t\tIn fact, I know you made a deal with the devil.\n\n\t\tAnd am willing to exchange three years of pain for survival.\n\n\t\tNow the three-year period has come.\n\n\t\tThe devil asks me to go through the boundless forest to find your heart.\n\n\n\t\tthe Diary for His Wife\n\n\t\tDear wife,\n\n\t\tMy wife,if you see this diary,I'll be gone\n\n\t\tDon't worry about me,I'll be back soon.\n\n\t\t\t\t\t\t\tYours,\n\n\t\t\t\t\t\t\tDavid";
for(int i=0; i<str.size(); i++) cout<<str[i],Sleep(10);
cout<<endl<<endl<<endl<<"\t\t";
system("pause");
system("cls");
cout<<endl<<endl<<endl<<endl<<endl;
str="关于本游戏";
cout<<"\t\t\t\t";
for(int i=0; i<str.size(); i++) cout<<str[i],Sleep(10);
cout<<endl<<endl;
str="类似Chaser game的休闲(摸鱼)游戏";
cout<<"\t\t\t";
for(int i=0; i<str.size(); i++) cout<<str[i],Sleep(100);
cout<<endl<<endl;
str="按键:W(上) S(下) D(左) A(右)";
cout<<"\t\t\t";
for(int i=0; i<str.size(); i++) cout<<str[i],Sleep(100);
cout<<endl<<endl;
system("pause");
}
void bege()
{
string str="\t 魔鬼:既来之,则安之。规矩是要守得,先度过这四关什么都好商量。▽";
go(0,10);
for(int i=0; i<str.size(); i++) cout<<str[i],Sleep(100);
char chr=getch();
go(0,13);
str="\t 魔鬼:好,豪爽。那就来吧。▽";
for(int i=0; i<str.size(); i++) cout<<str[i],Sleep(100);
system("cls");
}
DWORD WINAPI xian1(LPVOID lpParamter)
{
common_sound();
}
DWORD WINAPI xian2(LPVOID lpParamter)
{
win_sound();
}
int main()
{
//Stops=true;
system("title 心房");
system("mode con cols=90 lines=40");
Begins();
CreateThread(NULL, 1,xian1, NULL, 1, NULL);
while(1)
{
system("cls");
go(20,15);
cout<<"第";
Sleep(200);
cout<<" ";
Sleep(200);
cout<<Pass;
Sleep(200);
cout<<" ";
Sleep(200);
cout<<"关";
Sleep(200);
go(20,15);
for(int i=1; i<=6; i++) cout<<" ",Sleep(200);
system("cls");
if(Pass==1) bege();
else if(Pass==2)
{
MessageBox(NULL,"真是有趣,这么快就完成了第一关,看来要给你点难度了","魔鬼",MB_OK|MB_ICONINFORMATION);
MessageBox(NULL,"后面几关会随机出现障碍物并且增加(貌似还会动)\n但你还有15步的无障碍时间\nGood luck and have fun!","提示",MB_OK|MB_ICONINFORMATION);
}
print();
int x=2,y=2,mov=0,cx=1+rand()%42,cy=1+rand()%35;
go(x,y);
color(14);
cout<<char(1);
go(cx,cy);
color(15);
cout<<char(3);
while(1)
{
char s=getch();
int lx=x,ly=y,lcx=cx,lcy=cy;
if(s=='d'&&x<=42&&!flag[x+1][y])
{
x++;
mov++;
}
if(s=='a'&&x>=2&&!flag[x-1][y])
{
x--;
mov++;
}
if(s=='w'&&y>=2&&!flag[x][y-1])
{
y--;
mov++;
}
if(s=='s'&&y<=35&&!flag[x][y+1])
{
y++;
mov++;
}
if(ly!=y||lx!=x)
while(1)
{
int turn=1+rand()%4;
if(turn==1&&cx<=35&&!flag[cx+1][cy])
{
cx++;
break;
}
if(turn==2&&cx>=2&&!flag[cx-1][cy])
{
cx--;
break;
}
if(turn==3&&cy<=35&&!flag[cx][cy+1])
{
cy++;
break;
}
if(turn==4&&cy>=2&&!flag[cx][cy-1])
{
cy--;
break;
}
if(flag[cx-1][cy]&&flag[cx+1][cy]&&flag[cx][cy-1]&&flag[cx][cy+1])
{
mov=15;
break;
}
if(flag[cx-1][cy]&&flag[cx+1][cy]&&flag[cx][cy+1])
{
cy--;
break;
}
if(flag[cx-1][cy]&&flag[cx+1][cy]&&flag[cx][cy-1])
{
cy++;
break;
}
if(flag[cx-1][cy]&&flag[cx][cy+1]&&flag[cx][cy-1])
{
cx++;
break;
}
if(flag[cx+1][cy]&&flag[cx][cy+1]&&flag[cx][cy-1])
{
cx--;
break;
}
}
if((cx==x&&cy==y)||(cx==(x-1)&&cy==y)||(cx==(x+1)&&cy==y))
{
CreateThread(NULL, 1,xian2, NULL, 1, NULL);
if(chNum==1000)
{
MessageBox(NULL,"恭喜","全部通关",MB_ICONEXCLAMATION),exit(0);
}
char str[]="恭喜过关,你要进入下一关吗?";
int m=MessageBox(NULL,"恭喜",str,MB_YESNO|MB_ICONQUESTION);
if(m==IDYES)
{
for(int i=1; i<=chNum; i++)
flag[point[i].x][point[i].y]=false;
chNum+=(++Pass)*100;
break;
}
else exit(0);
}
go(lcx,lcy);
cout<<" ";
go(cx,cy);
color(5);
cout<<char(3);
go(lx,ly);
cout<<" ";
go(x,y);
color(14);
cout<<char(1);
go(1,38);
printf("Yours: (%d,%d) Hreat: (%d,%d) CheckNum: %d ",x,y,cx,cy,chNum);
if(mov%15==0)
{
for(int i=1; i<=chNum-100; i++)
{
go(point[i].x,point[i].y);
cout<<" ";
int rx,ry;
while(1)
{
rx=1+rand()%42,ry=1+rand()%36;
if(flag[rx][ry]||(rx==x&&ry==y)||(rx==cx&&ry==cy)) continue;
else break;
}
flag[point[i].x][point[i].y]=false;
flag[point[i].x=rx][point[i].y=ry]=true;
go(point[i].x,point[i].y);
color(7);
int xin=rand()%3;
if(xin==0) cout<<"▓";
else if(xin==1) cout<<"∷";
else cout<<"×";
}
}
}
}
return 0;
}