⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 custom_time.cpp

📁 游戏编程精髓里的人工智能源代码很好的源代码!
💻 CPP
字号:
/* Copyright (C) Steve Rabin, 2000.  * All rights reserved worldwide. * * This software is provided "as is" without express or implied * warranties. You may freely copy and compile this source into * applications you distribute provided that the copyright text * below is included in the resulting source code, for example: * "Portions Copyright (C) Steve Rabin, 2000" */#ifdef _WIN32#include <windows.h>#include <time.h>#else#include <stdio.h>#include <sys/timeb.h>#endif#ifdef _WIN32float g_StartTime = -1.0f;#elsestruct timeb   g_StartTimeb;#endiffloat g_CurrentTime = -1.0f;float g_TimeLastTick = -1.0f;void InitTime( void ){#ifdef _WIN32	g_StartTime = ((float)timeGetTime()) / 1000.0f;#else	ftime(&g_StartTimeb);#endif	g_CurrentTime = 0.0f;	g_TimeLastTick = 0.001f;}void MarkTimeThisTick( void ){#ifdef _WIN32	float newTime = (((float)timeGetTime()) / 1000.0f) - g_StartTime;#else	struct timeb tp;	ftime(&tp);	float newTime = tp.time - g_StartTimeb.time +	  (tp.millitm/1000.0) - (g_StartTimeb.millitm/1000.0);#endif	g_TimeLastTick = newTime - g_CurrentTime;	g_CurrentTime = newTime;	if( g_TimeLastTick <= 0.0f ) {		g_TimeLastTick = 0.001f;	}}float GetElapsedTime( void ){	return( g_TimeLastTick );}float GetExactTime( void ){#ifdef _WIN32	return( ((float)timeGetTime())/1000.0f );#else	struct timeb tp;	ftime(&tp);	return tp.time - g_StartTimeb.time +	  (tp.millitm/1000.0) - (g_StartTimeb.millitm/1000.0);#endif}float GetCurTime( void ){	return( g_CurrentTime );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -