YUTU魔改的b_game,饼干原创

YUTU研究了饼干的b_game库,感觉很好用,后期我要和我的伙伴深莫的森林一起用b_game

制作更好玩的game(游戏)!

不是YUTU原创的,找原版,去搜@饼干369。(没有句号)

上代码!

#ifndef b_game
#define b_game
#include<iostream>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<windows.h>
#include<conio.h>
#include<fstream>
#define qdo 262
#define qre 294
#define qmi 330     //q前缀为低音,1后缀为高音,s前缀为半音阶
#define qfa 349
#define qso 392
#define qla 440
#define qsi 494
#define do 523
#define re 578
#define mi 659
#define fa 698
#define so 784
#define la 880
#define si 988
#define do1 1046
#define re1 1175
#define mi1 1318
#define fa1 1480
#define so1 1568
#define la1 1760
#define si1 1976
#define sqdo 277
#define sqre 311
#define sqfa 370
#define sqso 415
#define sqla 466
#define sdo 554
#define sre 622
#define sfa 740
#define sso 831
#define sla 932
#define sdo1 1046
#define sre1 1245
#define sfa1 1480
#define sso1 1661
#define sla1 1865
using namespace std;
void printf_red(const char *s)
{
    printf("\033[0m\033[1;31m%s\033[0m", s);
}

void printf_green(const char *s)
{
    printf("\033[0m\033[1;32m%s\033[0m", s);
}

void printf_yellow(const char *s)
{
    printf("\033[0m\033[1;33m%s\033[0m", s);
}

void printf_blue(const char *s)
{
    printf("\033[0m\033[1;34m%s\033[0m", s);
}

void printf_pink(const char *s)
{
    printf("\033[0m\033[1;35m%s\033[0m", s);
}

void printf_cyan(const char *s)
{
    printf("\033[0m\033[1;36m%s\033[0m", s);
}

namespace _game
{//YUTU是在饼干的代码上加以改进,还增添了一些东西,应该不是抄袭吧?
// YUTU还在上面加了备注,b_game.h一堆拼音,很多人看不懂。
	//结构体与类提前声明
	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);//颜色

	//常量
	//运用了:#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
	//这么用:
	//if(KEY_DOWN(输入你的东西,东西在下面)……
	const long long ESC = 27,//电脑左上角的esc
		Enter = 13,//回车
		Tab = 9,//esc下面一些的tab
		Shang = 38,//\、
		Xia = 40,//   |方向键
		Zuo = 37,//   |
		You = 39,//  /
		Kong = ' ',//空格
		z_sb = VK_LBUTTON,//鼠标左键
		y_sb = VK_RBUTTON,//鼠标右键
		Shift = VK_SHIFT,//上档
		z_Shift = VK_LSHIFT,//左边的SHIFT
		y_Shift = VK_RSHIFT,//右边的shift
		Ctrl = VK_CONTROL,//控制
		z_Ctrl = VK_LCONTROL,//左边的Ctrl
		y_Ctrl = VK_RCONTROL,//右边的Ctrl
		Alt = VK_MENU,//windows右边的alt
		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()//查看当前库版本信息
	{
		system("cls");
		cout << "库名:被YUTU魔改过的b_game.h\n";
		cout << "类型:真~拓展库\n";
		cout << "版本号:3.0\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;
	}
	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

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值