我的世界0.1
2026-11-07 13:44:40
发布于:陕西
#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];
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(1){
if(GetAsyncKeyState('W') & 0x8000)x--;
if(GetAsyncKeyState('S') & 0x8000)x++;
if(GetAsyncKeyState('D') & 0x8000)y++;
if(GetAsyncKeyState('A') & 0x8000)y--;
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;
}
Sleep(100);
}
return 0;
}
全部评论 3
- 置顶
wsad移动,OK,没了
2026-11-07 来自 陕西
0 1
2026-11-07 来自 上海
0l
2026-11-07 来自 四川
0?
2026-11-07 来自 陕西
0
























有帮助,赞一个