本文整理汇总了C++中Timer::GetCounter方法的典型用法代码示例。如果您正苦于以下问题:C++ Timer::GetCounter方法的具体用法?C++ Timer::GetCounter怎么用?C++ Timer::GetCounter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::GetCounter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tWinMain
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine,
_In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: разместите код здесь.
MSG msg;
HACCEL hAccelTable;
// »нициализаци¤ глобальных строк
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_WIN32PROJECT3, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// ¬ыполнить инициализацию приложени¤:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WIN32PROJECT3));
try
{
// create
gl.reset(new shell::Ogl());
game.reset(new mech::Game());
// init
gl->Bind(hWnd);
menu = game->GetInterface();
// timer & rng
Timer timer;
std::srand((unsigned int)timer.GetCounter());
timer.Start();
// main & message loop:
auto last_turn = game->GetTurn();
bool run = true;
while (!game->IsFinished() && run)
{
auto current_turn = game->GetTurn();
if (last_turn != current_turn)
{
timer.Start();
last_turn = current_turn;
}
gl->Draw(*game, timer.GetCounter());
// windows dispatcher
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) != 0)
{
run &= (GetMessage(&msg, NULL, 0, 0) == TRUE);
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
}
catch (std::runtime_error &exc)
{
wchar_t message[1025];
MultiByteToWideChar(CP_ACP, 0, exc.what(), -1, message, 1024);
MessageBox(NULL, message, NULL, NULL);
}
return (int) msg.wParam;
}