gpUpdateKey()を他ファイルにして共通化したいのですが上手くいきません。
こんな感じでやっています。
--- main.cpp ---
#include "DxLib.h"
#include<math.h>
#include "globalfunc.h"
int DxLib_InitEx(略)
{
// 略
}
int processLoop()
{
// 略
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
DxLib_InitEx();
while(processLoop() == 0)
{
gpUpdateKey();
if(Key[KEY_INPUT_ESCAPE) == 1) { break;}
}
DxLib_End();
return 0;
}
#include<DxLib.h>
int Key[256]; // キーが押されているフレーム数を格納する
// キーの入力状態を更新する
int gpUpdateKey(){
char tmpKey[256]; // 現在のキーの入力状態を格納する
GetHitKeyStateAll( tmpKey ); // 全てのキーの入力状態を得る
for( int i=0; i<256; i++ ){
if( tmpKey[i] != 0 ){ // i番のキーコードに対応するキーが押されていたら
Key[i]++; // 加算
} else { // 押されていなければ
Key[i] = 0; // 0にする
}
}
return 0;
}
よろしくお願いします。