#1
by ゆうchin » 4年前
コード:
#include "DxLib.h"
int map[15][20] = {
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
};
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) {
int x = 200;
int y = 384;
int pj;
bool PR, PL, JumpFlag = false;
char img;
int count = 0;
ChangeWindowMode(TRUE);//非全画面にセット
SetAlwaysRunFlag(true);
SetDrawScreen(DX_SCREEN_BACK);//描画先を裏画面に
SetGraphMode(640, 480, 16);
if (DxLib_Init() == -1) { return -1; }//初期化に失敗時にエラーを吐かせて終了
int main3_1 = LoadGraph("pic\\chara_main3.png");
int main3_move1 = LoadGraph("pic\\chara_main3_move1.png");
int main3_move2 = LoadGraph("pic\\chara_main3_move2.png");
int main3_move3 = LoadGraph("pic\\chara_main3_move3.png");
int block = LoadGraph("pic\\block.png");
while (1) {
count++;
if (y >= 384) { pj = 10; y -= 3;} // ジャンプ可能回数
if (CheckHitKey(KEY_INPUT_RIGHT) > 0 && 0 < count%15 && count%15 <= 5) { img = main3_move3; }
else if (CheckHitKey(KEY_INPUT_RIGHT) > 0 && 5 < count % 15 && count % 15 <= 10) { img = main3_move2; }
else if (CheckHitKey(KEY_INPUT_RIGHT) > 0 && 10 < count % 15 && count % 15 <= 15) { img = main3_move1; }
else if (CheckHitKey(KEY_INPUT_LEFT) > 0 && 0 < count % 15 && count % 15 <= 5) { img = main3_move1; }
else if (CheckHitKey(KEY_INPUT_LEFT) > 0 && 5 < count % 15 && count % 15 <= 10) { img = main3_move2; }
else if (CheckHitKey(KEY_INPUT_LEFT) > 0 && 10 < count % 15 && count % 15 <= 15) { img = main3_move3; }
if (CheckHitKey(KEY_INPUT_RIGHT) == 1 || CheckHitKey(KEY_INPUT_D) == 1) { PR = true; }
else { PR = false; }
if (CheckHitKey(KEY_INPUT_LEFT) == 1 || CheckHitKey(KEY_INPUT_A) == 1) { PL = true; }
else { PL = false; }
if (CheckHitKey(KEY_INPUT_UP) == 1 || CheckHitKey(KEY_INPUT_W) == 1) { JumpFlag = true; }
else {
JumpFlag = false;
}
if (PR == true) { x += 3; }
if (PL == true) { x -= 3; }
if (JumpFlag == true) {
for (int a = 0; a < 6; a++) {
pj -= 1;
y += 5;
}
}
ClearDrawScreen();
DrawGraph(x, y, img, TRUE);
for (int a = 0; a < 15; a++) {
for (int b = 0; b < 20; b++) {
switch (map[a][b]) {
case 1:
DrawGraph(b * 32, a * 32, block, FALSE);
break;
}
}
}
ScreenFlip();
if (CheckHitKey(KEY_INPUT_ESCAPE) > 0) break;
if (ProcessMessage() < 0) break;
Sleep(16);
}
DxLib_End();
return 0;
}
このような物理演算もあまり気にしないような練習用プログラムを書いてみたのですが、LNK2019 未解決の外部シンボル_main が関数 "int_cdecl invoke main(void)" (?invoke_main @@ YAHXZ) で参照されました。というものとLNK1120 1件の未解決の外部参照 という二つのエラー出てきてしまい、実行も出来ずに良くわかりません。調べてみても、リンカーのエラーということだけ辛うじてわかる程度でした。もしよければ、解決方法又は原因など教えてください。よろしくお願いします。
[code]
#include "DxLib.h"
int map[15][20] = {
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
{1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1},
};
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) {
int x = 200;
int y = 384;
int pj;
bool PR, PL, JumpFlag = false;
char img;
int count = 0;
ChangeWindowMode(TRUE);//非全画面にセット
SetAlwaysRunFlag(true);
SetDrawScreen(DX_SCREEN_BACK);//描画先を裏画面に
SetGraphMode(640, 480, 16);
if (DxLib_Init() == -1) { return -1; }//初期化に失敗時にエラーを吐かせて終了
int main3_1 = LoadGraph("pic\\chara_main3.png");
int main3_move1 = LoadGraph("pic\\chara_main3_move1.png");
int main3_move2 = LoadGraph("pic\\chara_main3_move2.png");
int main3_move3 = LoadGraph("pic\\chara_main3_move3.png");
int block = LoadGraph("pic\\block.png");
while (1) {
count++;
if (y >= 384) { pj = 10; y -= 3;} // ジャンプ可能回数
if (CheckHitKey(KEY_INPUT_RIGHT) > 0 && 0 < count%15 && count%15 <= 5) { img = main3_move3; }
else if (CheckHitKey(KEY_INPUT_RIGHT) > 0 && 5 < count % 15 && count % 15 <= 10) { img = main3_move2; }
else if (CheckHitKey(KEY_INPUT_RIGHT) > 0 && 10 < count % 15 && count % 15 <= 15) { img = main3_move1; }
else if (CheckHitKey(KEY_INPUT_LEFT) > 0 && 0 < count % 15 && count % 15 <= 5) { img = main3_move1; }
else if (CheckHitKey(KEY_INPUT_LEFT) > 0 && 5 < count % 15 && count % 15 <= 10) { img = main3_move2; }
else if (CheckHitKey(KEY_INPUT_LEFT) > 0 && 10 < count % 15 && count % 15 <= 15) { img = main3_move3; }
if (CheckHitKey(KEY_INPUT_RIGHT) == 1 || CheckHitKey(KEY_INPUT_D) == 1) { PR = true; }
else { PR = false; }
if (CheckHitKey(KEY_INPUT_LEFT) == 1 || CheckHitKey(KEY_INPUT_A) == 1) { PL = true; }
else { PL = false; }
if (CheckHitKey(KEY_INPUT_UP) == 1 || CheckHitKey(KEY_INPUT_W) == 1) { JumpFlag = true; }
else {
JumpFlag = false;
}
if (PR == true) { x += 3; }
if (PL == true) { x -= 3; }
if (JumpFlag == true) {
for (int a = 0; a < 6; a++) {
pj -= 1;
y += 5;
}
}
ClearDrawScreen();
DrawGraph(x, y, img, TRUE);
for (int a = 0; a < 15; a++) {
for (int b = 0; b < 20; b++) {
switch (map[a][b]) {
case 1:
DrawGraph(b * 32, a * 32, block, FALSE);
break;
}
}
}
ScreenFlip();
if (CheckHitKey(KEY_INPUT_ESCAPE) > 0) break;
if (ProcessMessage() < 0) break;
Sleep(16);
}
DxLib_End();
return 0;
}
[/code]
このような物理演算もあまり気にしないような練習用プログラムを書いてみたのですが、LNK2019 未解決の外部シンボル_main が関数 "int_cdecl invoke main(void)" (?invoke_main @@ YAHXZ) で参照されました。というものとLNK1120 1件の未解決の外部参照 という二つのエラー出てきてしまい、実行も出来ずに良くわかりません。調べてみても、リンカーのエラーということだけ辛うじてわかる程度でした。もしよければ、解決方法又は原因など教えてください。よろしくお願いします。