#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 main3_1 = LoadGraph("pic\\chara_main3.png");
int x = 200;
int y = 384;
int pj;
bool PR, PL, JumpFlag = false;
char img = main3_1;
int count = 0;
ChangeWindowMode(TRUE);//非全画面にセット
SetAlwaysRunFlag(true);
SetDrawScreen(DX_SCREEN_BACK);//描画先を裏画面に
SetGraphMode(640, 480, 16);
if (DxLib_Init() == -1) { return -1; }//初期化に失敗時にエラーを吐かせて終了
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 (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 (y >= 384) { pj = 10; y -= 3; } // ジャンプ可能回数
if (PR == true && 0 < count%15 && count%15 <= 5) { img = main3_move3; }
else if (PR == true && 5 < count % 15 && count % 15 <= 10) { img = main3_move2; }
else if (PR == true && 10 < count % 15 && count % 15 <= 15) { img = main3_move1; }
else if (PL == true && 0 < count % 15 && count % 15 <= 5) { img = main3_move1; }
else if (PL == true && 5 < count % 15 && count % 15 <= 10) { img = main3_move2; }
else if (PL == true && 10 < count % 15 && count % 15 <= 15) { img = main3_move3; }
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, FALSE);
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;
}
自分は、ステージをblockという画像で下に二段描写し、その上にキャラが立っているようにしたく、block(32pixel)*2 とキャラ(32pixel) の合計96pixel分y軸480から引いてそこで当たり判定をつけるべくやってみたつもりなのですが、実行してみると何故かステージ部分だけが表示されて、キャラは表示されませんでした。
何かコードに問題があるでしょうか。。。 もしよろしければ、教えていただきたいです。