码迷,mamicode.com
首页 > 其他好文 > 详细

1.game.h

时间:2020-02-03 12:03:34      阅读:65      评论:0      收藏:0      [点我收藏+]

标签:bool   des   led   tput   access   als   文件   scan   ati   

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);
}
//会更新的

1.game.h

标签:bool   des   led   tput   access   als   文件   scan   ati   

原文地址:https://www.cnblogs.com/yuzijiangorz/p/12254895.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!