質問編集履歴
2
タグを編集
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
1
提示コードを修正して画像も追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
提示コードの////コメント部のコードです。真横に動いても自分の"後"を仲間が追尾する処理を実装したいのですがどうすればいいのでしょうか?アルゴリズムというか考え方が知りたいです。
|
2
2
|
|
3
|
+
提示画像の一番上のキャラクターが自分のキャラクターでそれを右に動かしてその後上に動かした時にちゃんと後ろを追いかけてくれる処理を作りたいです。
|
3
4
|
|
4
5
|
|
6
|
+

|
7
|
+
|
8
|
+
|
9
|
+
|
5
10
|
```ここに言語を入力
|
6
11
|
#include "Game.hpp"
|
7
12
|
#include "DxLib.h"
|
8
13
|
#include "Input.hpp"
|
9
14
|
#include <time.h>
|
10
15
|
|
11
|
-
const char* filename = "Log.txt";
|
16
|
+
static const char* filename = "Log.txt";
|
12
|
-
std::ofstream ofs(filename);
|
17
|
+
static std::ofstream ofs(filename);
|
13
18
|
|
14
19
|
Game::Game()
|
15
20
|
{
|
@@ -82,7 +87,7 @@
|
|
82
87
|
speed->y = 0;
|
83
88
|
}
|
84
89
|
|
85
|
-
|
90
|
+
*player->PrevPos = *player->position;
|
86
91
|
player->Move(speed);
|
87
92
|
|
88
93
|
}
|
@@ -90,19 +95,28 @@
|
|
90
95
|
/*仲間を自分に追尾させる。処理*/
|
91
96
|
void Game::Party()
|
92
97
|
{
|
98
|
+
|
99
|
+
// member_a->position->x = p.x - mapCELL;
|
100
|
+
// member_a->position->y = p.y - mapCELL;
|
101
|
+
|
102
|
+
|
93
|
-
|
103
|
+
/*Right move*/
|
104
|
+
if(player->getDirection().x > 0 && player->getDirection().y == 0)
|
94
105
|
{
|
95
|
-
float m = member_a->position->x + mapCELL;
|
96
106
|
|
107
|
+
member_a->position->x = player->PrevPos->x - mapCELL;
|
97
|
-
|
108
|
+
member_a->position->y = player->PrevPos->y;
|
109
|
+
}else if (player->getDirection().x < 0 && player->getDirection().y == 0)
|
98
|
-
|
110
|
+
{
|
99
|
-
member_a->position->y = player->position->y;
|
100
111
|
|
112
|
+
member_a->position->x = player->PrevPos->x + mapCELL;
|
101
|
-
|
113
|
+
member_a->position->y = player->PrevPos->y;
|
102
|
-
|
103
114
|
}
|
104
115
|
|
105
116
|
|
117
|
+
|
118
|
+
|
119
|
+
|
106
120
|
//member_a->Move(speed);
|
107
121
|
//member_b->Move(speed);
|
108
122
|
//member_c->Move(speed);
|
@@ -127,10 +141,10 @@
|
|
127
141
|
|
128
142
|
|
129
143
|
map->Update();
|
130
|
-
player->Update();
|
131
144
|
member_a->Update();
|
132
145
|
member_b->Update();
|
133
146
|
member_c->Update();
|
147
|
+
player->Update();
|
134
148
|
|
135
149
|
}
|
136
150
|
|
@@ -139,11 +153,14 @@
|
|
139
153
|
{
|
140
154
|
|
141
155
|
map->Draw_Update();
|
142
|
-
player->Draw_Update();
|
143
156
|
member_a->Draw_Update();
|
144
157
|
member_b->Draw_Update();
|
145
158
|
member_c->Draw_Update();
|
159
|
+
player->Draw_Update();
|
146
160
|
|
161
|
+
|
162
|
+
DrawFormatString(0, 0, GetColor(0, 0, 0), "player: %.2f , %.2f", player->position->x, player->position->y);
|
163
|
+
|
147
164
|
}
|
148
165
|
|
149
166
|
|