先日、逃げ続けていたファイル分割を勉強し、試しに何も見ずにプログラムの館のキャラクターの操作をファイル分割して作ってみようと思い、以下のコードを書きました
//main.cpp
#include "DxLib.h"
#include "player.h"
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
ChangeWindowMode(TRUE),DxLib_Init(),SetDrawScreen(DX_SCREEN_BACK);
int key[256];
int x,y,handle;
handle = LoadGraph("画像/キャラクタ01.png",TRUE);
x = 270;
y = 300;
while(ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0)
{
DrawGraph(x,y,handle,TRUE);
player_key_update(key);
player_move(&x,&y,key);
player_test();
}
DxLib_End();
return 0;
}
//ここまでmain.cpp ここから↓player.cpp
#include "DxLib.h"
#define WHITE GetColor(255,255,255)
void player_test()
{
DrawFormatString(0,0,WHITE,"できてるよ~");
return;
}
int player_key_update(int key[])
{
char hoge[256];
GetHitKeyStateAll(hoge);
int i;
for(i=0;i<256;i++)
{
if(hoge[i] != 0)
key[i]++;
else
key[i] = 0;
}
return 0;
}
void player_move(int *x,int *y,int key[])
{
if(key[KEY_INPUT_UP] > 1)
*y--;
else if(key[KEY_INPUT_DOWN] > 1)
*y++;
else if(key[KEY_INPUT_RIGHT] > 1)
*x++;
else if(key[KEY_INPUT_LEFT] > 1)
*x--;
return;
}
//ここまでplayer.cpp 以下player.h
#ifndef SUM
#define SUM
void player_test();
int player_key_update(int*);
void player_move(int*,int*,int*);
#endif
main.obj : error LNK2001: 外部シンボル ""void __cdecl player_move(int *,int *,int *)" (?player_move@@YAXPAH00@Z)" は未解決です。
main.obj : error LNK2001: 外部シンボル ""int __cdecl player_key_update(int *)" (?player_key_update@@YAHPAH@Z)" は未解決です。
C:\Users\owner\Documents\Visual Studio 2010\Projects\ファイル分割\Debug\ファイル分割.exe : fatal error LNK1120: 外部参照 2 が未解決です。
とエラーメッセージが出ました
自分でコメントアウトしたりしておかしい箇所を探したところ、
player.cppの引数付の関数をなくせばリンクエラーが消えたので、この2つの関数に問題があるというのはわかるのですが、
プログラムの館の分割コンパイルの項目を見てもよくわからず困っております。
対処法を教えていただけると幸せです。
乱文長文失礼しました