b_game3.0重磅上线!!!
本次更新了1个按钮类和其他2个函数,
修复了N个BUG
#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
{//结构体与类提前声明struct hl//行列{long long h, l;};//函数提前声明bool axj(long long key);hl sbwz(bool x, bool n);void ydgb(long long h, long long l);void yanse(int n);//常量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';//结构体与类class anniu{private:short h_1, l_1, h_2, l_2, ys1, ys2;string nr;public:void csh(short hh_1, short ll_1, short hh_2, short ll_2, string _nr, short _yanse1, short _yanse2);bool gx_ax(bool f);};struct cdhs//存档结构体{void out(int n, string name);void out(long long n, string name);void out(bool n, string name);void out(char n, string name);void out(string n, string name);void in(int& n, string name);void in(long long& n, string name);void in(bool& n, string name);void in(char& n, string name);void in(string& n, string name);};//成员函数void anniu::csh(short hh_1 = 1, short ll_1 = 1, short hh_2 = 1, short ll_2 = 1, string _nr = " ", short _yanse1 = 240, short _yanse2 = 7){h_1 = hh_1;l_1 = ll_1;h_2 = hh_2;l_2 = ll_2;ys1 = _yanse1;ys2 = _yanse2;nr = _nr;return;}bool anniu::gx_ax(bool f = 1){short h = sbwz(1, 1).h, l = sbwz(1, 1).l, t = -1;if (h >= h_1 && h <= h_2 && l >= l_1 && l <= l_2){yanse(ys2);for (short i = h_1; i <= h_2; i++){ydgb(i, l_1);for (short j = l_1; j <= l_2; j++){t++;cout << nr[t];}}if ((axj(z_sb) && (f == 1)) || (axj(y_sb) && (f == 0))){return 1;}}else{yanse(ys1);for (short i = h_1; i <= h_2; i++){ydgb(i, l_1);for (short j = l_1; j <= l_2; j++){t++;cout << nr[t];}}return 0;}}void cdhs::out(int n, string name){ofstream cd(&name[0]);cd << n;cd.close();return;}void cdhs::out(long long n, string name){ofstream cd(&name[0]);cd << n;cd.close();return;}void cdhs::out(bool n, string name){ofstream cd(&name[0]);cd << n;cd.close();return;}void cdhs::out(char n, string name){ofstream cd(&name[0]);cd << n;cd.close();return;}void cdhs::out(string n, string name){ofstream cd(&name[0]);cd << n;cd.close();return;}void cdhs::in(int& n, string name){ifstream cd(&name[0]);cd >> n;cd.close();return;}void cdhs::in(long long& n, string name){ifstream cd(&name[0]);cd >> n;cd.close();return;}void cdhs::in(bool& n, string name){ifstream cd(&name[0]);cd >> n;cd.close();return;}void cdhs::in(char& n, string name){ifstream cd(&name[0]);cd >> n;cd.close();return;}void cdhs::in(string& n, string name){ifstream cd(&name[0]);cd >> n;cd.close();return;}//函数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.hn";cout << "类型:拓展库n";cout << "版本号:3.0n";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;}void gckdx(short h, short l){string n = "mode con cols=", t = "";while (l > 0){t = t + char(l % 10 + '0');l /= 10;}for (short i = t.size() - 1; i >= 0; i--){n = n + t[i];}n = n + " lines=", t = "";while (h > 0){t = t + char(h % 10 + '0');h /= 10;}for (short i = t.size() - 1; i >= 0; i--){n = n + t[i];}system(&n[0]);return;}void gckm(string n){string t = "title ";t += n;system(&t[0]);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
VS2019
第一步
打开VS2019
随便打开一个项目
第二步
右键“头文件”筛选器
选择“添加”->“新建项”
第三步
选择“头文件(.h)”
名称是“b_game.h”
位置是“D:”
第四步
点击添加
第五步
把原先的代码删掉
把上面的代码复制上去
第六步
调试(F5)
第七步
右键b_game.h
点击“移除”
第八步
点击移除
Devc++
第一步
打开Devc++
第二步
Ctrl+N新建源文件
第三步
把代码复制到源文件里
第四步
F11(编译运行)
这时会跳出来一个框框
用来保存
第五步
将文件名改为b_game.h
点击“计算机”
点击“本地磁盘(D:)”
点击保存
第六步
此时会跳出来一个框框
点击OK
第七步
Ctrl+W关闭b_game.h
代码
#include<D:b_game.h>
本文发布于:2024-01-30 22:31:50,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170662510923293.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |