我已經在控制檯中用C++創建了運行迷宮遊戲。C++迷宮計數傳遞時間
我想添加函數來計算玩家通過迷宮所需的時間。
通過迷宮後可顯示總時間。
我真的很感激任何幫助或想法。
遊戲主循環看起來就像這樣:
do {
show(); // function do display maze , 2d array
cout << "Your position: " << x << " " << y << endl;
cout << "Coins gained: " << coins << endl;
cout << "blahblahblah" : "<<endl;
m = getche();
cout << endl;
move(m); // function to recognize which way player want to go, including checking for not going through the wall
cout << endl;
system("CLS");
} while (x != 12 || y != 18 || coins < 10); //for pass the maze player have to move on these position and gain x coins
system("CLS");
cout << "You Won!" << endl;
cout << "Click enter to move on. \n";
你的帖子不清楚你實際需要什麼幫助。你有一個_specific_問題或什麼_specific_你需要幫助嗎? \ –
如果你的編譯器支持C++ 11'std :: chrono'將會是開始的地方:http://en.cppreference.com/w/cpp/chrono – drescherjm