话不多说,上代码:
#undef UNICODE
#undef _UNICODE
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include <ctime>
#include <windows.h>
#include <conio.h>
#include <fstream>
#include <stdio.h>
using namespace std;
namespace _game
{
//常量
const long long ESC=27,
Enter=13,
Tab=9,
Shang=38,
Xia=40,
Zuo=37,
You=39,
Kong=' ',
z_sb=VK_LBUTTON,
y_sb=VK_RBUTTON,
Shift=VK_SHIFT,
z_Shift=VK_LSHIFT,
y_Shift=VK_RSHIFT,
Ctrl=VK_CONTROL,
z_Ctrl=VK_LCONTROL,
y_Ctrl=VK_RCONTROL,
Alt=VK_MENU,
z_Alt=VK_LMENU,
y_Alt=VK_RMENU,
A='A',
B='B',
C='C',
D='D',
E='E',
F='F',
G='G',
H='H',
I='I',
J='J',
K='K',
L='L',
M='M',
N='N',
O='O',
P='P',
Q='Q',
R='R',
S='S',
T='T',
U='U',
V='V',
W='W',
X='X',
Y='Y',
Z='Z';
//结构体
struct cdhs//存档结构体
{
void out(int n, string name)//输出存档
{
ofstream cd(&name[0]);
cd << n;
return;
}
void out(long long n, string name)
{
ofstream cd(&name[0]);
cd << n;
return;
}
void out(bool n, string name)
{
ofstream cd(&name[0]);
cd << n;
return;
}
void out(char n, string name)
{
ofstream cd(&name[0]);
cd << n;
return;
}
void out(string n, string name)
{
ofstream cd(&name[0]);
cd << n;
return;
}//重载
void in(int& n, string name)//读入存档
{
ifstream cd(&name[0]);
cd >> n;
return;
}
void in(long long& n, string name)
{
ifstream cd(&name[0]);
cd >> n;
return;
}
void in(bool& n, string name)
{
ifstream cd(&name[0]);
cd >> n;
return;
}
void in(char& n, string name)
{
ifstream cd(&name[0]);
cd >> n;
return;
}
void in(string& n, string name)
{
ifstream cd(&name[0]);
cd >> n;
return;
}//重载
};
struct hl//行列
{
long long h,l;
};
//函数
bool axj(long long key)
{
return (GetKeyState(key)<0);
}
void bout(string n, long long s=50,bool f=0,char key=13)//输出
{
for (long long i = 0; i < n.size(); i++)
{
if (f&&GetKeyState(key)<0)
{
cout<<n.substr(i,n.size());
return ;
}
cout << n[i];
Sleep(s);
}
return;
}
void ckbb()//查看当前b_game.h库版本信息
{
system("cls");
cout << "库名:b_game.h\n";
cout << "类型:拓展库\n";
cout << "版本号:2.0.1\n";
return;
}
void gs(long long h, long long l, string z)//格式
{
for (long long i = 1; i <= h; i++)
cout << "\n";
for (long long i = 1; i <= l; i++)
cout << " ";
cout << z;
return;
}
hl sbwz(bool x=1,bool n=1)//鼠标位置
{
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
HWND h=GetForegroundWindow();
CONSOLE_FONT_INFO consoleCurrentFont;
hl hl;
POINT p;
if(x)
{
GetCursorPos(&p);
ScreenToClient(h,&p);
}
else
{
GetCursorPos(&p);
}
if(n)
{
GetCurrentConsoleFont(hOutput, FALSE, &consoleCurrentFont);
p.x/=consoleCurrentFont.dwFontSize.X;
p.y/=consoleCurrentFont.dwFontSize.Y;
}
hl.h=p.y+1;
hl.l=p.x+1;
return hl;
}
void yanse(int n)//颜色
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), n);
return;
}
void ycbj()//移除快速编辑模式
{
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode;
GetConsoleMode(hStdin, &mode);
mode&=~ENABLE_QUICK_EDIT_MODE;
SetConsoleMode(hStdin, mode);
return ;
}
void ycgb()//隐藏光标
{
CONSOLE_CURSOR_INFO cursor;
cursor.bVisible = FALSE;
cursor.dwSize = sizeof(cursor);
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorInfo(handle, &cursor);
return;
}
void ydgb(long long h, long long l)//移动光标
{
COORD pos = { l-1,h-1 };
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut, pos);
return;
}
}
using namespace _game;
const long long dts = 9;
long long wj1x, wj1y, wj2x, wj2y, wj3x, wj3y, wj4x, wj4y, cs = 0, dtbh, sy, runs, cgjd = 1, y_1x, y_1y, y_2x, y_2y, y_3x, y_3y, y_4x, y_4y;
cdhs cddx;
bool f = 1, t1 = 1, t2 = 1, t3 = 1, t4 = 1, cxjs = 1, hyflag = 1;
long long csx[dts + 1] = {
0,
18,
18,
18,
14,
1,
3,
1,
3,
18
};
long long csy[dts + 1] = {
0,
1,
1,
1,
1,
1,
1,
1,
37,
1
};
string dtm[dts + 1] = {
"空地图",
"新手练习",
"蹦床天地",
"信仰之跃",
"生死双道",
"天空跳床",
"小心暗刺",
"转来转去",
"9 9 加 6",
"天空尖刺"
};
string dt[dts + 1][21] = {
{
" ",//
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
},
{
" =",//
" =",
" =",
" =",
" =",
" =",
" =",
" =",
" =",
" =",
" =",
" =",
" =",
" =",
" ===================",
" =",
" ==== =",
" = =",
" < > = $=",
" ==== ====^^^^==================- ======= =",
" ="
},
{
" ",//
" = < ",
" = < ",
" = < $ ",
" = < ",
" = < ",
" --- < ",
" = ",
" ======-=====-===---=----=-=----========-=======",
" ",
" ",
" --- ",
" ",
" ",
" ",
" ",
"

这是一个用C++编写的马里奥风格跑酷游戏,包括模式选择、游戏控制、地图设计等功能。游戏支持单人至四人模式,玩家通过键盘操作角色跳跃、移动,避开障碍物到达终点。游戏设有多个关卡,每个关卡地图不同,玩家需要掌握好节奏和技巧才能顺利过关。此外,代码中还包含了暂停、存档、读档等功能,增加了游戏的可玩性。
最低0.47元/天 解锁文章
4225

被折叠的 条评论
为什么被折叠?



