game.h
//以后会一直更新的呢.
/*
Name: game.h
Copyright: MG.ltd
Author: yuzijiangorz
Date: 04/01/20 13:54
Description: about games
*/
#include <bits/stdc++.h>
#include <windows.h>
#include <fstream>
#include <tchar.h>
#include <io.h>
#include <conio.h>
using namespace std;
//define
#define INFO_BUFFER_SIZE (MAX_COMPUTERNAME_LENGTH + 1)
//上下左右键的ASCII码值
#define UPK 72
#define DOWNK 80
#define LEFTK 75
#define RIGHTK 77
//随机
inline unsigned int rnd(const unsigned int& n)
{
srand(int(time(NULL)));
static unsigned int seed=0,c1=rand()%1000,c2=rand()%4566,c3=rand()%1029;
if (seed==0)seed=(UINT)::GetTickCount();
seed=(seed*c1+c2)%c3;
return seed*n/c3;
}
// __int128 I/O
inline __int128 scan(){//in
__int128 x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
inline void print(__int128 x){//out
if(x<0){
putchar('-');
x=-x;
}
if(x>9)
print(x/10);
putchar(x%10+'0');
}
//about out
void SlowDisplay(char *p)//缓慢输出
{
while(*p!=0)
{
printf("%c",*p++);
Sleep(40);//可以被改变
}
}
//about console
void color(int a) {SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);}//改变颜色(1~256)
void settitle(char *s) {SetConsoleTitle(s);}//设置标题
void Getcomputername(void)//得到本机的名字
{
CHAR infoBuf[INFO_BUFFER_SIZE];
DWORD bufCharCount = INFO_BUFFER_SIZE;
// Get and display the name of the computer.
if( GetComputerName( infoBuf, &bufCharCount ) ) {
_tprintf( "The NetBIOS name of the local computer is %s \n", infoBuf );
}
else {
_tprintf( "Get NetBIOS name of the local computer failed with error %lu \n", GetLastError() );
}
}
//about file and folder
int createf(char *f)//创建文件夹
{
int status;
status=mkdir(f);
if(status==-1)
{
cout<<"\a";
MessageBox(NULL,"Error:create folder failed!","error",MB_ICONERROR);
return -1;
}
return status;
}
bool fie(char *l)//判断文件是否存在
{
if(access(l,0)!=-1) return true;
else return false;
}
void HideCursor()//隐藏cmd光标
{
CONSOLE_CURSOR_INFO cursor;
cursor.bVisible = FALSE;
cursor.dwSize = sizeof(cursor);
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorInfo(handle, &cursor);
}
//会更新的
原文地址:https://www.cnblogs.com/yuzijiangorz/p/12254895.html
时间: 2024-11-10 01:18:22