1
已解决
吴庞茂旭
资深光能
资深光能
半年苦寒,无数的心血,终于在我生日的这一天,Block World的正式版:上线了!!!
效果展示:
链接:提取码:2009
代码也许在洛谷呢!
吴庞茂旭在2021-05-28 19:20:42追加了内容
我默默地发出了BW的代码,但是没人能看见,因为只有十年码农的灵魂才能看到…………
#include <bits/stdc++.h>
#include "windows.h"
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)d
using namespace std;
/*
0=黑色,1=蓝色,2=绿色,3=湖蓝色,4=红色,5=紫色;
6=黄色,7=白色,8=灰色,9=淡蓝色,10=淡绿色 11=浅绿色;
12=淡红色,13=淡紫色,14=淡黄色,15=亮白色。
*/
/*
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,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,1,1,1,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,1,1,1,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,1,1,1,1,1,0,0,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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,1,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,1,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,1,0,1,0,1,0,1,0,1,0,1,0,1,4,4,4}
};
void color(int ForgC, int BackC) {//手写color函数
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}
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 EA");
ShowWindow(hwnd,SW_MAXIMIZE);
system("title block world 作者:赟邢道×创新公社");
HideCursor();
cnt+=3;
{
//第一关
bool flag=true;
int x,y;
int a=0;
while(map1[x][y]!=3){
flag=true;
a++;
cout<<a<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map1[i][j]==1){
color(0,14);
cout<<"■";
} else if(map1[i][j]==0){
color(10,14);
cout<<"□";
} else if(map1[i][j]==2){
color(4,14);
cout<<"●";
x=i,y=j;
} else if(map1[i][j]==4){
color(11,14);
cout<<"※";
}
else{
if(a%3==0)color(1,14);
if(a%3==1)color(2,14);
if(a%3==2)color(4,14);
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■:墙 □:空 ●:你 ※:箱子 ★:旗子";
}
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 a=0;
//第二关
while(map2[x][y]!=3){
cls();
flag=true;
a++;
cout<<a<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map2[i][j]==1){
color(0,14);
cout<<"■";
} else if(map2[i][j]==0){
color(10,14);
cout<<"□";
} else if(map2[i][j]==2){
color(4,14);
cout<<"●";
x=i,y=j;
} else if(map2[i][j]==4){
color(11,14);
cout<<"※";
}
else{
if(a%3==0)color(1,14);
if(a%3==1)color(2,14);
if(a%3==2)color(4,14);
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 a=0;
//第三关
while(map3[x][y]!=3){
cls();
flag=true;
a++;
cout<<a<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map3[i][j]==1){
color(0,14);
cout<<"■";
} else if(map3[i][j]==0){
color(10,14);
cout<<"□";
} else if(map3[i][j]==2){
color(4,14);
cout<<"●";
x=i,y=j;
} else if(map3[i][j]==4){
color(11,14);
cout<<"※";
}
else{
if(a%3==0)color(1,14);
if(a%3==1)color(2,14);
if(a%3==2)color(4,14);
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 a=0;
//第四关
do{
cls();
flag=true;
a++;
cout<<a<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map4[i][j]==1){
color(0,14);
cout<<"■";
} else if(map4[i][j]==0){
color(10,14);
cout<<"□";
} else if(map4[i][j]==2){
color(4,14);
cout<<"●";
x=i,y=j;
} else if(map4[i][j]==4){
color(11,14);
cout<<"※";
}
else{
if(a%3==0)color(1,14);
if(a%3==1)color(2,14);
if(a%3==2)color(4,14);
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 a=0;
//第五关
do{
cls();
flag=true;
a++;
cout<<a<<endl;
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
if(map5[i][j]==1){
color(0,14);
cout<<"■";
} else if(map5[i][j]==0){
color(10,14);
cout<<"□";
} else if(map5[i][j]==2){
color(4,14);
cout<<"●";
x=i,y=j;
} else if(map5[i][j]==4){
color(11,14);
cout<<"※";
}
else{
if(a%3==0)color(1,14);
if(a%3==1)color(2,14);
if(a%3==2)color(4,14);
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
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0