teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

壁の描画を追加

2019/08/22 12:11

投稿

kazuma-s
kazuma-s

スコア8222

answer CHANGED
@@ -91,4 +91,17 @@
91
91
  DxLib_End(); // DXライブラリ使用の終了処理
92
92
  return 0; // ソフトの終了
93
93
  }
94
+ ```
95
+ プレイヤーを描画する前に壁を描画してもよいでしょう。
96
+ ```C++
97
+ for (int i = 0; i < 5; i++) {
98
+ for (int j = 0; j < 5; j++) {
99
+ if (idou[i][j] == 1) {
100
+ int x = j * 60 + 100, y = i * 80 + 100;
101
+ DrawGraph(x, y, gh[11], FALSE); // 壁を裏画面に描画
102
+ }
103
+ }
104
+ }
105
+ int x = nx * 60 + 100, y = ny * 80 + 100; // 表示位置に変換
106
+ DrawGraph(x, y, playerphoto, FALSE); // プレイヤーを裏画面に描画
94
107
  ```

1

バグ修正

2019/08/22 12:11

投稿

kazuma-s
kazuma-s

スコア8222

answer CHANGED
@@ -43,32 +43,36 @@
43
43
  while (ProcessMessage() == 0) {
44
44
  gpUpdateKey(); // キーの入力状態を取得
45
45
  if (Key[KEY_INPUT_RIGHT] == 1) { // カーソルキーの右が押されている
46
+ move = 1;
46
47
  if (idou[nx + 1][ny] == 0) { //移動先が空いていれば
47
- move = 1; nx = nx + 1; playerphoto = gh[7]; // 右向き
48
+ nx = nx + 1; playerphoto = gh[7]; // 右向き
48
49
  }
49
50
  else {
50
51
  playerphoto = gh[9]; // 移動不可能
51
52
  }
52
53
  }
53
54
  if (Key[KEY_INPUT_LEFT] == 1) {
55
+ move = 1;
54
56
  if (idou[nx - 1][ny] == 0) { //移動先が空いていれば
55
- move = 1; nx = nx - 1; playerphoto = gh[2]; // 左向き
57
+ nx = nx - 1; playerphoto = gh[2]; // 左向き
56
58
  }
57
59
  else {
58
60
  playerphoto = gh[9]; // 移動不可能
59
61
  }
60
62
  }
61
63
  if (Key[KEY_INPUT_UP] == 1) {
64
+ move = 1;
62
65
  if (idou[nx][ny - 1] == 0) { //移動先が空いていれば
63
- move = 1; ny = ny - 1; playerphoto = gh[4]; // 上向き
66
+ ny = ny - 1; playerphoto = gh[4]; // 上向き
64
67
  }
65
68
  else {
66
69
  playerphoto = gh[9]; // 移動不可能
67
70
  }
68
71
  }
69
72
  if (Key[KEY_INPUT_DOWN] == 1) {
73
+ move = 1;
70
74
  if (idou[nx][ny + 1] == 0) { //移動先が空いていれば
71
- move = 1; ny = ny + 1; playerphoto = gh[3]; // 下向き
75
+ ny = ny + 1; playerphoto = gh[3]; // 下向き
72
76
  }
73
77
  else {
74
78
  playerphoto = gh[9]; // 移動不可能