エラーが出て困っています・・・
Posted: 2013年4月20日(土) 00:48
エラー 1 error LNK2005: _WinMain@16 は既に main.obj で定義されています。 C:\Users\りゅーのす\Desktop\Game4\Game4\test.obj
エラー 2 error LNK2019: 未解決の外部シンボル "void __cdecl Player_Draw(void)" (?Player_Draw@@YAXXZ) が関数 _WinMain@16 で参照されました。 C:\Users\りゅーのす\Desktop\Game4\Game4\main.obj
エラー 3 error LNK1120: 外部参照 1 が未解決です。 C:\Users\りゅーのす\Desktop\Game4\Debug\Game4.exe 1
main.cppです。
#include "DxLib.h"
#include "Player.h"
#include "Keyboard.h"
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK);
Player_Initialize();
while(ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0){
Player_test();
Keyboard_Update();
Player_Update();
Player_Draw();
}
DxLib_End();
return 0;
}
test.cppです。
#include "DxLib.h"
#define PI 3.141592654
int Key[256]; //キーが押されているフレーム数を格納する
//キーの入力状態を更新する
int gpUpdateKey(){
char tmpKey[256]; //現在のキーの入力状態を格納する
GetHitKeyStateAll(tmpKey); //全てのキーの入力状態を得る
for(int i = 0; i < 256; i++){
if(tmpKey != 0){ //i番のキーコードに対応するキーが押されていたら
Key++; //加算
}else{ //押されていなければ
Key = 0; //0にする
}
}
return 0;
}
typedef struct{
int x, y; //座標格納用変数
char name[128]; //項目名格納用変数
}MenuElement_t;
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){
//ChangeWindowMode(TRUE);//ウィンドウモードに設定
//LoadGraphScreen(50, 10, "sample.jpg",TRUE); //画像を絵画する 必要なし
//DxLib_Init(); //DXライブラリ初期化処理
//SetDrawScreen( DX_SCREEN_BACK);//画像先を裏画面に設定
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK);
MenuElement_t MenuElement[3] = {
{ 80, 100, "スタート"},
{100, 150, "おまけ"},
{100, 200, "終了"},
};
int SelectNum = 0; //現在の選択番号
int x = 320 , y = 245;
//int image[16];
//LoadDivGraph("sample2.png", 16, 4, 4, 32, 32, image); //画像の分割読み込み
//int Green = GetColor(0, 255, 0); //色の設定
int Handle; //データハンドル格納用変数
Handle = LoadGraph("sample2.png", TRUE); //画像をロード
//DrawGraph(50, 100, Handle, TRUE); //データハンドルを使用し画像を絵画
//while(裏画面を表表示、メッセージ処理、画面クリア)
while(ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0){//×ボタンで終了
//if(ProcessMessage() != 0){
//break;
//}
//ClearDrawScreen();//画面を消す
//DrawGraph(x, 100, Handle, TRUE);//画像の絵画
//DrawGraph(x / 2, 200, Handle, TRUE); //画像の絵画
//DrawGraph(x / 4, 300, Handle, TRUE); //画像の絵画
//DrawGraph(x, 0, Handle, TRUE); //画像の絵画
//DrawRotaGraph(400, 200, 2.0, PI / 4, Handle, TRUE);//画像の絵画 斜め
//SetDrawBlendMode(DX_BLENDMODE_ALPHA, 128);//透過度
//DrawGraph(100, 200, Handle, TRUE); //画像の絵画
//DrawGraph(120, 200, Handle, TRUE); //画像の絵画
//SetDrawBlendMode(DX_BLENDMODE_ADD, 255);
//DrawGraph(300, 200, Handle, TRUE); //画像の絵画
//DrawGraph(320, 200, Handle, TRUE); //画像の絵画
//DrawRotaGraph(x, 200, 1.0, 0.0, Handle, TRUE);//画像の絵画 斜め
//SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);//透過度
//DrawRotaGraph(100, 200, 1.0, 0.0, Handle, TRUE); //画像の絵画 斜め
//DrawRotaGraph(400, 200, 2.0, PI / 4, Handle, TRUE); //画像の絵画 斜め
//DrawFormatString(x, y, Green, "私は人形じゃない!", x, y); //文字を表示
//DrawGraph(0, 0, image[8], TRUE); //画像を表示
//DrawFormatString(x, 0, GetColor(255, 255, 255), "!!");
//if(CheckHitKey(KEY_INPUT_RIGHT)!= 0){
//x = x + 50;
//x++; //xを1増やす
//y = y + 1; //y座標を1追加
//x = x + 2;//xを2増やす
//Sleep(7);//7[ms]
//ScreenFlip();//裏画面を表画面に反映
//if(Key[KEY_INPUT_X]>= 60){ //60フレーム以上押されたら
//DrawFormatString(0, 0, GetColor(255, 255, 255), "!?"); //文字を表示する
//}
if(Key[KEY_INPUT_DOWN] == 1){
SelectNum = (SelectNum + 1) % 5;
}
if(Key[KEY_INPUT_UP] == 1){
SelectNum = (SelectNum + 4) % 5;
}
if(Key[KEY_INPUT_DOWN] == 1 || Key[KEY_INPUT_UP] == 1){
for(int i = 0; i < 5; i++){
if(i == SelectNum){
MenuElement.x = 80;
}else{
MenuElement.x = 100;
}
}
}
for(int i = 0; i < 5; i++){ //メニュー項目を絵画
DrawFormatString(MenuElement.x, MenuElement.y, GetColor(255, 255, 0), MenuElement.name);
}
if(Key[KEY_INPUT_RIGHT] >= 1){ //右キーが押されたら
x++;//右へ移動
}
if(Key[KEY_INPUT_DOWN] >= 1){ //下キーが押されていたら
y++;//下へ移動
}
if(Key[KEY_INPUT_LEFT] >= 1){//左キーが押されていたら
x--;//左へ移動
}
if(Key[KEY_INPUT_UP] >= 1){ //上キーが押されていたら
y--;//上へ移動
}
DrawRotaGraph(x, y, 1.0, 0.0, Handle, TRUE); //x, yの位置にキャラを絵画
//}
}
//WaitKey(); //キー入力待ち
DxLib_End(); //DXライブラリ終了処理
return 0;
}
//while文の中でゲームの中核となるコードを追加。
一番上にあるエラーをどう解決すればよいのかわかりません・・・・
申し訳ありませんが教えてください・・・
エラー 2 error LNK2019: 未解決の外部シンボル "void __cdecl Player_Draw(void)" (?Player_Draw@@YAXXZ) が関数 _WinMain@16 で参照されました。 C:\Users\りゅーのす\Desktop\Game4\Game4\main.obj
エラー 3 error LNK1120: 外部参照 1 が未解決です。 C:\Users\りゅーのす\Desktop\Game4\Debug\Game4.exe 1
main.cppです。
#include "DxLib.h"
#include "Player.h"
#include "Keyboard.h"
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK);
Player_Initialize();
while(ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0){
Player_test();
Keyboard_Update();
Player_Update();
Player_Draw();
}
DxLib_End();
return 0;
}
test.cppです。
#include "DxLib.h"
#define PI 3.141592654
int Key[256]; //キーが押されているフレーム数を格納する
//キーの入力状態を更新する
int gpUpdateKey(){
char tmpKey[256]; //現在のキーの入力状態を格納する
GetHitKeyStateAll(tmpKey); //全てのキーの入力状態を得る
for(int i = 0; i < 256; i++){
if(tmpKey != 0){ //i番のキーコードに対応するキーが押されていたら
Key++; //加算
}else{ //押されていなければ
Key = 0; //0にする
}
}
return 0;
}
typedef struct{
int x, y; //座標格納用変数
char name[128]; //項目名格納用変数
}MenuElement_t;
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){
//ChangeWindowMode(TRUE);//ウィンドウモードに設定
//LoadGraphScreen(50, 10, "sample.jpg",TRUE); //画像を絵画する 必要なし
//DxLib_Init(); //DXライブラリ初期化処理
//SetDrawScreen( DX_SCREEN_BACK);//画像先を裏画面に設定
ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK);
MenuElement_t MenuElement[3] = {
{ 80, 100, "スタート"},
{100, 150, "おまけ"},
{100, 200, "終了"},
};
int SelectNum = 0; //現在の選択番号
int x = 320 , y = 245;
//int image[16];
//LoadDivGraph("sample2.png", 16, 4, 4, 32, 32, image); //画像の分割読み込み
//int Green = GetColor(0, 255, 0); //色の設定
int Handle; //データハンドル格納用変数
Handle = LoadGraph("sample2.png", TRUE); //画像をロード
//DrawGraph(50, 100, Handle, TRUE); //データハンドルを使用し画像を絵画
//while(裏画面を表表示、メッセージ処理、画面クリア)
while(ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0){//×ボタンで終了
//if(ProcessMessage() != 0){
//break;
//}
//ClearDrawScreen();//画面を消す
//DrawGraph(x, 100, Handle, TRUE);//画像の絵画
//DrawGraph(x / 2, 200, Handle, TRUE); //画像の絵画
//DrawGraph(x / 4, 300, Handle, TRUE); //画像の絵画
//DrawGraph(x, 0, Handle, TRUE); //画像の絵画
//DrawRotaGraph(400, 200, 2.0, PI / 4, Handle, TRUE);//画像の絵画 斜め
//SetDrawBlendMode(DX_BLENDMODE_ALPHA, 128);//透過度
//DrawGraph(100, 200, Handle, TRUE); //画像の絵画
//DrawGraph(120, 200, Handle, TRUE); //画像の絵画
//SetDrawBlendMode(DX_BLENDMODE_ADD, 255);
//DrawGraph(300, 200, Handle, TRUE); //画像の絵画
//DrawGraph(320, 200, Handle, TRUE); //画像の絵画
//DrawRotaGraph(x, 200, 1.0, 0.0, Handle, TRUE);//画像の絵画 斜め
//SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);//透過度
//DrawRotaGraph(100, 200, 1.0, 0.0, Handle, TRUE); //画像の絵画 斜め
//DrawRotaGraph(400, 200, 2.0, PI / 4, Handle, TRUE); //画像の絵画 斜め
//DrawFormatString(x, y, Green, "私は人形じゃない!", x, y); //文字を表示
//DrawGraph(0, 0, image[8], TRUE); //画像を表示
//DrawFormatString(x, 0, GetColor(255, 255, 255), "!!");
//if(CheckHitKey(KEY_INPUT_RIGHT)!= 0){
//x = x + 50;
//x++; //xを1増やす
//y = y + 1; //y座標を1追加
//x = x + 2;//xを2増やす
//Sleep(7);//7[ms]
//ScreenFlip();//裏画面を表画面に反映
//if(Key[KEY_INPUT_X]>= 60){ //60フレーム以上押されたら
//DrawFormatString(0, 0, GetColor(255, 255, 255), "!?"); //文字を表示する
//}
if(Key[KEY_INPUT_DOWN] == 1){
SelectNum = (SelectNum + 1) % 5;
}
if(Key[KEY_INPUT_UP] == 1){
SelectNum = (SelectNum + 4) % 5;
}
if(Key[KEY_INPUT_DOWN] == 1 || Key[KEY_INPUT_UP] == 1){
for(int i = 0; i < 5; i++){
if(i == SelectNum){
MenuElement.x = 80;
}else{
MenuElement.x = 100;
}
}
}
for(int i = 0; i < 5; i++){ //メニュー項目を絵画
DrawFormatString(MenuElement.x, MenuElement.y, GetColor(255, 255, 0), MenuElement.name);
}
if(Key[KEY_INPUT_RIGHT] >= 1){ //右キーが押されたら
x++;//右へ移動
}
if(Key[KEY_INPUT_DOWN] >= 1){ //下キーが押されていたら
y++;//下へ移動
}
if(Key[KEY_INPUT_LEFT] >= 1){//左キーが押されていたら
x--;//左へ移動
}
if(Key[KEY_INPUT_UP] >= 1){ //上キーが押されていたら
y--;//上へ移動
}
DrawRotaGraph(x, y, 1.0, 0.0, Handle, TRUE); //x, yの位置にキャラを絵画
//}
}
//WaitKey(); //キー入力待ち
DxLib_End(); //DXライブラリ終了処理
return 0;
}
//while文の中でゲームの中核となるコードを追加。
一番上にあるエラーをどう解決すればよいのかわかりません・・・・
申し訳ありませんが教えてください・・・