跳到正文

个人记录

冲浪

binomial约 3 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年5月17日
篇幅
约 3 分钟

版本

  1. v1当前

用了10min,写着玩的

C++
#include <bits/stdc++.h>
#include <windows.h>
using namespace std;
const int MAXN=5005;
int mp[MAXN][MAXN],lux,luy;
void Cls(){
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coordScreen = {0, 0};
    SetConsoleCursorPosition( hConsole, coordScreen );
}
bool IsPressed(int count, ...) {
	va_list nVirtKey;
	va_start(nVirtKey, count);
	for (int i = 0; i < count; i++) {
		if (!(GetKeyState(va_arg(nVirtKey, int)) & 0x8000)) {
			return 0;
		}
	}
	return 1;
}
int main() {
	system("mode con cols=103 lines=56");
	srand(time(0));
	for(int i=1;i<=5000;i++){
		for(int j=1;j<=5000;j++){
			mp[i][j]=rand()%10;
		}
	}
	for(int i=2525;i<=2540;i++){
		for(int j=1;j<=5000;j++){
			mp[i][j]=1;
		}
	}
	lux=luy=2500;
	while(1){
		for(int i=lux;i<lux+50;i++){
			for(int j=luy;j<luy+100;j++){
				if(i==lux+25&&j==luy+50){
					cout<<"Y";
					continue;
				}
				if(mp[i][j]==0){
					cout<<"#";
				}
				else{
					cout<<".";
				}
			}
			cout<<'\n';
		}
		Cls();
		lux++;
		if(IsPressed(1,'A')){
			luy--;
		}
		if(IsPressed(1,'S')){
			lux++;
		}
		if(IsPressed(1,'W')){
			lux--;
		}
		if(IsPressed(1,'D')){
			luy++;
		}
		if(!mp[lux+25][luy+50]){
			system("cls");
			cout<<"LOSE";
			exit(0);
		}
		if(lux==3000){
			system("cls");
			cout<<"WIN";
			exit(0);
		}
		Sleep(150);
	}
	return 0;

}
原文