Last active
August 29, 2015 13:56
-
-
Save castaneai/9050117 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// プログラムは WinMain から始まります | |
int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int) | |
{ | |
// ウィンドウモードにする | |
ChangeWindowMode(true); | |
// DXライブラリ開始処理 | |
DxLib_Init(); | |
// 裏画面に描画するように変更 | |
SetDrawScreen(DX_SCREEN_BACK); | |
// FPSを設定 | |
static const int FPS = 60; | |
while (ProcessMessage() == 0) { | |
// ESCが押されたらアプリ終了 | |
if (CheckHitKey(KEY_INPUT_ESCAPE) != 0) { | |
break; | |
} | |
int startTime = GetNowCount(); | |
// 画面を消去 | |
ClearDrawScreen(); | |
// シーンを描画する | |
// -------------------- ここに描画処理を書く ---------------------- | |
// 裏画面を表画面に反映 | |
ScreenFlip(); | |
// 次のフレーム更新時間になるまで待つ | |
const int elapsedTime = GetNowCount() - startTime; | |
const int waitTime = (1 / FPS * 1000) - elapsedTime; | |
if (waitTime > 0) { | |
Sleep(waitTime); | |
} | |
} | |
// DXライブラリ終了処理 | |
DxLib_End(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment