我把框架整理了一遍
东西都放到了一个命名空间里
其他没啥更新
安装方式和b_game.h1.2一样
#ifndef b_game
#define b_game
#include<iostream>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<windows.h>
#include<conio.h>
#include<fstream>
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;
}
}
#endif