1度簡単なゲームを作成し
第2弾を作ろうとしたところ error LNK2005に悩まされております
構造体の2重定義が原因のようなのですが解決策が分からないため質問させて頂きます。
お力をおかしください
ヘッダ
heard.h
#include "DxLib.h"
#ifdef GLOBAL_INSTANCE
#define GLOBAL
#else
#define GLOBAL extern
#endif
#include "variable.h"
#define PLAYER_X 200
#define PLAYER_Y 200
//関数
GLOBAL void load_main();
GLOBAL int get_move_key();
GLOBAL void game_main();struct Player{
int Grun[4];//走りグラ
int Grun2[4];//走りその2
int Attack;//たちグラ
int Px,Py;//プレイヤーの場所
} player_t;
main.cpp
#define GLOBAL_INSTANCE
#include "head.h"
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK ); //ウィンドウモード変更と初期化と裏画面設定
// while( 裏画面を表画面に反映, メッセージ処理, 画面クリア )
while( ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 ){
if(Game_Kind == 0){
load_main();
}
else if(Game_Kind == 1){
game_main();
}
}
DxLib_End(); // DXライブラリ終了処理
return 0;
}
#include "head.h"
char Buf[ 256 ] ;
int get_move_key(){
if(CheckHitKeyAll() != 0){
GetHitKeyStateAll( Buf ) ;
if( Buf[ KEY_INPUT_RIGHT ] == 1 )
{
return 1;
}
if( Buf[ KEY_INPUT_LEFT ] == 1 )
{
return 2;
}
}
return 0;
}
#include "head.h"
void load_main(){
// 透過色を変更
SetTransColor( 255 , 0 , 255 ) ;
//素材を読み込み
LoadDivGraph( "素材/run.bmp" ,4 ,4 ,1 ,48 ,60 ,player_t.Grun ) ;
LoadDivGraph( "素材/run2.bmp" ,4 ,4 ,1 ,48 ,60 ,player_t.Grun2 ) ;
player_t.Attack = LoadGraph("素材/attack.bmp");
//初期化
player_t.Px = PLAYER_X;
player_t.Py = PLAYER_Y;
Game_Kind = 1;
}
#include "head.h"
void run(){
if(get_move_key() == 1){
GrN++;
player_t.Px++;
DrawGraph( player_t.Px , player_t.Py , player_t.Grun2[GrN%4] , TRUE ) ;
}
if(get_move_key() == 2){
GrN++;
player_t.Px--;
DrawGraph( player_t.Px , player_t.Py , player_t.Grun[GrN%4] , TRUE ) ;
}
if(get_move_key() == 0){
DrawGraph( player_t.Px , player_t.Py , player_t.Attack , TRUE ) ;
GrN=0;
}
}
void game_main(){
run();
}