You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

61 lines
1.5 KiB

using System;
namespace Sog
{
/// <summary>
/// 管理游戏逻辑的时间,和AppTime不同,AppTime就是时间(基于cpu的),这个是基于游戏具体的运行时间,可以暂停,加速减速等,某年某月某一天
/// </summary>
public class GameTime
{
//正常游戏1秒10帧,移动表现层做平滑
public const int LogicFPS = 30;
//移动帧率20
public const int MoveLoopCount = 1;
//子弹帧率30
public const int BulletLoopCount = 1;
//毫秒
public const int LogicTimeOneFrameMs = 1000 / LogicFPS;
public readonly static Fixed64 LogicTimeOneFrameFixed64 = ((Fixed64)LogicTimeOneFrameMs / 1000);
public readonly static Fixed64 LogicTimeMoveFixed64 = LogicTimeOneFrameFixed64 / MoveLoopCount;
public readonly static Fixed64 LogicTimeBulletFixed64 = LogicTimeOneFrameFixed64 / BulletLoopCount;
int _totalFrameCount = 0;
public GameTime()
{
_totalFrameCount = 0;
}
public void UpdateOneFrame()
{
_totalFrameCount++;
}
public int GetLogicFrame()
{
return _totalFrameCount;
}
//framecount * frametime
public Fixed64 GetTimeFixed()
{
return _totalFrameCount * LogicTimeOneFrameFixed64;
}
public int GetTimeMs()
{
return _totalFrameCount * LogicTimeOneFrameMs;
}
}
}