我的世界0.1.1
2026-11-08 19:14:22
发布于:陕西
wsad移动 鼠标左键哇方块 鼠标右键放方块
0是水 1是泥土
#include<bits/stdc++.h>
#include <windows.h>
#include <iostream>
#include <chrono>
#include <thread>
#include<iostream>
#include<windows.h>
#include<conio.h>
#include<time.h>
#define int long long
using namespace std;
int x, y, mp[110][110], anx, g[10];
int ns=10,nsm=10;
int hp=20, hpx=20;
void setCursorPosition(int x, int y) {
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void show_cursor(bool visible) {
CONSOLE_CURSOR_INFO cursor_info = {20, visible};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
signed main(){
srand((unsigned)time(NULL));
for(int i = 1; i <= 100; i++){
for(int j = 1; j <= 100; j++){
int n=rand()%2;
mp[i][j]=n;
}
}
while(hp>0){
if(GetAsyncKeyState('W') & 0x8000)x--;
if(GetAsyncKeyState('S') & 0x8000)x++;
if(GetAsyncKeyState('D') & 0x8000)y++;
if(GetAsyncKeyState('A') & 0x8000)y--;
if(GetAsyncKeyState(VK_LBUTTON) & 0x8000){
if(anx==0){
anx=1;
if(mp[x][y]==1){
g[1]++;
mp[x][y]=0;
}
}
}
if(GetAsyncKeyState(VK_RBUTTON) & 0x8000){
if(mp[x][y]==0&&g[1]>0){
g[1]--;
mp[x][y]=1;
}
}
if(!(GetAsyncKeyState(VK_LBUTTON) & 0x8000))anx=0;
if(x<1)x=1;
if(x>100)x=100;
if(y<1)y=1;
if(y>100)y=100;
setCursorPosition(0, 0);
for(int i = x-5; i <= x+5; i++){
for(int j = y-5; j <= y+5; j++){
if(i==x&&j==y)cout<<"P";
else if(i>=1&&i<=100&&j>=1&&j<=100) cout<<mp[i][j];
else cout<<" ";
}
cout<<endl;
}
for(int i = 1; i <= hp; i++){
if(i%2==0)cout<<"1 ";
else cout<<1;
}
for(int i = hp+1; i <= hpx; i++){
if(i%2==0)cout<<"0 ";
else cout<<0;
}
cout<<" ";
for(int i = 1; i <= ns; i++){
cout<<"o";
}
for(int i = ns+1; i <= 10; i++){
cout<<" ";
}
cout<<endl;
for(int i = 1; i <= 9; i++){
if(g[i]>0){
cout<<"泥土"<<g[i];
}
else cout<<"无";
cout<<" ";
}
cout<<" ";
if(mp[x][y]==0)nsm--;
else nsm++;
if(nsm==0){
nsm=10;
if(ns>0)ns--;
else hp--;
}else if(nsm>9){
if(ns<10)ns++;
nsm=0;
}
//cout<<endl;
//cout<<ns<<" ";
Sleep(100);
}
system("cls");
if(ns==0)cout<<"你溺水而亡";;
return 0;
}
全部评论 2
- 置顶
点赞点赞点赞
2026-11-08 来自 陕西
0 5
2026-11-08 来自 浙江
0评价 1(1星)2(2星)3(3星)4(4星)5(5星)
2026-11-08 来自 陕西
0



















有帮助,赞一个