0
已解决
吴庞茂旭
资深光能
资深光能
耗时半年的游戏:Block World(简称BW)、创新公社出品、全问答第一个不闪屏跑酷游戏体验版!新鲜出炉!
这次,我带着我全部的游戏经验,写出了我认为全问答第一个不闪屏的跑酷游戏Block World,BW!虽然有行走这座大山,但是——我还是耗时半年第一次写出这款跑酷!
游戏截图:
代码提取:
#include <bits/stdc++.h>
#include "windows.h"
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
/*
0=黑色,1=蓝色,2=绿色,3=湖蓝色,4=红色,5=紫色;
6=黄色,7=白色,8=灰色,9=淡蓝色,A=淡绿色,B=浅绿色;
C=淡红色,D=淡紫色,E=淡黄色,F=亮白色。
*/
/*
VK_LBUTTON 鼠标左键 0x01
VK_RBUTTON 鼠标右键 0x02
VK_CANCEL Ctrl + Break 0x03
VK_MBUTTON 鼠标中键 0x04
VK_BACK Backspace 键 0x08
VK_TAB Tab 键 0x09
VK_RETURN 回车键 0x0D
VK_SHIFT Shift 键 0x10
VK_CONTROL Ctrl 键 0x11
VK_MENU Alt 键 0x12
VK_PAUSE Pause 键 0x13
VK_CAPITAL Caps Lock 键 0x14
VK_ESCAPE Esc 键 0x1B
VK_SPACE 空格键 0x20
VK_PRIOR Page Up 键 0x21
VK_NEXT Page Down 键 0x22
VK_END End 键 0x23
VK_HOME Home 键 0x24
VK_LEFT 左箭头键 0x25
VK_UP 上箭头键 0x26
VK_RIGHT 右箭头键 0x27
VK_DOWN 下箭头键 0x28
VK_SNAPSHOT Print Screen 键 0x2C
VK_Insert Insert 键 0x2D
VK_Delete Delete 键 0x2E
'0' – '9' 数字 0 - 9 0x30 - 0x39
'A' – 'Z' 字母 A - Z 0x41 - 0x5A
VK_LWIN 左WinKey(104键盘才有) 0x5B
VK_RWIN 右WinKey(104键盘才有) 0x5C
VK_APPS AppsKey(104键盘才有) 0x5D
VK_NUMPAD0 小键盘 0 键 0x60
VK_NUMPAD1 小键盘 1 键 0x61
VK_NUMPAD2 小键盘 2 键 0x62
VK_NUMPAD3 小键盘 3 键 0x63
VK_NUMPAD4 小键盘 4 键 0x64
VK_NUMPAD5 小键盘 5 键 0x65
VK_NUMPAD6 小键盘 6 键 0x66
VK_NUMPAD7 小键盘 7 键 0x67
VK_NUMPAD8 小键盘 8 键 0x68
VK_NUMPAD9 小键盘 9 键 0x69
VK_F1 - VK_F24 功能键F1 – F24 0x70 - 0x87
VK_NUMLOCK Num Lock 键 0x90
VK_SCROLL Scroll Lock 键 0x91
*/
HWND hwnd=GetForegroundWindow();//使hwnd代表最前端的窗口
void HideCursor(){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
CursorInfo.bVisible = false; //隐藏控制台光标
SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
}
//1----围墙 2----自己 3----终点 0----空地 4----箱子
int map1[21][21]={
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1},
{1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
};
void cls(){
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coordScreen = { 0, 0 }; // home for the cursor
SetConsoleCursorPosition( hConsole, coordScreen );
}
bool flag;
int main(){
system("color 30");
ShowWindow(hwnd,SW_MAXIMIZE);
system("title block world 作者:赟邢道×创新公社");
HideCursor();
//第一关
int x,y;
int i=0;
while(map1[x][y]!=3){
flag=true;
i++;
cout<<i<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map1[i][j]==1){
cout<<"■";
} else if(map1[i][j]==0){
cout<<"□";
} else if(map1[i][j]==2){
cout<<"你";
x=i,y=j;
} else if(map1[i][j]==4){
cout<<"▓";
}
else{
cout<<"旗";
flag=false;
}
}
cout<<endl;
}
if(flag){
cout<<"恭喜过关!";
break;
}
if(map1[x+1][y]!=1&&map1[x+1][y]!=4){
map1[x][y]=0;
x++;
map1[x][y]=2;
}
cls();
if(GetAsyncKeyState('D')&&y<20&&map1[x][y+1]!=1){
map1[x][y]=0;
y++;
map1[x][y]=2;
Sleep(100);
}
if(GetAsyncKeyState('A')&&y>=0&&map1[x][y-1]!=1){
map1[x][y]=0;
y--;
map1[x][y]=2;
Sleep(100);
}
if(GetAsyncKeyState('X')&&x>=0&&map1[x-1][y]!=1){
map1[x][y]=4;
x--;
map1[x][y]=2;
Sleep(100);
}
if(GetAsyncKeyState('W')&&(map1[x+1][y]==1||map1[x+1][y]==4)&&x>=0&&map1[x-3][y]!=1){
map1[x][y]=0;
x-=3;
map1[x][y]=2;
Sleep(100);
}
}
Sleep(100000);
return 0;
}
教程:
W跳跃
D向前
A向后
X放箱子
吴庞茂旭在2021-03-21 16:01:49追加了内容
我申明一下,这是体验版,只是让你们评价一下,只做了一关。
吴庞茂旭在2021-03-24 21:54:54追加了内容
#include <bits/stdc++.h>
#include "windows.h"
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
/*
0=黑色,1=蓝色,2=绿色,3=湖蓝色,4=红色,5=紫色;
6=黄色,7=白色,8=灰色,9=淡蓝色,A=淡绿色,B=浅绿色;
C=淡红色,D=淡紫色,E=淡黄色,F=亮白色。
*/
/*
VK_LBUTTON 鼠标左键 0x01
VK_RBUTTON 鼠标右键 0x02
VK_CANCEL Ctrl + Break 0x03
VK_MBUTTON 鼠标中键 0x04
VK_BACK Backspace 键 0x08
VK_TAB Tab 键 0x09
VK_RETURN 回车键 0x0D
VK_SHIFT Shift 键 0x10
VK_CONTROL Ctrl 键 0x11
VK_MENU Alt 键 0x12
VK_PAUSE Pause 键 0x13
VK_CAPITAL Caps Lock 键 0x14
VK_ESCAPE Esc 键 0x1B
VK_SPACE 空格键 0x20
VK_PRIOR Page Up 键 0x21
VK_NEXT Page Down 键 0x22
VK_END End 键 0x23
VK_HOME Home 键 0x24
VK_LEFT 左箭头键 0x25
VK_UP 上箭头键 0x26
VK_RIGHT 右箭头键 0x27
VK_DOWN 下箭头键 0x28
VK_SNAPSHOT Print Screen 键 0x2C
VK_Insert Insert 键 0x2D
VK_Delete Delete 键 0x2E
'0' – '9' 数字 0 - 9 0x30 - 0x39
'A' – 'Z' 字母 A - Z 0x41 - 0x5A
VK_LWIN 左WinKey(104键盘才有) 0x5B
VK_RWIN 右WinKey(104键盘才有) 0x5C
VK_APPS AppsKey(104键盘才有) 0x5D
VK_NUMPAD0 小键盘 0 键 0x60
VK_NUMPAD1 小键盘 1 键 0x61
VK_NUMPAD2 小键盘 2 键 0x62
VK_NUMPAD3 小键盘 3 键 0x63
VK_NUMPAD4 小键盘 4 键 0x64
VK_NUMPAD5 小键盘 5 键 0x65
VK_NUMPAD6 小键盘 6 键 0x66
VK_NUMPAD7 小键盘 7 键 0x67
VK_NUMPAD8 小键盘 8 键 0x68
VK_NUMPAD9 小键盘 9 键 0x69
VK_F1 - VK_F24 功能键F1 – F24 0x70 - 0x87
VK_NUMLOCK Num Lock 键 0x90
VK_SCROLL Scroll Lock 键 0x91
*/
HWND hwnd=GetForegroundWindow();//使hwnd代表最前端的窗口
void HideCursor(){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
CursorInfo.bVisible = false; //隐藏控制台光标
SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
}
//1----围墙 2----自己 3----终点 0----空地 4----箱子
int map1[21][21]={
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1},
{1,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
};
void cls(){
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coordScreen = { 0, 0 }; // home for the cursor
SetConsoleCursorPosition( hConsole, coordScreen );
}
bool flag;
int main(){
system("color 30");
ShowWindow(hwnd,SW_MAXIMIZE);
system("title block world 作者:赟邢道×创新公社");
HideCursor();
//第一关
int x,y;
int i=0;
while(map1[x][y]!=3){
flag=true;
i++;
cout<<i<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map1[i][j]==1){
cout<<"■";
} else if(map1[i][j]==0){
cout<<"□";
} else if(map1[i][j]==2){
cout<<"你";
x=i,y=j;
} else if(map1[i][j]==4){
cout<<"▓ ";
}
else{
cout<<"旗";
flag=false;
}
}
cout<<endl;
}
if(flag){
cout<<"恭喜过关!";
break;
}
if(map1[x+1][y]!=1&&map1[x+1][y]!=4){
map1[x][y]=0;
x++;
map1[x][y]=2;
}
cls();
if(GetAsyncKeyState('D')&&y<20&&map1[x][y+1]!=1){
map1[x][y]=0;
y++;
map1[x][y]=2;
Sleep(100);
}
if(GetAsyncKeyState('A')&&y>=0&&map1[x][y-1]!=1){
map1[x][y]=0;
y--;
map1[x][y]=2;
Sleep(100);
}
if(GetAsyncKeyState('X')&&x>=0&&map1[x-1][y]!=1){
map1[x][y]=4;
x--;
map1[x][y]=2;
Sleep(100);
}
if(GetAsyncKeyState(VK_SPACE)&&x-3>=0&&(map1[x+1][y]==1||map1[x+1][y]==4)&&x>=0&&map1[x-3][y]!=1){
map1[x][y]=0;
x-=3;
map1[x][y]=2;
Sleep(100);
}
}
Sleep(100000);
return 0;
}
更新内容:跳跃键变成空格,解决了一些BUG。
吴庞茂旭在2021-03-28 09:27:13追加了内容
你们老是说我只有一关,这不,我加到两关了!
但是——代码我隐藏了,你们只能下载我的成品!我才不给你们看我的代码~
注:需要代码的给我评论我洛谷发给你。
链接:代码提取
提取码:2009
还是老样子,操作和体验版一样。
吴庞茂旭在2021-03-28 09:32:16追加了内容
代码展示:
吴庞茂旭在2021-03-30 18:10:07追加了内容
下载:
链接:提取码:2009
成品展示:
吴庞茂旭在2021-04-10 20:51:11追加了内容
#include <bits/stdc++.h>
#include "windows.h"
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
/*
0=黑色,1=蓝色,2=绿色,3=湖蓝色,4=红色,5=紫色;
6=黄色,7=白色,8=灰色,9=淡蓝色,A=淡绿色,B=浅绿色;
C=淡红色,D=淡紫色,E=淡黄色,F=亮白色。
*/
/*
VK_LBUTTON 鼠标左键 0x01
VK_RBUTTON 鼠标右键 0x02
VK_CANCEL Ctrl + Break 0x03
VK_MBUTTON 鼠标中键 0x04
VK_BACK Backspace 键 0x08
VK_TAB Tab 键 0x09
VK_RETURN 回车键 0x0D
VK_SHIFT Shift 键 0x10
VK_CONTROL Ctrl 键 0x11
VK_MENU Alt 键 0x12
VK_PAUSE Pause 键 0x13
VK_CAPITAL Caps Lock 键 0x14
VK_ESCAPE Esc 键 0x1B
VK_SPACE 空格键 0x20
VK_PRIOR Page Up 键 0x21
VK_NEXT Page Down 键 0x22
VK_END End 键 0x23
VK_HOME Home 键 0x24
VK_LEFT 左箭头键 0x25
VK_UP 上箭头键 0x26
VK_RIGHT 右箭头键 0x27
VK_DOWN 下箭头键 0x28
VK_SNAPSHOT Print Screen 键 0x2C
VK_Insert Insert 键 0x2D
VK_Delete Delete 键 0x2E
'0' – '9' 数字 0 - 9 0x30 - 0x39
'A' – 'Z' 字母 A - Z 0x41 - 0x5A
VK_LWIN 左WinKey(104键盘才有) 0x5B
VK_RWIN 右WinKey(104键盘才有) 0x5C
VK_APPS AppsKey(104键盘才有) 0x5D
VK_NUMPAD0 小键盘 0 键 0x60
VK_NUMPAD1 小键盘 1 键 0x61
VK_NUMPAD2 小键盘 2 键 0x62
VK_NUMPAD3 小键盘 3 键 0x63
VK_NUMPAD4 小键盘 4 键 0x64
VK_NUMPAD5 小键盘 5 键 0x65
VK_NUMPAD6 小键盘 6 键 0x66
VK_NUMPAD7 小键盘 7 键 0x67
VK_NUMPAD8 小键盘 8 键 0x68
VK_NUMPAD9 小键盘 9 键 0x69
VK_F1 - VK_F24 功能键F1 – F24 0x70 - 0x87
VK_NUMLOCK Num Lock 键 0x90
VK_SCROLL Scroll Lock 键 0x91
*/
HWND hwnd=GetForegroundWindow();//使hwnd代表最前端的窗口
void HideCursor(){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
CursorInfo.bVisible = false; //隐藏控制台光标
SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
}
//1----围墙 2----自己 3----终点 0----空地 4----箱子
int map1[21][21]={
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,1,1,1,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1},
{1,0,1,0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,1},
{1,0,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0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,0,0,0,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0}
};
int map5[21][21]={
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0},
{0,1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,0,1},
{0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0},
{1,1,0,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,0},
{0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,1,0},
{0,1,0,1,0,0,0,1,1,1,1,0,1,0,1,0,1,1,1,1},
{0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,1,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1},
{1,1,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
{0,1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0},
{1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1},
{0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,4},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,3},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,4}
};
int cnt=5;
void cls(){
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coordScreen = { 0, 0 }; // home for the cursor
SetConsoleCursorPosition( hConsole, coordScreen );
}
string name;
int main(){
system("color 30");
ShowWindow(hwnd,SW_MAXIMIZE);
system("title block world 作者:赟邢道×创新公社");
HideCursor();
cnt+=3;
{
//第一关
bool flag=true;
int x,y;
int i=0;
while(map1[x][y]!=3){
flag=true;
i++;
cout<<i<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map1[i][j]==1){
cout<<"■";
} else if(map1[i][j]==0){
cout<<"□";
} else if(map1[i][j]==2){
cout<<"●";
x=i,y=j;
} else if(map1[i][j]==4){
cout<<"▓ ";
}
else{
cout<<"★";
flag=false;
}
}
cout<<endl;
}
if(x>20||y>20||x<0||y<0){
cout<<"芜湖~你落入了虚空......";
break;
} else if(flag){
cout<<"恭喜过关!";
break;
} else{
cout<<"您还有"<<cnt<<"个箱子 "<<endl<<"教程:\n\"A\"键向左,\"D\键向右,\" \"跳跃,\"X\放箱子\n■:墙 □:空 ●:你 ▓:箱子(需要升到Windows最新版本才能显示正常) ★:旗子";
}
if(map1[x+1][y]!=1&&map1[x+1][y]!=4){
map1[x][y]=0;
x++;
map1[x][y]=2;
}
cls();
if(GetAsyncKeyState('D')){
if(y<20&&map1[x][y+1]!=1){
map1[x][y]=0;
y++;
map1[x][y]=2;
Sleep(100);
} else if(x>=0&&y<20&&map1[x][y+1]==1&&map1[x-1][y+1]!=1){
map1[x][y]=0;
x--,y++;
map1[x][y]=2;
Sleep(100);
}
}
if(GetAsyncKeyState('A')){
if(y<20&&map1[x][y-1]!=1){
map1[x][y]=0;
y--;
map1[x][y]=2;
Sleep(100);
} else if(x>=0&&y>=0&&map1[x][y-1]==1&&map1[x-1][y-1]!=1){
map1[x][y]=0;
x--,y--;
map1[x][y]=2;
Sleep(100);
}
}
if(GetAsyncKeyState('X')&&x>=0&&map1[x-1][y]!=1&&cnt){
map1[x][y]=4;
x--;
cnt--;
map1[x][y]=2;
Sleep(100);
}
if(GetAsyncKeyState(VK_SPACE)){
if(x-3>=0&&(map1[x+1][y]==1||map1[x+1][y]==4)&&x>=0&&map1[x-3][y]!=1&&map1[x-1][y]!=1&&map1[x-2][y]!=1&&map1[x-3][y]!=1){
map1[x][y]=0;
x-=3;
map1[x+1][y]=0;
map1[x+2][y]=0;
map1[x][y]=2;
} else if(x-2>=0&&(map1[x+1][y]==1||map1[x+1][y]==4)&&x>=0&&map1[x-2][y]!=1&&map1[x-1][y]!=1&&map1[x-2][y]!=1){
map1[x][y]=0;
x-=2;
map1[x+1][y]=0;
map1[x][y]=2;
} else if(x-1>=0&&(map1[x+1][y]==1||map1[x+1][y]==4)&&x>=0&&map1[x-1][y]!=1&&map1[x-1][y]!=1){
map1[x][y]=0;
x-=1;
map1[x][y]=2;
}
}
if(GetAsyncKeyState(VK_ESCAPE)){
break;
}
}
Sleep(100);
cls();
if(x>20||y>20||x<0||y<0)return 0;
Sleep(1000);
}
{
cnt+=5;
bool flag=true;
int x,y;
int i=0;
//第二关
while(map2[x][y]!=3){
cls();
flag=true;
i++;
cout<<i<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map2[i][j]==1){
cout<<"■";
} else if(map2[i][j]==0){
cout<<"□";
} else if(map2[i][j]==2){
cout<<"●";
x=i,y=j;
} else if(map2[i][j]==4){
cout<<"▓ ";
}
else{
cout<<"★";
flag=false;
}
}
cout<<endl;
}
if(x>20||y>20||x<0||y<0){
cout<<"芜湖,你消失在地图之外!";
break;
} else if(flag){
cout<<"恭喜过关! ";
break;
} else{
cout<<"您还有"<<cnt<<"个箱子 ";
}
if(map2[x+1][y]!=1&&map2[x+1][y]!=4){
map2[x][y]=0;
x++;
map2[x][y]=2;
}
cls();
if(GetAsyncKeyState('D')){
if(y<20&&map2[x][y+1]!=1){
map2[x][y]=0;
y++;
map2[x][y]=2;
Sleep(100);
} else if(x>=0&&y<20&&map2[x][y+1]==1&&map2[x-1][y+1]!=1){
map2[x][y]=0;
x--,y++;
map2[x][y]=2;
Sleep(100);
}
}
if(GetAsyncKeyState('A')){
if(y<20&&map2[x][y-1]!=1){
map2[x][y]=0;
y--;
map2[x][y]=2;
Sleep(100);
} else if(x>=0&&y>=0&&map2[x][y-1]==1&&map2[x-1][y-1]!=1){
map2[x][y]=0;
x--,y--;
map2[x][y]=2;
Sleep(100);
}
}
if(GetAsyncKeyState('X')&&x>=0&&map2[x-1][y]!=1&&cnt){
map2[x][y]=4;
x--;
cnt--;
map2[x][y]=2;
Sleep(100);
}
if(GetAsyncKeyState(VK_SPACE)){
if(x-3>=0&&(map2[x+1][y]==1||map2[x+1][y]==4)&&x>=0&&map2[x-3][y]!=1&&map2[x-1][y]!=1&&map2[x-2][y]!=1&&map2[x-3][y]!=1){
map2[x][y]=0;
x-=3;
map2[x+1][y]=0;
map2[x+2][y]=0;
map2[x][y]=2;
} else if(x-2>=0&&(map2[x+1][y]==1||map2[x+1][y]==4)&&x>=0&&map2[x-2][y]!=1&&map2[x-1][y]!=1&&map2[x-2][y]!=1){
map2[x][y]=0;
x-=2;
map2[x+1][y]=0;
map2[x][y]=2;
} else if(x-1>=0&&(map2[x+1][y]==1||map2[x+1][y]==4)&&x>=0&&map2[x-1][y]!=1&&map2[x-1][y]!=1){
map2[x][y]=0;
x-=1;
map2[x][y]=2;
}
}
if(GetAsyncKeyState(VK_ESCAPE)){
break;
}
}
Sleep(1000);
cls();
if(x>20||y>20||x<0||y<0)return 0;
Sleep(1000);
}
{
bool flag=true;
int x,y;
int i=0;
//第三关
while(map3[x][y]!=3){
cls();
flag=true;
i++;
cout<<i<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map3[i][j]==1){
cout<<"■";
} else if(map3[i][j]==0){
cout<<"□";
} else if(map3[i][j]==2){
cout<<"●";
x=i,y=j;
} else if(map3[i][j]==4){
cout<<"▓ ";
}
else{
cout<<"★";
flag=false;
}
}
cout<<endl;
}
if(x>20||y>20||x<0||y<0){
cout<<"芜湖,你消失在地图之外!";
break;
} else if(flag){
cout<<"恭喜过关! ";
break;
} else{
cout<<"您还有"<<cnt<<"个箱子";
}
if(map3[x+1][y]!=1&&map3[x+1][y]!=4){
map3[x][y]=0;
x++;
map3[x][y]=2;
}
cls();
if(GetAsyncKeyState('D')){
if(y<20&&map3[x][y+1]!=1){
map3[x][y]=0;
y++;
map3[x][y]=2;
Sleep(100);
} else if(x>=0&&y<20&&map3[x][y+1]==1&&map3[x-1][y+1]!=1){
map3[x][y]=0;
x--,y++;
map3[x][y]=2;
Sleep(100);
}
}
if(GetAsyncKeyState('A')){
if(y<20&&map3[x][y-1]!=1){
map3[x][y]=0;
y--;
map3[x][y]=2;
Sleep(100);
} else if(x>=0&&y>=0&&map3[x][y-1]==1&&map3[x-1][y-1]!=1){
map3[x][y]=0;
x--,y--;
map3[x][y]=2;
Sleep(100);
}
}
if(GetAsyncKeyState(VK_SPACE)){
if(x-3>=0&&(map3[x+1][y]==1||map3[x+1][y]==4)&&x>=0&&map3[x-3][y]!=1&&map3[x-1][y]!=1&&map3[x-2][y]!=1&&map3[x-3][y]!=1){
map3[x][y]=0;
x-=3;
map3[x+1][y]=0;
map3[x+2][y]=0;
map3[x][y]=2;
} else if(x-2>=0&&(map3[x+1][y]==1||map3[x+1][y]==4)&&x>=0&&map3[x-2][y]!=1&&map3[x-1][y]!=1&&map3[x-2][y]!=1){
map3[x][y]=0;
x-=2;
map3[x+1][y]=0;
map3[x][y]=2;
} else if(x-1>=0&&(map3[x+1][y]==1||map3[x+1][y]==4)&&x>=0&&map3[x-1][y]!=1&&map3[x-1][y]!=1){
map3[x][y]=0;
x-=1;
map3[x][y]=2;
}
}
if(GetAsyncKeyState(VK_ESCAPE)){
break;
}
}
Sleep(1000);
cls();
if(x>20||y>20||x<0||y<0)return 0;
Sleep(1000);
}
{
cnt+=3;
bool flag=true;
int x,y;
int i=0;
//第四关
do{
cls();
flag=true;
i++;
cout<<i<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map4[i][j]==1){
cout<<"■";
} else if(map4[i][j]==0){
cout<<"□";
} else if(map4[i][j]==2){
cout<<"●";
x=i,y=j;
} else if(map4[i][j]==4){
cout<<"▓ ";
}
else{
cout<<"★";
flag=false;
}
}
cout<<endl;
}
if(x>20||y>20||x<0||y<0){
cout<<"芜湖,你消失在地图之外!";
break;
} else if(flag){
cout<<"恭喜过关! ";
break;
} else{
cout<<"您还有"<<cnt<<"个箱子";
}
if(map4[x+1][y]!=1&&map4[x+1][y]!=4){
map4[x][y]=0;
x++;
map4[x][y]=2;
}
cls();
if(GetAsyncKeyState('D')){
if(y<20&&map4[x][y+1]!=1){
map4[x][y]=0;
y++;
map4[x][y]=2;
Sleep(100);
} else if(x>=0&&y<20&&map4[x][y+1]==1&&map4[x-1][y+1]!=1){
map4[x][y]=0;
x--,y++;
map4[x][y]=2;
Sleep(100);
}
}
if(GetAsyncKeyState('A')){
if(y<20&&map4[x][y-1]!=1){
map4[x][y]=0;
y--;
map4[x][y]=2;
Sleep(100);
} else if(x>=0&&y>=0&&map4[x][y-1]==1&&map4[x-1][y-1]!=1){
map4[x][y]=0;
x--,y--;
map4[x][y]=2;
Sleep(100);
}
}
if(GetAsyncKeyState('X')&&x>=0&&map4[x-1][y]!=1&&cnt){
map4[x][y]=4;
x--;
cnt--;
map4[x][y]=2;
Sleep(100);
}
if(GetAsyncKeyState(VK_SPACE)){
if(x-3>=0&&(map4[x+1][y]==1||map4[x+1][y]==4)&&x>=0&&map4[x-3][y]!=1&&map4[x-1][y]!=1&&map4[x-2][y]!=1&&map4[x-3][y]!=1){
map4[x][y]=0;
x-=3;
map4[x+1][y]=0;
map4[x+2][y]=0;
map4[x][y]=2;
} else if(x-2>=0&&(map4[x+1][y]==1||map4[x+1][y]==4)&&x>=0&&map4[x-2][y]!=1&&map4[x-1][y]!=1&&map4[x-2][y]!=1){
map4[x][y]=0;
x-=2;
map4[x+1][y]=0;
map4[x][y]=2;
} else if(x-1>=0&&(map4[x+1][y]==1||map4[x+1][y]==4)&&x>=0&&map4[x-1][y]!=1&&map4[x-1][y]!=1){
map4[x][y]=0;
x-=1;
map4[x][y]=2;
}
}
if(GetAsyncKeyState(VK_ESCAPE)){
break;
}
}while(map4[x][y]!=3);
Sleep(1000);
cls();
if(x>20||y>20||x<0||y<0)return 0;
Sleep(1000);
}
{
cnt+=6;
bool flag=true;
int x,y;
int i=0;
//第五关
do{
cls();
flag=true;
i++;
cout<<i<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map5[i][j]==1){
cout<<"■";
} else if(map5[i][j]==0){
cout<<"□";
} else if(map5[i][j]==2){
cout<<"●";
x=i,y=j;
} else if(map5[i][j]==4){
cout<<"▓ ";
}
else{
cout<<"★";
flag=false;
}
}
cout<<endl;
}
if(x>20||y>20||x<0||y<0){
cout<<"芜湖,你消失在地图之外!";
break;
} else if(flag){
cout<<"恭喜过关! ";
break;
} else{
cout<<"您还有"<<cnt<<"个箱子";
}
if(map5[x+1][y]!=1&&map5[x+1][y]!=4){
map5[x][y]=0;
x++;
map5[x][y]=2;
}
cls();
if(GetAsyncKeyState('D')){
if(y<20&&map5[x][y+1]!=1){
map5[x][y]=0;
y++;
map5[x][y]=2;
Sleep(100);
} else if(x>=0&&y<20&&map5[x][y+1]==1&&map5[x-1][y+1]!=1){
map5[x][y]=0;
x--,y++;
map5[x][y]=2;
Sleep(100);
}
}
if(GetAsyncKeyState('A')){
if(y<20&&map5[x][y-1]!=1){
map5[x][y]=0;
y--;
map5[x][y]=2;
Sleep(100);
} else if(x>=0&&y>=0&&map5[x][y-1]==1&&map5[x-1][y-1]!=1){
map5[x][y]=0;
x--,y--;
map5[x][y]=2;
Sleep(100);
}
}
if(GetAsyncKeyState('X')&&x>=0&&map5[x-1][y]!=1&&cnt){
map5[x][y]=4;
x--;
cnt--;
map5[x][y]=2;
Sleep(100);
}
if(GetAsyncKeyState(VK_SPACE)){
if(x-3>=0&&(map5[x+1][y]==1||map5[x+1][y]==4)&&x>=0&&map5[x-3][y]!=1&&map5[x-1][y]!=1&&map5[x-2][y]!=1&&map5[x-3][y]!=1){
map5[x][y]=0;
x-=3;
map5[x+1][y]=0;
map5[x+2][y]=0;
map5[x][y]=2;
} else if(x-2>=0&&(map5[x+1][y]==1||map5[x+1][y]==4)&&x>=0&&map5[x-2][y]!=1&&map5[x-1][y]!=1&&map5[x-2][y]!=1){
map5[x][y]=0;
x-=2;
map5[x+1][y]=0;
map5[x][y]=2;
} else if(x-1>=0&&(map5[x+1][y]==1||map5[x+1][y]==4)&&x>=0&&map5[x-1][y]!=1&&map5[x-1][y]!=1){
map5[x][y]=0;
x-=1;
map5[x][y]=2;
}
}
if(GetAsyncKeyState(VK_ESCAPE)){
break;
}
}while(map5[x][y]!=3);
Sleep(1000);
cls();
if(x>20||y>20||x<0||y<0)return 0;
Sleep(1000);
}
return 0;
}
增加了一些关卡(注:如果放箱子出现错位可以在放箱子的代码中去除空格)
1
1
1
1
1
1
0
郑泓毅
资深守护
资深守护
#include<iostream>
#include<windows.h>
using namespace std;
bool flag;
int cnt,x,y,k,o;
int r[105][5]={{0},{0,9,5},{0,14,2}};
int map[105][20][20]={{0},{{0},
{0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{0,1,0,3,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,1,1,0,0,1,0,0,0,0,0,0,0,1},
{0,1,0,0,1,1,0,1,0,0,0,0,0,0,0,1},
{0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,1,1,0,1,1,0,0,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1},
{0,1,0,0,0,2,0,0,0,0,0,0,0,0,0,1},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,1,0,1,0,1,0,1,1,0,0,0,0,0,1},
{0,1,1,0,1,0,1,0,1,1,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1},
{0,1,1,1,0,1,0,1,1,1,0,0,0,0,0,1},
{0,1,1,1,0,1,0,1,1,1,1,1,1,1,0,1},
},{{0},
{0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,1,0,1,0,0,1,0,0,1,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1},
{0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1},
{0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1},
{0,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1},
{0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,1},
{0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,1},
{0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,1},
{0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1},
{0,1,2,1,1,0,0,0,0,0,0,0,0,0,0,1},
{0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
}
};
void cls(){
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coordScreen = { 0, 0 }; // home for the cursor
SetConsoleCursorPosition( hConsole, coordScreen );
}
void HideCursor(){
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_CURSOR_INFO CursorInfo;
GetConsoleCursorInfo(handle, &CursorInfo);//获取控制台光标信息
CursorInfo.bVisible = false; //隐藏控制台光标
SetConsoleCursorInfo(handle, &CursorInfo);//设置控制台光标状态
}
bool KO(int cnt){
for(int i=1;i<=15;i++){
for(int j=1;j<=15;j++){
if(map[cnt][i][j]==3){
return false;
}
}
}
return true;
}
bool OK(int cnt){
for(int i=1;i<=15;i++){
for(int j=1;j<=15;j++){
if(map[cnt][i][j]==2){
return false;
}
}
}
return true;
}
int main(){
system("color 30");
HideCursor();
cnt=1;
while(cnt){
flag=false,k=1;
while(true){
cout<<k<<" "<<o<<endl;
k++;
for(int i=1;i<=15;i++){
for(int j=1;j<=15;j++){
if(map[cnt][i][j]==2){
cout<<"你";
x=i,y=j;
}else if(map[cnt][i][j]==0){
cout<<" ";
}else if(map[cnt][i][j]==1){
cout<<"■";
}else if(map[cnt][i][j]==3){
cout<<"旗";
}
}
cout<<endl;
}
if(OK(cnt)){
cout<<"你掉进了虚空!!!"<<endl;
Sleep(3000);
system("cls");
map[cnt][r[cnt][1]][r[cnt][2]]=2;
}
if(KO(cnt)){
cout<<"恭喜过关!!!"<<endl;
Sleep(3000);
system("cls");
break;
}
cls();
if(GetAsyncKeyState('W')&&map[cnt][x+1][y]!=0){
int m=0;
for(int i=1;i<=3;i++){
if(map[cnt][x-i][y]==0){
m=i;
}else break;
}
map[cnt][x][y]=0;
map[cnt][x-m][y]=2;
Sleep(100);
continue;
}
if(GetAsyncKeyState('S')&&map[cnt][x+1][y]!=1){
map[cnt][x][y]=0;
//if(map[cnt][x+1][y]==3) flag=true;
map[cnt][x+1][y]=2;
Sleep(100);
continue;
}
if(GetAsyncKeyState('A')&&map[cnt][x][y-1]!=1){
map[cnt][x][y]=0;
//if(map[cnt][x][y-1]==3) flag=true;
map[cnt][x][y-1]=2;
Sleep(100);
if(map[cnt][x+1][y-1]==0) o++;
if(o>=2){
if(map[cnt][x+1][y-1]==0){
map[cnt][x][y-1]=0;
map[cnt][x+1][y-1]=2;
}
o=0;
x++;
}
continue;
}
if(GetAsyncKeyState('D')&&map[cnt][x][y+1]!=1){
map[cnt][x][y]=0;
//if(map[cnt][x][y+1]==3) flag=true;
map[cnt][x][y+1]=2;
Sleep(100);
if(map[cnt][x+1][y+1]==0) o++;
if(o>=2){
if(map[cnt][x+1][y+1]==0){
map[cnt][x][y+1]=0;
map[cnt][x+1][y+1]=2;
}
o=0;
x++;
}
continue;
}
if(map[cnt][x+1][y]==0){
map[cnt][x][y]=0;
//if(map[cnt][x+1][y]==3) flag=true;
map[cnt][x+1][y]=2;
Sleep(100);
}
}
cls();
cnt+=1;
}
return 0;
}
帮你更新
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
高舒豪
中级光能
中级光能
只有一关?!!
————————————————————————————————————————
PS:建议不闪屏的方法和XACRAFT结合一下,XACRAFT就完美了
0
0
0
0
0