跳到正文

休闲·娱乐

原创小游戏(未完工)

Super_Diu约 9 分钟
原文
文章信息与版本

文章信息

发布
2025年10月7日
收录
2025年12月12日
更新
2026年8月28日
篇幅
约 9 分钟

版本

  1. v1当前
C++
#include <bits/stdc++.h>
#include <windows.h>
typedef long long ll;
using namespace std;
const int N=1e5+10;
int x,y,sx,sy;
int jp;
string mp[]={
	{"=                                                                                                                      ="},
	{"=                                                =                                                                     ="},
	{"=   *                                 =====   ===                                                                      ="},
	{"=   ============================               =                                                                       ="},
	{"=                             =               =                                                                        ="},
	{"=                            =               =                                                                         ="},
	{"=                           =               =                                                                          ="},
	{"=                          =               =                                                                           ="},
	{"=                           =             =                                                                            ="},
	{"=                            =           =                                                                             ="},
	{"=                             =         =                                                                              ="},
	{"=                              =       =                                                                               ="},
	{"=                               =     =                                                                                ="},
	{"=                                =                                                                                     ="},
	{"=                                 =                                                                                  # ="},
	{"========================================================================================================================"},
	{"                                                                                                                        "},
	{"                                                                                                                        "}
};
bool IsKeyDown(int keyCode) {
	return (GetAsyncKeyState(keyCode) & 0x8000) != 0;
}
void HideCursor() {
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO cci;
	cci.dwSize = 30;
	cci.bVisible = FALSE;
	SetConsoleCursorInfo(hOut, &cci);
}
//void ycbj()//移除快速编辑模式
//{
//	HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
//	DWORD mode;
//	GetConsoleMode(hStdin, &mode);
//	mode&=~ENABLE_QUICK_EDIT_MODE;
//	SetConsoleMode(hStdin, mode);
//	return ;
//}
void fastClearScreen() {
	printf("\033[2J\033[1;1H");
}
void print(){
	system("cls");
	for(int i=0;i<18;i++){
		for(int j=0;j<120;j++){
			if(i==x&&j==y){
				if(mp[i][j]=='*'||mp[i][j]==' ')putchar('*');
				else printf("%c",mp[i][j]);
			}
			else if(mp[i][j]=='*'){
				mp[i][j]=' ';
				putchar(' ');
			}
			else printf("%c",mp[i][j]);
		}
		putchar('\n');
	}
}
int main(){
//	ios::sync_with_stdio(0);
//	cin.tie(0),cout.tie(0);
	HideCursor();
//	ycbj();
	for(int i=0;i<18;i++){
		for(int j=0;j<120;j++){
			if(mp[i][j]=='*'){
				sx=i;
				sy=j;
			}
		}
	}
	x=sx;
	y=sy;
	print();
	while(1){
		if (IsKeyDown(VK_UP)) {
			if(mp[x+1][y]!=' '&&!jp){
				jp=5;
				mp[x][y]=' ';
				int t=x;
				for(int i=x;i>=x-5&&i>=0;i--){
					if(mp[i][y]!=' '){
						t=i;
						break;
					}
				}
				jp=5-(x-t);
				x=(t==x ? max(0,x-5) : t);
				print();
			}
		}
		if(x+1<18&&mp[x+1][y]==' '){
			int high=1;
			for(int i=x+1;i<18;i++){
				if(mp[i][y]==' '){
					if(i==x+1)high=0;
					high++;
				}
			}
			jp=high;
		}
		if (IsKeyDown(VK_LEFT)) {
			if(mp[x][y-1]==' '){
				mp[x][y]=' ';
				y--;
				print();
			}
		}
		if (IsKeyDown(VK_RIGHT)) {
			if(mp[x][y+1]==' '){
				mp[x][y]=' ';
				y++;
				print();
			}
		}
		if(jp&&x+1<18&&mp[x+1][y]==' '){
			if(x+1>18){
				x=sx;
				y=sy;
			}
			else x++;
			if(!(IsKeyDown(VK_LEFT)||IsKeyDown(VK_RIGHT))){
				print();
			}
			jp--;
		}
		else{
			jp=0;
		}
		Sleep(5);
	}
	return 0;
}

有 bug 私信我

原文