game_hs 函数讲解——out类

前言:

        先附上原文链接函数 1.0

        然后在c++里面写上这玩意

#include<bits/stdc++.h>//输入输出用的 
#include<windows.h>//SLeep等函数 
using namespace std;
namespace _game_hs{
	bool axj(int a){
		return GetKeyState(a)<0;
	}
	void color(int c)
	{
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c);
		return;
	}
	void colorout(string s,int c){
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),c);
		cout<<s;
		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15);
		return;
	}
	void out(string s,int q){
		for(int i=0;i<s.size();i++){
			cout<<s[i];
			Sleep(q);
		}
		return;
	}
	void zk(string s,char c,string cd){
		int n=s.size(),n1=cd.size();
		if(cd=="长度")n1=100;
		int tot=n1-n;
		for(int i=0;i<tot/2;i++)
		cout<<c;
		cout<<s;
		if(tot%2==1)tot++;
		tot/=2;
		for(int i=0;i<tot;i++)
		cout<<c;
		return;
	}
	void zc(string s,char t,string cd){
		cout<<s;
		for(int i=s.size();i<cd.size();i++)
		cout<<t;
		return;
	}
}
using namespace _game_hs;
int main(){
	
	return 0;
}

二:void out(string s,int t);

这个函数是控制每次输出时等待一段时间

s表示输出的字符串,t表示等待的时间

引用代码:

out("让我们一起加油吧!!!",40);

三:void zk(string s,char c,string cd);

这个函数是让我们在一个范围内把字符串在中间输出,其余输出字符c

s表示输出地字符串

c表示其他位置用什么填充

cd表示在多大的范围内填充,可以用字符串来表示(最后取字符串的长度),或者用“长度”(表示长度为100)。

引用代码:

system("mode con cols=100 lines=35");
zk("欢迎来到Y_game",'-',"长度");

效果

game_hs 函数讲解——out类

四:void zc(string s,char t,string cd);

这个函数和上个函数差不多,只不过是让我们的字符在左侧输出

引用代码:

system("mode con cols=100 lines=35");
zc("欢迎来到Y_game",'-',"长度");

效果:game_hs 函数讲解——out类

 

上一篇:C语言实现扫雷小游戏


下一篇:从这里开始你的游戏黑客入门的之旅吧