#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
#define KEY_DOWN(VK_SPACE) ((GetAsyncKeyState(VK_SPACE) & 0x8000) ? 1:0)
#define ll long long
#define ull unsigned ll
using namespace std;
int x = 30, y = 1, jump, level = 1, Level = 1;
int dx[] = {-1, 30};
int dy[] = {-1, 1};
string maps[100][31] = {
{
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
},
{
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" @ ",
" ",
" ---=^^^ ",
" ----^ ",
" ----^ ",
" ----^ ",
" ----^ ",
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
}
};
void Get_Key(bool* flag){
char c = 'N';
if(KEY_DOWN('r') || KEY_DOWN('R')){
x = dx[level];
y = dy[level];
*flag = true;
return;
}
if(KEY_DOWN('d') || KEY_DOWN('D')){
c = 'Y';
if((maps[level][x][y] != '-' || maps[level][x][y] != '=') && y + 1 < 120){
y++;
}
}
if(KEY_DOWN('a') || KEY_DOWN('A')){
c = 'Y';
if((maps[level][x][y - 2] != '-' || maps[level][x][y - 2] != '=') && y - 1 > 0){
y--;
}
}
if(KEY_DOWN('w') || KEY_DOWN('W')){
c = 'Y';
if(jump == 0 && (maps[level][x + 1][y - 1] == '-' || x == 30)){
jump = 4;
}
}
if(c != 'N'){
*flag = true;
}
}
void _jump(bool* flag){
if((maps[level][x - 1][y - 1] != '-' || maps[level][x - 1][y - 1] != '=') && x - 1 > 0){
*flag = true;
x--;
}else if(maps[level][x - 1][y - 1] == '-' || maps[level][x - 1][y - 1] == '='){
jump = 0;
}
}
void down(bool* flag){
if((maps[level][x + 1][y - 1] != '-' && maps[level][x + 1][y - 1] != '=') && x + 1 < 31){
*flag = true;
x++;
jump--;
}else{
jump = 0;
}
}
void print(string s){
for(int i = 0; i < s.size(); i++){
Sleep(50);
cout << s[i];
}
}
int main(){
string s;
for(int i = 1; i <= 30; i++){
for(int j = 1; j <= 119; j++){
if(i == x && j == y){
s += "P";
}else{
s += maps[level][i][j - 1];
}
}
if(i != 30){
s += "\n";
}
}
cout << s;
bool ts = false;
while(1){
bool flag = false;
if(!ts){
Get_Key(&flag);
}
if(jump > 0){
_jump(&flag);
}else{
down(&flag);
}
if(jump){
jump--;
}
if(ts){
flag = true;
ts = false;
}
if(flag){
bool win = false, die = false;
Sleep(70);
system("cls");
string s;
for(int i = 1; i <= 30; i++){
for(int j = 1; j <= 119; j++){
if(i == x && j == y){
if(maps[level][i][j - 1] == '@'){
win = true;
}
if(maps[level][i][j - 1] == '^'){
die = true;
}
if(maps[level][i + 1][j - 1] == '='){
jump = 10;
ts = true;
}
s += "P";
}else{
s += maps[level][i][j - 1];
}
}
if(win){
break;
}
if(die){
break;
}
if(i != 30){
s += "\n";
}
}
cout << s;
if(win){
system("cls");
Sleep(500);
print("\n\n\n\n\n\n\n\n\n\n You win!!!");
Sleep(1000);
level++;
if(level > Level){
print("\n\n\n\n Game Clear!!!!!!\n\n 感谢游玩!!!!!!\n\n\n\n\n\n\n\n\n\n");
return 0;
}
x = dx[level];
y = dy[level];
}
if(die){
x = dx[level];
y = dy[level];
ts = true;
}
}
}
return 0;
}