ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら

トピックに返信する


答えを正確にご入力ください。答えられるかどうかでスパムボットか否かを判定します。

BBCode: ON
[img]: ON
[flash]: OFF
[url]: ON
スマイリー: OFF

トピックのレビュー
   

展開ビュー トピックのレビュー: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

Re: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#11

by 若葉マークぺらひこ » 7年前

確かにx++が抜けていました・・・
ご指摘ありがとうございます。

今回は自分の力量・知識不足が原因だったようです、出直します。
皆様、お付き合いありがとうございました。

Re: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#10

by Dixq (管理人) » 7年前

内容が一見同じことをしているように見える関数がたくさんあるのはなぜなのでしょう?
すごくコードが読みにくいので、共通化できるところを共通化してコードを短くしてみましょう。

また、質問するときには、不具合がなさそうなコードは消して必要最小限にして質問すると回答者が読みやすいかと思います。

一般的に
●●A、●●Bとか、●●1、●●2とかという名前の付け方はNGです。
他人がコードを読んでも意味が分からないので・・。

Re: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#9

by Math » 7年前

相変わらずワーニングが出ているけど 例えば263行は x++;が抜けてると思うけどね。
g1.cpp(263): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(280): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(297): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(314): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(331): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(348): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(351): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(355): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(359): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(363): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(367): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
g1.cpp(371): warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?

Re: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#8

by 若葉マークぺらひこ » 7年前

少々コメントを増やし、おかしかった部分を修正してみました。
私が教えて頂きたいのは大きく分けて3つです。
①穴に落ちる処理
②壁に当たる処理
③オブジェクトに向かって移動する処理

①については座標を指定する?方法が分かりません。現在のものは本当に適当に書いたものなので、何の意図もありません。
②については、壁に当たると歩きを止めるまではできたのですが、その後別の方向に歩くこともできなくなってしまいました。
③については、①の理由に加えて「壁は進めるけど、穴は超えられない」という仕様にするにはどうすればいいのかが分かっていません。
沢山質問して申し訳ないのですが、ひたすら調べてトライ&エラーを繰り返しても本当に分かりませんでした。
どうか教えて下さい。

コード:

#include "DxLib.h"


int Key[256]; // キーが押されているフレーム数を格納する
			  // キーの入力状態を更新する
int gpUpdateKey() {
	char tmpKey[256]; // 現在のキーの入力状態を格納する
	GetHitKeyStateAll(tmpKey); // 全てのキーの入力状態を得る
	for (int i = 0; i<256; i++) {
		if (tmpKey[i] != 0) { // i番のキーコードに対応するキーが押されていたら
			Key[i]++;     // 加算
		}
		else {             // 押されていなければ
			Key[i] = 0;    // 0にする
		}
	}
	return 0;
}

int hantei_A[15][20] = {
	{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,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 },
};

int hantei_B[15][20] = {
	{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,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 },
};

int hantei_C[15][20] = {
	{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,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 },
};

int x = 320, y = 160;
int v = 160, z = 160;
int Handle1;
int Handle2;
int walking_flag1 = 0;
int walking_flag2 = 0;
int direction_1a = 3;
int direction_1b = 3;
int direction_2a = 3;
int direction_2b = 3;
int direction_3a = 3;
int direction_3b = 3;
int Image_a[16];//16個の画像を格納する配列
int Image_b[16];//16個の画像を格納する配列
int Green = GetColor(0, 255, 0);//座標表示用


int function_status = 0, White;

typedef struct {
	int x, y;       // 座標格納用変数
	char name[128]; // 項目名格納用変数
} MenuElement_t;
MenuElement_t MenuElement[5] = {
	{ 80, 100, "ステージ1 スタート" }, // タグの中身の順番で格納される。xに80が、yに100が、nameに"ゲームスタート"が
	{ 100, 150, "ステージ2 スタート" },
	{ 100, 200, "ステージ3 スタート" },
	{ 100, 250, "操作方法" },
	{ 100, 300, "ゲーム終了" },
};
int SelectNum = 0; // 現在の選択番号


void Opening() {
	DrawString(100, 100, "オープニング画面 (zをプッシュ)", White);
	if (Key[KEY_INPUT_Z] == 1)
		function_status = 1;
}

void Menu() {
	DrawString(100, 140, "メニュー画面 (Qをプッシュ)", White);
	// 計算フェーズ 
	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++) {              // メニュー項目数である5個ループ処理
			if (i == SelectNum) {          // 今処理しているのが、選択番号と同じ要素なら
				MenuElement[i].x = 80; // 座標を80にする
			}
			else {                       // 今処理しているのが、選択番号以外なら
				MenuElement[i].x = 100;// 座標を100にする
			}
		}
	}
	if (SelectNum == 0 && Key[KEY_INPUT_Q] == 1) {
		function_status = 2;
	}
	if (SelectNum == 1 && Key[KEY_INPUT_Q] == 1) {
		function_status = 3;
	}
	if (SelectNum == 2 && Key[KEY_INPUT_Q] == 1) {
		function_status = 4;
	}
	if (SelectNum == 3 && Key[KEY_INPUT_Q] == 1) {
		function_status = 5;
	}
}

void Danjon1() {
	DrawString(100, 180, "第一ステージ (Oをプッシュ)", White);
	if (Key[KEY_INPUT_O]) {
		function_status = 3;
	}
}
int IsAbleToGo1_A(int x, int y, int direction_a1) {//ステージ1自機A 進む方向が通れるか通れないかを判定
	if (direction_a1 == 0)//上向きなら
		if (hantei_A[y / 32 - 1][x / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_a1 == 1)//左向きなら
		if (hantei_A[y / 32][x / 32 - 1] == 1)
			return 1;
	if (direction_a1 == 2)//下向きなら
		if (hantei_A[y / 32 + 1][x / 32] == 1)
			return 1;
	if (direction_a1 == 3)//右向きなら
		if (hantei_A[y / 32][x / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
int IsAbleToGo1_B(int v, int z, int direction_a2) {//ステージ1自機B 進む方向が通れるか通れないかを判定
	if (direction_a2 == 0)//上向きなら
		if (hantei_A[z / 32 - 1][v / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_a2 == 1)//左向きなら
		if (hantei_A[z / 32][v / 32 - 1] == 1)
			return 1;
	if (direction_a2 == 2)//下向きなら
		if (hantei_A[z / 32 + 1][v / 32] == 1)
			return 1;
	if (direction_a2 == 3)//右向きなら
		if (hantei_A[z / 32][v / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
int IsAbleToGo2_A(int x, int y, int direction_b1) {//ステージ2自機A 進む方向が通れるか通れないかを判定
	if (direction_b1 == 0)//上向きなら
		if (hantei_B[y / 32 - 1][x / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_b1 == 1)//左向きなら
		if (hantei_B[y / 32][x / 32 - 1] == 1)
			return 1;
	if (direction_b1 == 2)//下向きなら
		if (hantei_B[y / 32 + 1][x / 32] == 1)
			return 1;
	if (direction_b1 == 3)//右向きなら
		if (hantei_B[y / 32][x / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
int IsAbleToGo2_B(int v, int z, int direction_b2) {//ステージ2自機B 進む方向が通れるか通れないかを判定
	if (direction_b2 == 0)//上向きなら
		if (hantei_B[z / 32 - 1][v / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_b2 == 1)//左向きなら
		if (hantei_B[z / 32][v / 32 - 1] == 1)
			return 1;
	if (direction_b2 == 2)//下向きなら
		if (hantei_B[z / 32 + 1][v / 32] == 1)
			return 1;
	if (direction_b2 == 3)//右向きなら
		if (hantei_B[z / 32][v / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
int IsAbleToGo3_A(int x, int y, int direction_c1) {//ステージ3自機A 進む方向が通れるか通れないかを判定
	if (direction_c1 == 0)//上向きなら
		if (hantei_C[y / 32 - 1][x / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_c1 == 1)//左向きなら
		if (hantei_C[y / 32][x / 32 - 1] == 1)
			return 1;
	if (direction_c1 == 2)//下向きなら
		if (hantei_C[y / 32 + 1][x / 32] == 1)
			return 1;
	if (direction_c1 == 3)//右向きなら
		if (hantei_C[y / 32][x / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
int IsAbleToGo3_B(int v, int z, int direction_c2) {//ステージ3自機B 進む方向が通れるか通れないかを判定
	if (direction_c2 == 0)//上向きなら
		if (hantei_C[z / 32 - 1][v / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_c2 == 1)//左向きなら
		if (hantei_C[z / 32][v / 32 - 1] == 1)
			return 1;
	if (direction_c2 == 2)//下向きなら
		if (hantei_C[z / 32 + 1][v / 32] == 1)
			return 1;
	if (direction_c2 == 3)//右向きなら
		if (hantei_C[z / 32][v / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
void magnet_a1(int x, int y, int direction_a1) {//ステージ1自機A 吸い寄せの処理
	if (direction_a1 == 0)//上向きなら
		if (hantei_A[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_A[x][y >= 5] == 2 && Key[KEY_INPUT_I] >= 1)//ステージ上の特定の座標に近く、その方向を向いていてIキーが押されているなら
				y--;//一定の速度でオブジェクトに向かって移動する
	if (direction_a1 == 1)//左向きなら
		if (hantei_A[y / 32][x / 32 - 1] != 1)
			if (hantei_A[x >= 5][y] == 2 && Key[KEY_INPUT_I] >= 1)
				x--;
	if (direction_a1 == 2)//下向きなら
		if (hantei_A[y / 32 + 1][x / 32] != 1)
			if (hantei_A[x][y <= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y++;
	if (direction_a1 == 3)//右向きなら
		if (hantei_A[y / 32][x / 32 + 1] != 1)
			if (hantei_A[x <= 5][y] == 2 && Key[KEY_INPUT_I] >= 1);
}
void magnet_a2(int x, int y, int direction_a2) {//ステージ1自機B 吸い寄せの処理
	if (direction_a2 == 0)//上向きなら
		if (hantei_A[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_A[x][y >= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y--;
	if (direction_a2 == 1)//左向きなら
		if (hantei_A[y / 32][x / 32 - 1] != 1)
			if (hantei_A[x >= 5][y] == 2 && Key[KEY_INPUT_U] >= 1)
				x--;
	if (direction_a2 == 2)//下向きなら
		if (hantei_A[y / 32 + 1][x / 32] != 1)
			if (hantei_A[x][y <= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y++;
	if (direction_a2 == 3)//右向きなら
		if (hantei_A[y / 32][x / 32 + 1] != 1)
			if (hantei_A[x <= 5][y] == 2 && Key[KEY_INPUT_U] >= 1);
}
void magnet_b1(int x, int y, int direction_b1) {//ステージ2自機A 吸い寄せの処理
	if (direction_b1 == 0)//上向きなら
		if (hantei_B[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_B[x][y >= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y--;
	if (direction_b1 == 1)//左向きなら
		if (hantei_B[y / 32][x / 32 - 1] != 1)
			if (hantei_B[x >= 5][y] == 2 && Key[KEY_INPUT_I] >= 1)
				x--;
	if (direction_b1 == 2)//下向きなら
		if (hantei_B[y / 32 + 1][x / 32] != 1)
			if (hantei_B[x][y <= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y++;
	if (direction_b1 == 3)//右向きなら
		if (hantei_B[y / 32][x / 32 + 1] != 1)
			if (hantei_B[x <= 5][y] == 2 && Key[KEY_INPUT_I] >= 1);
}
void magnet_b2(int x, int y, int direction_b2) {//ステージ2自機B 吸い寄せの処理
	if (direction_b2 == 0)//上向きなら
		if (hantei_B[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_B[x][y >= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y--;
	if (direction_b2 == 1)//左向きなら
		if (hantei_B[y / 32][x / 32 - 1] != 1)
			if (hantei_B[x >= 5][y] == 2 && Key[KEY_INPUT_U] >= 1)
				x--;
	if (direction_b2 == 2)//下向きなら
		if (hantei_B[y / 32 + 1][x / 32] != 1)
			if (hantei_B[x][y <= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y++;
	if (direction_b2 == 3)//右向きなら
		if (hantei_B[y / 32][x / 32 + 1] != 1)
			if (hantei_B[x <= 5][y] == 2 && Key[KEY_INPUT_U] >= 1);
}
void magnet_c1(int x, int y, int direction_c1) {//ステージ3自機A 吸い寄せの処理
	if (direction_c1 == 0)//上向きなら
		if (hantei_C[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_C[x][y >= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y--;
	if (direction_c1 == 1)//左向きなら
		if (hantei_C[y / 32][x / 32 - 1] != 1)
			if (hantei_C[x >= 5][y] == 2 && Key[KEY_INPUT_I] >= 1)
				x--;
	if (direction_c1 == 2)//下向きなら
		if (hantei_C[y / 32 + 1][x / 32] != 1)
			if (hantei_C[x][y <= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y++;
	if (direction_c1 == 3)//右向きなら
		if (hantei_C[y / 32][x / 32 + 1] != 1)
			if (hantei_C[x <= 5][y] == 2 && Key[KEY_INPUT_I] >= 1);
}
void magnet_c2(int x, int y, int direction_c2) {//ステージ3自機B 吸い寄せの処理
	if (direction_c2 == 0)//上向きなら
		if (hantei_C[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_C[x][y >= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y--;
	if (direction_c2 == 1)//左向きなら
		if (hantei_C[y / 32][x / 32 - 1] != 1)
			if (hantei_C[x >= 5][y] == 2 && Key[KEY_INPUT_U] >= 1)
				x--;
	if (direction_c2 == 2)//下向きなら
		if (hantei_C[y / 32 + 1][x / 32] != 1)
			if (hantei_C[x][y <= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y++;
	if (direction_c2 == 3)//右向きなら
		if (hantei_C[y / 32][x / 32 + 1] != 1)
			if (hantei_C[x <= 5][y] == 2 && Key[KEY_INPUT_U] >= 1);
}
void hole_a1(){
	if (hantei_A[x][y] == 3);//穴の座標に来たら
		function_status = 6;//ゲームオーバー画面に移行する
}
void hole_a2() {
	if (hantei_A[v][z] == 3);
	function_status = 6;
}
void hole_b1() {
	if (hantei_B[x][y] == 3);
	function_status = 6;
}
void hole_b2() {
	if (hantei_B[v][z] == 3);
	function_status = 6;
}
void hole_c1() {
	if (hantei_C[x][y] == 3);
	function_status = 6;
}
void hole_c2() {
	if (hantei_C[v][z] == 3);
	function_status = 6;
}
void gpCalc1_A() {
	if (x % 32 == 0 && y % 32 == 0) {
		walking_flag1 = 1;
		if (Key[KEY_INPUT_UP] >= 1) {         //上ボタンが押されたら
			direction_1a = 0;
		}
		else if (Key[KEY_INPUT_LEFT] >= 1) {  //左ボタンが押されたら
			direction_1a = 1;
		}
		else if (Key[KEY_INPUT_DOWN] >= 1) {   //下ボタンが押されたら
			direction_1a = 2;
		}
		else if (Key[KEY_INPUT_RIGHT] >= 1) {  //右ボタン
			direction_1a = 3;
		}
		else {
			walking_flag1 = 0;
		}
	}
	if (walking_flag1 == 1) {
		if (direction_1a == 0) {
			y--;
		}
		else if (direction_1a == 1) {
			x--;
		}
		else if (direction_1a == 2) {
			y++;
		}
		else if (direction_1a == 3) {
			x++;
		}
		if (walking_flag1 == 1) {    //もし歩くなら
			if (IsAbleToGo1_A(x, y, direction_1a) == 1)//行き先が歩けないなら
				walking_flag1 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag1 == 0) {
			if (IsAbleToGo1_A(x, y, direction_1a) == 0)//行き先が歩けるなら
				walking_flag1 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpCalc1_B() {
	if (v % 32 == 0 && z % 32 == 0) {
		walking_flag2 = 1;
		if (Key[KEY_INPUT_W] >= 1) {         //Wボタンが押されたら
			direction_1b = 0;
		}
		else if (Key[KEY_INPUT_A] >= 1) {  //Aボタンが押されたら
			direction_1b = 1;
		}
		else if (Key[KEY_INPUT_Z] >= 1) {   //Sボタンが押されたら
			direction_1b = 2;
		}
		else if (Key[KEY_INPUT_S] >= 1) {  //Zボタン
			direction_1b = 3;
		}
		else {
			walking_flag2 = 0;
		}
	}
	if (walking_flag2 == 1) {
		if (direction_1b == 0) {
			z--;
		}
		else if (direction_1b == 1) {
			v--;
		}
		else if (direction_1b == 2) {
			z++;
		}
		else if (direction_1b == 3) {
			v++;
		}
		if (walking_flag2 == 1) {    //もし歩くなら
			if (IsAbleToGo1_B(v, z, direction_1b) == 1)//行き先が歩けないなら
				walking_flag2 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag2 == 0) {
			if (IsAbleToGo1_B(v, z, direction_1b) == 0)//行き先が歩けるなら
				walking_flag2 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpCalc2_A() {
	if (x % 32 == 0 && y % 32 == 0) {
		walking_flag1 = 1;
		if (Key[KEY_INPUT_UP] >= 1) {         //上ボタンが押されたら
			direction_2a = 0;
		}
		else if (Key[KEY_INPUT_LEFT] >= 1) {  //左ボタンが押されたら
			direction_2a = 1;
		}
		else if (Key[KEY_INPUT_DOWN] >= 1) {   //下ボタンが押されたら
			direction_2a = 2;
		}
		else if (Key[KEY_INPUT_RIGHT] >= 1) {  //右ボタン
			direction_2a = 3;
		}
		else {
			walking_flag1 = 0;
		}
	}
	if (walking_flag1 == 1) {
		if (direction_2a == 0) {
			y--;
		}
		else if (direction_2a == 1) {
			x--;
		}
		else if (direction_2a == 2) {
			y++;
		}
		else if (direction_2a == 3) {
			x++;
		}
		if (walking_flag1 == 1) {    //もし歩くなら
			if (IsAbleToGo2_A(x, y, direction_2a) == 1)//行き先が歩けないなら
				walking_flag1 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag1 == 0) {
			if (IsAbleToGo2_A(x, y, direction_2a) == 0)//行き先が歩けるなら
				walking_flag1 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpCalc2_B() {
	if (v % 32 == 0 && z % 32 == 0) {
		walking_flag2 = 1;
		if (Key[KEY_INPUT_W] >= 1) {         //Wボタンが押されたら
			direction_2b = 0;
		}
		else if (Key[KEY_INPUT_A] >= 1) {  //Aボタンが押されたら
			direction_2b = 1;
		}
		else if (Key[KEY_INPUT_Z] >= 1) {   //Sボタンが押されたら
			direction_2b = 2;
		}
		else if (Key[KEY_INPUT_S] >= 1) {  //Zボタン
			direction_2b = 3;
		}
		else {
			walking_flag2 = 0;
		}
	}
	if (walking_flag2 == 1) {
		if (direction_2b == 0) {
			z--;
		}
		else if (direction_2b == 1) {
			v--;
		}
		else if (direction_2b == 2) {
			z++;
		}
		else if (direction_2b == 3) {
			v++;
		}
		if (walking_flag2 == 1) {    //もし歩くなら
			if (IsAbleToGo2_B(v, z, direction_2b) == 1)//行き先が歩けないなら
				walking_flag2 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag2 == 0) {
			if (IsAbleToGo2_B(v, z, direction_2b) == 0)//行き先が歩けるなら
				walking_flag2 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpCalc3_A() {
	if (x % 32 == 0 && y % 32 == 0) {
		walking_flag1 = 1;
		if (Key[KEY_INPUT_UP] >= 1) {         //上ボタンが押されたら
			direction_3a = 0;
		}
		else if (Key[KEY_INPUT_LEFT] >= 1) {  //左ボタンが押されたら
			direction_3a = 1;
		}
		else if (Key[KEY_INPUT_DOWN] >= 1) {   //下ボタンが押されたら
			direction_3a = 2;
		}
		else if (Key[KEY_INPUT_RIGHT] >= 1) {  //右ボタン
			direction_3a = 3;
		}
		else {
			walking_flag1 = 0;
		}
	}
	if (walking_flag1 == 1) {
		if (direction_3a == 0) {
			y--;
		}
		else if (direction_3a == 1) {
			x--;
		}
		else if (direction_3a == 2) {
			y++;
		}
		else if (direction_3a == 3) {
			x++;
		}
		if (walking_flag1 == 1) {    //もし歩くなら
			if (IsAbleToGo3_A(x, y, direction_2a) == 1)//行き先が歩けないなら
				walking_flag1 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag1 == 0) {
			if (IsAbleToGo3_A(x, y, direction_2a) == 0)//行き先が歩けるなら
				walking_flag1 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpCalc3_B() {
	if (v % 32 == 0 && z % 32 == 0) {
		walking_flag2 = 1;
		if (Key[KEY_INPUT_W] >= 1) {         //Wボタンが押されたら
			direction_3b = 0;
		}
		else if (Key[KEY_INPUT_A] >= 1) {  //Aボタンが押されたら
			direction_3b = 1;
		}
		else if (Key[KEY_INPUT_Z] >= 1) {   //Sボタンが押されたら
			direction_3b = 2;
		}
		else if (Key[KEY_INPUT_S] >= 1) {  //Zボタン
			direction_3b = 3;
		}
		else {
			walking_flag2 = 0;
		}
	}
	if (walking_flag2 == 1) {
		if (direction_3b == 0) {
			z--;
		}
		else if (direction_3b == 1) {
			v--;
		}
		else if (direction_3b == 2) {
			z++;
		}
		else if (direction_3b == 3) {
			v++;
		}
		if (walking_flag2 == 1) {    //もし歩くなら
			if (IsAbleToGo3_B(v, z, direction_2b) == 1)//行き先が歩けないなら
				walking_flag2 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag2 == 0) {
			if (IsAbleToGo3_B(v, z, direction_2b) == 0)//行き先が歩けるなら
				walking_flag2 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpDraw1() {
	DrawRotaGraph(x, y, 1.0, 0.0, Handle1, TRUE);
}
void gpDraw2() {
	DrawRotaGraph(v, z, 1.0, 0.0, Handle2, TRUE);
}

void Danjon2() {
	DrawString(100, 220, "第二ステージ (vをプッシュ)", White);
	
	if (Key[KEY_INPUT_V] == 1)
		function_status = 4;
}

void Danjon3() {
	DrawString(100, 220, "第三ステージ (Pをプッシュ)", White);

	if (Key[KEY_INPUT_P] == 1)
		function_status = 7;
}

void Guide() {
	DrawString(100, 260, "操作方法 (Dをプッシュ)", White);
	if (Key[KEY_INPUT_D] == 1)
		function_status = 1;
}

void Gameover() {
	DrawString(100, 260, "ゲームオーバー画面 (cをプッシュ)", White);
	if (Key[KEY_INPUT_C] == 1)
		function_status = 1;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	ChangeWindowMode(TRUE);                                   //ウィンドウモードに変更
	if (DxLib_Init() == -1) return -1;                      // DXライブラリ初期化処理 エラーが起きたら終了 

	White = GetColor(255, 255, 255);                    //色の取得

	SetDrawScreen(DX_SCREEN_BACK);                                // 描画先を裏画面に設定
	LoadDivGraph("画像/キャラクタ10.png", 16, 4, 4, 32, 32, Image_a);//画像を16個に分割してImage_a配列に保存
	LoadDivGraph("画像/キャラクタ10.png", 16, 4, 4, 32, 32, Image_b);//画像を16個に分割してImage_b配列に保存
	while (1) {
		ClearDrawScreen();                                                               // 裏画面のデータを全て削除
		gpUpdateKey();                                 // すべてのキーの状態を得る

		switch (function_status) {
		case 0:
			Opening();
			break;
		case 1:
			// メニュー項目の表示に必要な構造体を用意する
			Menu();
			for (int i = 0; i<5; i++) { // メニュー項目を描画
				DrawFormatString(MenuElement[i].x, MenuElement[i].y, GetColor(255, 255, 255), MenuElement[i].name);
			}
			break;

		case 2:
			Danjon1();
			int IsAbleToGo1_A(int x, int y, int direction_1a);
			int IsAbleToGo1_B(int v, int z, int direction_1b);
			void magnet_a1(int x, int y, int direction_a1);
			void magnet_a2(int v, int z, int direction_a2);
			gpCalc1_A();
			gpDraw1();
			gpCalc1_B();
			gpDraw2();
			hole_a1();
			hole_a2();
			/*白い壁を描画*/
			for (int i = 0; i < 15; i++)
				for (int j = 0; j < 20; j++)
					if (hantei_A[i][j] == 1)
						DrawBox(j * 32, i * 32, (j + 1) * 32, (i + 1) * 32, GetColor(255, 255, 255), TRUE);
			//磁石ブロックを描画
			for (int i = 0; i < 15; i++)
				for (int j = 0; j < 20; j++)
					if(hantei_A[i][j] ==2)
						DrawBox(j * 32, i * 32, (j + 1) * 32, (i + 1) * 32, GetColor(0, 255, 255), TRUE);
			//磁石ブロックを描画
			for (int i = 0; i < 15; i++)
				for (int j = 0; j < 20; j++)
					if (hantei_A[i][j] == 3)
						DrawBox(j * 32, i * 32, (j + 1) * 32, (i + 1) * 32, GetColor(255, 0, 255), TRUE);

			
			DrawGraph(x, y, Image_a[(x % 32 + y % 32) / 8 + direction_1a * 4], TRUE);
			DrawGraph(v, z, Image_b[(v % 32 + z % 32) / 8 + direction_1b * 4], TRUE);
			//座標表示装置
			DrawFormatString(0, 0, Green, "座標[%d,%d]", x, y); // 文字を描画する
			DrawFormatString(0, 15, Green, "座標[%d,%d]", v, z); // 文字を描画する
			break;
		case 3:
			Danjon2();
			int IsAbleToGo2_A(int x, int y, int direction_2a);
			int IsAbleToGo2_B(int v, int z, int direction_2b);
			gpCalc2_A();
			gpDraw1();
			gpCalc2_B();
			gpDraw2();
			/*白い壁を描画*/
			for (int i = 0; i < 15; i++)
				for (int j = 0; j < 20; j++)
					if (hantei_B[i][j] == 1)
						DrawBox(j * 32, i * 32, (j + 1) * 32, (i + 1) * 32, GetColor(255, 255, 255), TRUE);
			DrawGraph(x, y, Image_a[(x % 32 + y % 32) / 8 + direction_2a * 4], TRUE);
			DrawGraph(v, z, Image_b[(v % 32 + z % 32) / 8 + direction_2b * 4], TRUE);
			//座標表示装置
			DrawFormatString(0, 0, Green, "座標[%d,%d]", x, y); // 文字を描画する
			DrawFormatString(0, 15, Green, "座標[%d,%d]", v, z); // 文字を描画する
			break;

		case 4:
			Danjon3();
			int IsAbleToGo3_A(int x, int y, int direction_3a);
			int IsAbleToGo3_B(int v, int z, int direction_3b);
			gpCalc3_A();
			gpDraw1();
			gpCalc3_B();
			gpDraw2();
			/*白い壁を描画*/
			for (int i = 0; i < 15; i++)
				for (int j = 0; j < 20; j++)
					if (hantei_C[i][j] == 1)
						DrawBox(j * 32, i * 32, (j + 1) * 32, (i + 1) * 32, GetColor(255, 255, 255), TRUE);
			DrawGraph(x, y, Image_a[(x % 32 + y % 32) / 8 + direction_3a * 4], TRUE);
			DrawGraph(v, z, Image_b[(v % 32 + z % 32) / 8 + direction_3b * 4], TRUE);
			//座標表示装置
			DrawFormatString(0, 0, Green, "座標[%d,%d]", x, y); // 文字を描画する
			DrawFormatString(0, 15, Green, "座標[%d,%d]", v, z); // 文字を描画する
			break;
		case 5:
			Guide();
			break;
		case 6:
			Gameover();
			break;
		default:
			DxLib_End();                                // DXライブラリ使用の終了処理
			return 0;
			break;
		}

		if (ProcessMessage() == -1) break;                 //エラーが起きたら終了

		ScreenFlip();                                   // 裏画面データを表画面へ反映
	}

	DxLib_End();                                            // DXライブラリ使用の終了処理
	return 0;                                               // ソフトの終了
}

Re: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#7

by 若葉マークぺらひこ » 7年前

なるほど…
自分は今、やってはならない方法で画像を表示しているのですね。
やり方を何とか変えてみます。

ソースコードが分かりづらいというのは自分の力量不足です。
何とか分かりやすくして出直します。
皆様、ありがとうございます!

Re: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#6

by みけCAT » 7年前

若葉マークぺらひこ さんが書きました:どう変えれば良いでしょうか?
とりあえず、似た内容の関数が多すぎて長く読みにくいので、まとめてほしいです。
IsAbleToGo系の関数も、コメントは統一された「進む方向が通れるか通れないかを判定」「進めるか判定」なのに、
内部で引数の値を使うかグローバル変数を使うかの違いがあり、役割がわかりにくいです。
わかりやすいコメントもあるといいと思います。

Re: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#5

by みけCAT » 7年前

若葉マークぺらひこ さんが書きました:magnet関数が私が失敗したものです。どう変えれば良いでしょうか?
どう変えれば良いかはまだよくわからないですが、magnet_なんとか関数内の3段目のif文のhantei_[ABC]の添字には必ず比較演算子が用いられており、
真偽値は整数に変換すると0か1になるはずですが、hantei_[ABC]の0行目、0列目、1行目、1列目のどこにも値が2である要素は無いので、
このmagnet_なんとか関数ではxやyのインクリメントやデクリメントはされません。
何を意図して添字に比較演算子を使っているのでしょうか?

Re: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#4

by Math » 7年前

エラーも出ず、コンパイル・実行もできますが 下記ワーニングがでます。
こころ当たりがありませんか。
262行: warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
279行: warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
296行: warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
313行: warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
330行: warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?
347行: warning C4390: ';': 制御が空の文が見つかりました。意図した記述でしょうか?

Re: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#3

by みけCAT » 7年前

若葉マークぺらひこ さんが書きました: 旧の方を参考に、一定だけ移動するマス目移動を実装したのですが、一定の時間が経過するとキャラクターの画像が消えてしまいます。
キャラクターの画像もサイトを参考に分割保存しているのですが、これは何が原因なのでしょう?
画像を毎フレーム読み込んで開放していないので、内部の上限に引っかかってしまって読み込みに失敗するのでしょう。
画像は最初に1回だけ読み込んでそれをずっと使うようにする(シーンごとに必要な分だけロードとか複雑なことをしなくていいくらい十分画像が少なそうなので推奨)か、
宗教上の理由などでどうしても画像を毎フレーム読み込みたければ、ちゃんと使い終わったら開放するようにしましょう。
オフトピック
書いてはいけない4つの処理に「LoadGraphScreen関数を使っている」はあるのに、
もっとひどい結果(リソースリーク)になる「画像をLoadGraphなどで毎フレーム読み込む」が無いのはなんでだろう?

Re: ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#2

by 若葉マークぺらひこ » 7年前

追記です。
この状態では、周りの壁にキャラクターが触れるとそれ以降動けなくなってしまいました。
この原因も教えて下さい。どうしても分かりません。

ゲーム制作 ①キャラクターが消える ②特定のオブジェクトに向かって移動

#1

by 若葉マークぺらひこ » 7年前

新・ゲームプログラミングの館を参考に(というより完全にそのまんまで)ゲームを作っています。
旧の方を参考に、一定だけ移動するマス目移動を実装したのですが、一定の時間が経過するとキャラクターの画像が消えてしまいます。
キャラクターの画像もサイトを参考に分割保存しているのですが、これは何が原因なのでしょう?

また、「特定のキーを押すと、画面上の特定の座標に向かって一定の速度で移動する」ことを実装したいのですが、上手く動きません。方法を教えて下さい。
magnet関数が私が失敗したものです。どう変えれば良いでしょうか?

コード:

#include "DxLib.h"


int Key[256]; // キーが押されているフレーム数を格納する
			  // キーの入力状態を更新する
int gpUpdateKey() {
	char tmpKey[256]; // 現在のキーの入力状態を格納する
	GetHitKeyStateAll(tmpKey); // 全てのキーの入力状態を得る
	for (int i = 0; i<256; i++) {
		if (tmpKey[i] != 0) { // i番のキーコードに対応するキーが押されていたら
			Key[i]++;     // 加算
		}
		else {             // 押されていなければ
			Key[i] = 0;    // 0にする
		}
	}
	return 0;
}

int hantei_A[15][20] = {
	{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,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 },
};

int hantei_B[15][20] = {
	{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,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 },
};

int hantei_C[15][20] = {
	{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 },
	{ 1,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 },
};

int x = 320, y = 160;
int v = 160, z = 160;
int Handle1;
int Handle2;
int walking_flag1 = 0;
int walking_flag2 = 0;
int direction_1a = 3;
int direction_1b = 3;
int direction_2a = 3;
int direction_2b = 3;
int direction_3a = 3;
int direction_3b = 3;
int Image_a[16];//16個の画像を格納する配列
int Image_b[16];//16個の画像を格納する配列
int Green = GetColor(0, 255, 0);//座標表示用

int function_status = 0, White;

typedef struct {
	int x, y;       // 座標格納用変数
	char name[128]; // 項目名格納用変数
} MenuElement_t;
MenuElement_t MenuElement[5] = {
	{ 80, 100, "ステージ1 スタート" }, // タグの中身の順番で格納される。xに80が、yに100が、nameに"ゲームスタート"が
	{ 100, 150, "ステージ2 スタート" },
	{ 100, 200, "ステージ3 スタート" },
	{ 100, 250, "操作方法" },
	{ 100, 300, "ゲーム終了" },
};
int SelectNum = 0; // 現在の選択番号


void Opening() {
	DrawString(100, 100, "オープニング画面 (zをプッシュ)", White);
	if (Key[KEY_INPUT_Z] == 1)
		function_status = 1;
}

void Menu() {
	DrawString(100, 140, "メニュー画面 (Qをプッシュ)", White);
	// 計算フェーズ 
	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++) {              // メニュー項目数である5個ループ処理
			if (i == SelectNum) {          // 今処理しているのが、選択番号と同じ要素なら
				MenuElement[i].x = 80; // 座標を80にする
			}
			else {                       // 今処理しているのが、選択番号以外なら
				MenuElement[i].x = 100;// 座標を100にする
			}
		}
	}
	if (SelectNum == 0 && Key[KEY_INPUT_Q] == 1) {
		function_status = 2;
	}
	if (SelectNum == 1 && Key[KEY_INPUT_Q] == 1) {
		function_status = 3;
	}
	if (SelectNum == 2 && Key[KEY_INPUT_Q] == 1) {
		function_status = 4;
	}
	if (SelectNum == 3 && Key[KEY_INPUT_Q] == 1) {
		function_status = 5;
	}
}

void Danjon1() {
	DrawString(100, 180, "第一ステージ (Oをプッシュ)", White);
	if (Key[KEY_INPUT_O]) {
		function_status = 3;
	}
}
int IsAbleToGo1_A(int x, int y, int direction_a1) {//進む方向が通れるか通れないかを判定
	if (direction_a1 == 0)//上向きなら
		if (hantei_A[y / 32 - 1][x / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_a1 == 1)//左向きなら
		if (hantei_A[y / 32][x / 32 - 1] == 1)
			return 1;
	if (direction_a1 == 2)//下向きなら
		if (hantei_A[y / 32 + 1][x / 32] == 1)
			return 1;
	if (direction_a1 == 3)//右向きなら
		if (hantei_A[y / 32][x / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
int IsAbleToGo1_B(int v, int z, int direction_a2) {//進む方向が通れるか通れないかを判定
	if (direction_a2 == 0)//上向きなら
		if (hantei_A[y / 32 - 1][x / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_a2 == 1)//左向きなら
		if (hantei_A[y / 32][x / 32 - 1] == 1)
			return 1;
	if (direction_a2 == 2)//下向きなら
		if (hantei_A[y / 32 + 1][x / 32] == 1)
			return 1;
	if (direction_a2 == 3)//右向きなら
		if (hantei_A[y / 32][x / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
int IsAbleToGo2_A(int x, int y, int direction_b1) {//進む方向が通れるか通れないかを判定
	if (direction_b1 == 0)//上向きなら
		if (hantei_B[z / 32 - 1][v / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_b1 == 1)//左向きなら
		if (hantei_B[z / 32][v / 32 - 1] == 1)
			return 1;
	if (direction_b1 == 2)//下向きなら
		if (hantei_B[z / 32 + 1][v / 32] == 1)
			return 1;
	if (direction_b1 == 3)//右向きなら
		if (hantei_B[z / 32][v / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
int IsAbleToGo2_B(int v, int z, int direction_b2) {//進む方向が通れるか通れないかを判定
	if (direction_b2 == 0)//上向きなら
		if (hantei_B[z / 32 - 1][v / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_b2 == 1)//左向きなら
		if (hantei_B[z / 32][v / 32 - 1] == 1)
			return 1;
	if (direction_b2 == 2)//下向きなら
		if (hantei_B[z / 32 + 1][v / 32] == 1)
			return 1;
	if (direction_b2 == 3)//右向きなら
		if (hantei_B[z / 32][v / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
int IsAbleToGo3_A(int x, int y, int direction_c1) {//進む方向が通れるか通れないかを判定
	if (direction_c1 == 0)//上向きなら
		if (hantei_C[z / 32 - 1][v / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_c1 == 1)//左向きなら
		if (hantei_C[z / 32][v / 32 - 1] == 1)
			return 1;
	if (direction_c1 == 2)//下向きなら
		if (hantei_C[z / 32 + 1][v / 32] == 1)
			return 1;
	if (direction_c1 == 3)//右向きなら
		if (hantei_C[z / 32][v / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
int IsAbleToGo3_B(int v, int z, int direction_c2) {//進む方向が通れるか通れないかを判定
	if (direction_c2 == 0)//上向きなら
		if (hantei_C[z / 32 - 1][v / 32] == 1)//進めるか判定
			return 1;//エラー
	if (direction_c2 == 1)//左向きなら
		if (hantei_C[z / 32][v / 32 - 1] == 1)
			return 1;
	if (direction_c2 == 2)//下向きなら
		if (hantei_C[z / 32 + 1][v / 32] == 1)
			return 1;
	if (direction_c2 == 3)//右向きなら
		if (hantei_C[z / 32][v / 32 + 1] == 1)
			return 1;

	return 0;//正常
}
void magnet_a1(int x, int y, int direction_a1) {
	if (direction_a1 == 0)//上向きなら
		if (hantei_A[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_A[x][y >= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y--;
	if (direction_a1 == 1)//左向きなら
		if (hantei_A[y / 32][x / 32 - 1] != 1)
			if (hantei_A[x >= 5][y] == 2 && Key[KEY_INPUT_I] >= 1)
				x--;
	if (direction_a1 == 2)//下向きなら
		if (hantei_A[y / 32 + 1][x / 32] != 1)
			if (hantei_A[x][y <= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y++;
	if (direction_a1 == 3)//右向きなら
		if (hantei_A[y / 32][x / 32 + 1] != 1)
			if (hantei_A[x <= 5][y] == 2 && Key[KEY_INPUT_I] >= 1);
}
void magnet_a2(int x, int y, int direction_a2) {
	if (direction_a2 == 0)//上向きなら
		if (hantei_A[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_A[x][y >= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y--;
	if (direction_a2 == 1)//左向きなら
		if (hantei_A[y / 32][x / 32 - 1] != 1)
			if (hantei_A[x >= 5][y] == 2 && Key[KEY_INPUT_U] >= 1)
				x--;
	if (direction_a2 == 2)//下向きなら
		if (hantei_A[y / 32 + 1][x / 32] != 1)
			if (hantei_A[x][y <= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y++;
	if (direction_a2 == 3)//右向きなら
		if (hantei_A[y / 32][x / 32 + 1] != 1)
			if (hantei_A[x <= 5][y] == 2 && Key[KEY_INPUT_U] >= 1);
}
void magnet_b1(int x, int y, int direction_b1) {
	if (direction_b1 == 0)//上向きなら
		if (hantei_B[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_B[x][y >= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y--;
	if (direction_b1 == 1)//左向きなら
		if (hantei_B[y / 32][x / 32 - 1] != 1)
			if (hantei_B[x >= 5][y] == 2 && Key[KEY_INPUT_I] >= 1)
				x--;
	if (direction_b1 == 2)//下向きなら
		if (hantei_B[y / 32 + 1][x / 32] != 1)
			if (hantei_B[x][y <= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y++;
	if (direction_b1 == 3)//右向きなら
		if (hantei_B[y / 32][x / 32 + 1] != 1)
			if (hantei_B[x <= 5][y] == 2 && Key[KEY_INPUT_I] >= 1);
}
void magnet_b2(int x, int y, int direction_b2) {
	if (direction_b2 == 0)//上向きなら
		if (hantei_B[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_B[x][y >= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y--;
	if (direction_b2 == 1)//左向きなら
		if (hantei_B[y / 32][x / 32 - 1] != 1)
			if (hantei_B[x >= 5][y] == 2 && Key[KEY_INPUT_U] >= 1)
				x--;
	if (direction_b2 == 2)//下向きなら
		if (hantei_B[y / 32 + 1][x / 32] != 1)
			if (hantei_B[x][y <= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y++;
	if (direction_b2 == 3)//右向きなら
		if (hantei_B[y / 32][x / 32 + 1] != 1)
			if (hantei_B[x <= 5][y] == 2 && Key[KEY_INPUT_U] >= 1);
}
void magnet_c1(int x, int y, int direction_c1) {
	if (direction_c1 == 0)//上向きなら
		if (hantei_C[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_C[x][y >= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y--;
	if (direction_c1 == 1)//左向きなら
		if (hantei_C[y / 32][x / 32 - 1] != 1)
			if (hantei_C[x >= 5][y] == 2 && Key[KEY_INPUT_I] >= 1)
				x--;
	if (direction_c1 == 2)//下向きなら
		if (hantei_C[y / 32 + 1][x / 32] != 1)
			if (hantei_C[x][y <= 5] == 2 && Key[KEY_INPUT_I] >= 1)
				y++;
	if (direction_c1 == 3)//右向きなら
		if (hantei_C[y / 32][x / 32 + 1] != 1)
			if (hantei_C[x <= 5][y] == 2 && Key[KEY_INPUT_I] >= 1);
}
void magnet_c2(int x, int y, int direction_c2) {
	if (direction_c2 == 0)//上向きなら
		if (hantei_C[y / 32 - 1][x / 32] != 1)//進めるか判定
			if (hantei_C[x][y >= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y--;
	if (direction_c2 == 1)//左向きなら
		if (hantei_C[y / 32][x / 32 - 1] != 1)
			if (hantei_C[x >= 5][y] == 2 && Key[KEY_INPUT_U] >= 1)
				x--;
	if (direction_c2 == 2)//下向きなら
		if (hantei_C[y / 32 + 1][x / 32] != 1)
			if (hantei_C[x][y <= 5] == 2 && Key[KEY_INPUT_U] >= 1)
				y++;
	if (direction_c2 == 3)//右向きなら
		if (hantei_C[y / 32][x / 32 + 1] != 1)
			if (hantei_C[x <= 5][y] == 2 && Key[KEY_INPUT_U] >= 1);
}
void gpCalc1_A() {
	if (x % 32 == 0 && y % 32 == 0) {
		walking_flag1 = 1;
		if (Key[KEY_INPUT_UP] >= 1) {         //上ボタンが押されたら
			direction_1a = 0;
		}
		else if (Key[KEY_INPUT_LEFT] >= 1) {  //左ボタンが押されたら
			direction_1a = 1;
		}
		else if (Key[KEY_INPUT_DOWN] >= 1) {   //下ボタンが押されたら
			direction_1a = 2;
		}
		else if (Key[KEY_INPUT_RIGHT] >= 1) {  //右ボタン
			direction_1a = 3;
		}
		else {
			walking_flag1 = 0;
		}
	}
	if (walking_flag1 == 1) {
		if (direction_1a == 0) {
			y--;
		}
		else if (direction_1a == 1) {
			x--;
		}
		else if (direction_1a == 2) {
			y++;
		}
		else if (direction_1a == 3) {
			x++;
		}
		if (walking_flag1 == 1) {    //もし歩くなら
			if (IsAbleToGo1_A(x, y, direction_1a) == 1)//行き先が歩けないなら
				walking_flag1 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag1 == 0) {
			if (IsAbleToGo1_A(x, y, direction_1a) == 0)//行き先が歩けるなら
				walking_flag1 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpCalc1_B() {
	if (v % 32 == 0 && z % 32 == 0) {
		walking_flag2 = 1;
		if (Key[KEY_INPUT_W] >= 1) {         //Wボタンが押されたら
			direction_1b = 0;
		}
		else if (Key[KEY_INPUT_A] >= 1) {  //Aボタンが押されたら
			direction_1b = 1;
		}
		else if (Key[KEY_INPUT_Z] >= 1) {   //Sボタンが押されたら
			direction_1b = 2;
		}
		else if (Key[KEY_INPUT_S] >= 1) {  //Zボタン
			direction_1b = 3;
		}
		else {
			walking_flag2 = 0;
		}
	}
	if (walking_flag2 == 1) {
		if (direction_1b == 0) {
			z--;
		}
		else if (direction_1b == 1) {
			v--;
		}
		else if (direction_1b == 2) {
			z++;
		}
		else if (direction_1b == 3) {
			v++;
		}
		if (walking_flag2 == 1) {    //もし歩くなら
			if (IsAbleToGo1_B(v, z, direction_1b) == 1)//行き先が歩けないなら
				walking_flag2 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag2 == 0) {
			if (IsAbleToGo1_B(v, z, direction_1b) == 0)//行き先が歩けるなら
				walking_flag2 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpCalc2_A() {
	if (x % 32 == 0 && y % 32 == 0) {
		walking_flag1 = 1;
		if (Key[KEY_INPUT_UP] >= 1) {         //上ボタンが押されたら
			direction_2a = 0;
		}
		else if (Key[KEY_INPUT_LEFT] >= 1) {  //左ボタンが押されたら
			direction_2a = 1;
		}
		else if (Key[KEY_INPUT_DOWN] >= 1) {   //下ボタンが押されたら
			direction_2a = 2;
		}
		else if (Key[KEY_INPUT_RIGHT] >= 1) {  //右ボタン
			direction_2a = 3;
		}
		else {
			walking_flag1 = 0;
		}
	}
	if (walking_flag1 == 1) {
		if (direction_2a == 0) {
			y--;
		}
		else if (direction_2a == 1) {
			x--;
		}
		else if (direction_2a == 2) {
			y++;
		}
		else if (direction_2a == 3) {
			x++;
		}
		if (walking_flag1 == 1) {    //もし歩くなら
			if (IsAbleToGo2_A(x, y, direction_2a) == 1)//行き先が歩けないなら
				walking_flag1 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag1 == 0) {
			if (IsAbleToGo2_A(x, y, direction_2a) == 0)//行き先が歩けるなら
				walking_flag1 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpCalc2_B() {
	if (v % 32 == 0 && z % 32 == 0) {
		walking_flag2 = 1;
		if (Key[KEY_INPUT_W] >= 1) {         //Wボタンが押されたら
			direction_2b = 0;
		}
		else if (Key[KEY_INPUT_A] >= 1) {  //Aボタンが押されたら
			direction_2b = 1;
		}
		else if (Key[KEY_INPUT_Z] >= 1) {   //Sボタンが押されたら
			direction_2b = 2;
		}
		else if (Key[KEY_INPUT_S] >= 1) {  //Zボタン
			direction_2b = 3;
		}
		else {
			walking_flag2 = 0;
		}
	}
	if (walking_flag2 == 1) {
		if (direction_2b == 0) {
			z--;
		}
		else if (direction_2b == 1) {
			v--;
		}
		else if (direction_2b == 2) {
			z++;
		}
		else if (direction_2b == 3) {
			v++;
		}
		if (walking_flag2 == 1) {    //もし歩くなら
			if (IsAbleToGo2_B(v, z, direction_2b) == 1)//行き先が歩けないなら
				walking_flag2 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag2 == 0) {
			if (IsAbleToGo2_B(v, z, direction_2b) == 0)//行き先が歩けるなら
				walking_flag2 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpCalc3_A() {
	if (x % 32 == 0 && y % 32 == 0) {
		walking_flag1 = 1;
		if (Key[KEY_INPUT_UP] >= 1) {         //上ボタンが押されたら
			direction_3a = 0;
		}
		else if (Key[KEY_INPUT_LEFT] >= 1) {  //左ボタンが押されたら
			direction_3a = 1;
		}
		else if (Key[KEY_INPUT_DOWN] >= 1) {   //下ボタンが押されたら
			direction_3a = 2;
		}
		else if (Key[KEY_INPUT_RIGHT] >= 1) {  //右ボタン
			direction_3a = 3;
		}
		else {
			walking_flag1 = 0;
		}
	}
	if (walking_flag1 == 1) {
		if (direction_3a == 0) {
			y--;
		}
		else if (direction_3a == 1) {
			x--;
		}
		else if (direction_3a == 2) {
			y++;
		}
		else if (direction_3a == 3) {
			x++;
		}
		if (walking_flag1 == 1) {    //もし歩くなら
			if (IsAbleToGo3_A(x, y, direction_2a) == 1)//行き先が歩けないなら
				walking_flag1 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag1 == 0) {
			if (IsAbleToGo3_A(x, y, direction_2a) == 0)//行き先が歩けるなら
				walking_flag1 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpCalc3_B() {
	if (v % 32 == 0 && z % 32 == 0) {
		walking_flag2 = 1;
		if (Key[KEY_INPUT_W] >= 1) {         //Wボタンが押されたら
			direction_3b = 0;
		}
		else if (Key[KEY_INPUT_A] >= 1) {  //Aボタンが押されたら
			direction_3b = 1;
		}
		else if (Key[KEY_INPUT_Z] >= 1) {   //Sボタンが押されたら
			direction_3b = 2;
		}
		else if (Key[KEY_INPUT_S] >= 1) {  //Zボタン
			direction_3b = 3;
		}
		else {
			walking_flag2 = 0;
		}
	}
	if (walking_flag2 == 1) {
		if (direction_3b == 0) {
			z--;
		}
		else if (direction_3b == 1) {
			v--;
		}
		else if (direction_3b == 2) {
			z++;
		}
		else if (direction_3b == 3) {
			v++;
		}
		if (walking_flag2 == 1) {    //もし歩くなら
			if (IsAbleToGo3_B(v, z, direction_2b) == 1)//行き先が歩けないなら
				walking_flag2 = 0;    //歩かないフラグを立てる。
		}
		if (walking_flag2 == 0) {
			if (IsAbleToGo3_B(v, z, direction_2b) == 0)//行き先が歩けるなら
				walking_flag2 = 1;    //歩くフラグを立てる。
		}
	}
}
void gpDraw1() {
	DrawRotaGraph(x, y, 1.0, 0.0, Handle1, TRUE);
}
void gpDraw2() {
	DrawRotaGraph(v, z, 1.0, 0.0, Handle2, TRUE);
}

void Danjon2() {
	DrawString(100, 220, "第二ステージ (vをプッシュ)", White);
	
	if (Key[KEY_INPUT_V] == 1)
		function_status = 4;
}

void Danjon3() {
	DrawString(100, 220, "第三ステージ (Pをプッシュ)", White);

	if (Key[KEY_INPUT_P] == 1)
		function_status = 6;
}

void Guide() {
	DrawString(100, 260, "操作方法 (Dをプッシュ)", White);
	if (Key[KEY_INPUT_D] == 1)
		function_status = 1;
}

void Ending() {
	DrawString(100, 260, "エンディング画面 (bをプッシュ)", White);
	if (Key[KEY_INPUT_B] == 1)
		function_status = 7;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	ChangeWindowMode(TRUE);                                   //ウィンドウモードに変更
	if (DxLib_Init() == -1) return -1;                      // DXライブラリ初期化処理 エラーが起きたら終了 

	White = GetColor(255, 255, 255);                    //色の取得

	SetDrawScreen(DX_SCREEN_BACK);                                // 描画先を裏画面に設定

	while (1) {
		ClearDrawScreen();                                                               // 裏画面のデータを全て削除
		gpUpdateKey();                                 // すべてのキーの状態を得る

		switch (function_status) {
		case 0:
			Opening();
			break;
		case 1:
			// メニュー項目の表示に必要な構造体を用意する
			Menu();
			for (int i = 0; i<5; i++) { // メニュー項目を描画
				DrawFormatString(MenuElement[i].x, MenuElement[i].y, GetColor(255, 255, 255), MenuElement[i].name);
			}
			break;

		case 2:
			Danjon1();
			int IsAbleToGo1_A(int x, int y, int direction_1a);
			int IsAbleToGo1_B(int v, int z, int direction_1b);
			void magnet_a1(int x, int y, int direction_a1);
			void magnet_a2(int x, int y, int direction_a2);
			gpCalc1_A();
			gpDraw1();
			gpCalc1_B();
			gpDraw2();
			/*白い壁を描画*/
			for (int i = 0; i < 15; i++)
				for (int j = 0; j < 20; j++)
					if (hantei_A[i][j] == 1)
						DrawBox(j * 32, i * 32, (j + 1) * 32, (i + 1) * 32, GetColor(255, 255, 255), TRUE);
			//磁石ブロックを描画
			for (int i = 0; i < 15; i++)
				for (int j = 0; j < 20; j++)
					if(hantei_A[i][j] ==2)
						DrawBox(j * 32, i * 32, (j + 1) * 32, (i + 1) * 32, GetColor(0, 255, 255), TRUE);

			LoadDivGraph("画像/キャラクタ10.png", 16, 4, 4, 32, 32, Image_a);//画像を16個に分割してImage_a配列に保存
			LoadDivGraph("画像/キャラクタ10.png", 16, 4, 4, 32, 32, Image_b);//画像を16個に分割してImage_b配列に保存
			DrawGraph(x, y, Image_a[(x % 32 + y % 32) / 8 + direction_1a * 4], TRUE);
			DrawGraph(v, z, Image_b[(v % 32 + z % 32) / 8 + direction_1b * 4], TRUE);
			//座標表示装置
			DrawFormatString(0, 0, Green, "座標[%d,%d]", x, y); // 文字を描画する
			DrawFormatString(0, 15, Green, "座標[%d,%d]", v, z); // 文字を描画する
			break;
		case 3:
			Danjon2();
			int IsAbleToGo2_A(int x, int y, int direction_2a);
			int IsAbleToGo2_B(int v, int z, int direction_2b);
			gpCalc2_A();
			gpDraw1();
			gpCalc2_B();
			gpDraw2();
			/*白い壁を描画*/
			for (int i = 0; i < 15; i++)
				for (int j = 0; j < 20; j++)
					if (hantei_B[i][j] == 1)
						DrawBox(j * 32, i * 32, (j + 1) * 32, (i + 1) * 32, GetColor(255, 255, 255), TRUE);
			LoadDivGraph("画像/girl.jpg", 16, 4, 4, 28, 28, Image_a);//画像を16個に分割してImage_a配列に保存
			LoadDivGraph("画像/girl.jpg", 16, 4, 4, 28, 28, Image_b);//画像を16個に分割してImage_b配列に保存
			DrawGraph(x, y, Image_a[(x % 32 + y % 32) / 8 + direction_2a * 4], TRUE);
			DrawGraph(v, z, Image_b[(v % 32 + z % 32) / 8 + direction_2b * 4], TRUE);
			//座標表示装置
			DrawFormatString(0, 0, Green, "座標[%d,%d]", x, y); // 文字を描画する
			DrawFormatString(0, 15, Green, "座標[%d,%d]", v, z); // 文字を描画する
			break;

		case 4:
			Danjon3();
			int IsAbleToGo3_A(int x, int y, int direction_3a);
			int IsAbleToGo3_B(int v, int z, int direction_3b);
			gpCalc3_A();
			gpDraw1();
			gpCalc3_B();
			gpDraw2();
			/*白い壁を描画*/
			for (int i = 0; i < 15; i++)
				for (int j = 0; j < 20; j++)
					if (hantei_C[i][j] == 1)
						DrawBox(j * 32, i * 32, (j + 1) * 32, (i + 1) * 32, GetColor(255, 255, 255), TRUE);
			LoadDivGraph("画像/girl.jpg", 16, 4, 4, 32, 32, Image_a);//画像を16個に分割してImage_a配列に保存
			LoadDivGraph("画像/girl.jpg", 16, 4, 4, 32, 32, Image_b);//画像を16個に分割してImage_b配列に保存
			DrawGraph(x, y, Image_a[(x % 32 + y % 32) / 8 + direction_3a * 4], TRUE);
			DrawGraph(v, z, Image_b[(v % 32 + z % 32) / 8 + direction_3b * 4], TRUE);
			//座標表示装置
			DrawFormatString(0, 0, Green, "座標[%d,%d]", x, y); // 文字を描画する
			DrawFormatString(0, 15, Green, "座標[%d,%d]", v, z); // 文字を描画する
			break;
		case 5:
			Guide();
			break;
		case 6:
			Ending();
			break;
		default:
			DxLib_End();                                // DXライブラリ使用の終了処理
			return 0;
			break;
		}

		if (ProcessMessage() == -1) break;                 //エラーが起きたら終了

		ScreenFlip();                                   // 裏画面データを表画面へ反映
	}

	DxLib_End();                                            // DXライブラリ使用の終了処理
	return 0;                                               // ソフトの終了
}


ページトップ