FPSが60になりません、どこか間違っているでしょうか?
環境はDXライブラリです
#include "DxLib.h"
int Key[256];
int GetHitKeyStateAll_2(int GetHitKeyStateAll_InputKey[/url]){
char GetHitKeyStateAll_Key[256];
GetHitKeyStateAll( GetHitKeyStateAll_Key );
for(int i=0;i<256;i++){
if(GetHitKeyStateAll_Key==1) GetHitKeyStateAll_InputKey++;
else GetHitKeyStateAll_InputKey=0;
}
return 0;
}
int count=0;
void wait_fanc(){
int term;
static int t=0;
if( count%60==1 )t=GetNowCount();
if( count%60==60 )term=1000+t-GetNowCount();
else term=(1000.0/60)*(count%60)+t-GetNowCount();
if(term>0)Sleep(term);
}
void fps(){
int i;
static int t=0,ave=0,f[60];
f[count%60]=GetNowCount()-t;
t=GetNowCount();
if(count%60==59){
ave=0;
for(i=0;i<60;i++)
ave+=f;
ave/=60;
}
if(ave!=0){
DrawFormatString(0, 0,GetColor(255,255,255),"%.1fFPS",1000.0/(double)ave);
DrawFormatString(0,20,GetColor(255,255,255),"%dms" ,ave);
}
return;
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode(TRUE);SetOutApplicationLogValidFlag( FALSE );
if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1;//初期化と裏画面化
while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0){
//↑メッセージ処理 ↑画面をクリア ↑入力状態を保存 ↑ESCが押されていない
fps();
count++;
ScreenFlip();
wait_fanc();
}
DxLib_End();
return 0;
}