質問編集履歴
5
質問用に編集したコード"fileinput.open("savefile.txt")"を元のコード"fileinput.open(filename);"に変更しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -232,9 +232,9 @@
|
|
232
232
|
|
233
233
|
|
234
234
|
|
235
|
-
fileinput.open("savefile.txt");
|
235
|
+
//fileinput.open("savefile.txt");
|
236
|
+
|
236
|
-
|
237
|
+
fileinput.open(filename);
|
237
|
-
|
238
238
|
|
239
239
|
|
240
240
|
|
4
コンストラクタの一部を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -202,6 +202,26 @@
|
|
202
202
|
|
203
203
|
```mainadmin.cpp
|
204
204
|
|
205
|
+
|
206
|
+
|
207
|
+
MainAdmin::MainAdmin():filename("savefile.txt"),quitApplication(false)
|
208
|
+
|
209
|
+
{
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
205
225
|
void MainAdmin::Init()
|
206
226
|
|
207
227
|
{
|
3
クラスヘッダファイルを一部抜粋ではなく、全体を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,6 +26,36 @@
|
|
26
26
|
|
27
27
|
```C++
|
28
28
|
|
29
|
+
#pragma once
|
30
|
+
|
31
|
+
#include <fstream>
|
32
|
+
|
33
|
+
using namespace std;
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
class SaveButton;
|
38
|
+
|
39
|
+
class GameObject;
|
40
|
+
|
41
|
+
class EnemyHP_AddButton;
|
42
|
+
|
43
|
+
class EnemyHP_SubButton;
|
44
|
+
|
45
|
+
class X_AddButton;
|
46
|
+
|
47
|
+
class X_SubButton;
|
48
|
+
|
49
|
+
class Y_AddButton;
|
50
|
+
|
51
|
+
class Y_SubButton;
|
52
|
+
|
53
|
+
class ClearScoreButton_Add;
|
54
|
+
|
55
|
+
class ClearScoreButton_Sub;
|
56
|
+
|
57
|
+
class Mouse;
|
58
|
+
|
29
59
|
class MainAdmin
|
30
60
|
|
31
61
|
{
|
@@ -40,49 +70,209 @@
|
|
40
70
|
|
41
71
|
|
42
72
|
|
73
|
+
int Player_initHP;
|
74
|
+
|
75
|
+
int Enemy_initHP;
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
int Clear_Score_init;
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
char key[256];
|
84
|
+
|
85
|
+
bool quitApplication;
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
int Player_GraphicHandle;
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
std::unique_ptr<GameObject>Player;
|
94
|
+
|
95
|
+
std::shared_ptr<Mouse>mouse;
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
std::unique_ptr<SaveButton>S_button;
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
std::unique_ptr<EnemyHP_AddButton>HPAdd;
|
104
|
+
|
105
|
+
std::unique_ptr<EnemyHP_SubButton>HPSub;
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
std::unique_ptr<X_AddButton>X_add;
|
110
|
+
|
111
|
+
std::unique_ptr<X_SubButton>X_Sub;
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
std::unique_ptr<Y_AddButton>Y_add;
|
116
|
+
|
117
|
+
std::unique_ptr<Y_SubButton>Y_Sub;
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
std::unique_ptr <ClearScoreButton_Add>Clear_Add;
|
122
|
+
|
123
|
+
std::unique_ptr<ClearScoreButton_Sub>Clear_Sub;
|
124
|
+
|
125
|
+
public:
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
const char* filename;
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
MainAdmin();
|
134
|
+
|
135
|
+
~MainAdmin();
|
136
|
+
|
137
|
+
int GetP_initX() { return Player_initX; }
|
138
|
+
|
139
|
+
int GetP_initY() {
|
140
|
+
|
141
|
+
return Player_initY;
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
int GetP_initHP() {
|
146
|
+
|
147
|
+
return Player_initHP;
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
int GetE_initHP() {
|
152
|
+
|
153
|
+
return Enemy_initHP;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
int GetClear_Score_Init()
|
158
|
+
|
159
|
+
{
|
160
|
+
|
161
|
+
return Clear_Score_init;
|
162
|
+
|
163
|
+
}
|
164
|
+
|
165
|
+
std::shared_ptr<Mouse> GetMouse() { return mouse; }
|
166
|
+
|
167
|
+
void SetClear_Score_Init(int score) { Clear_Score_init = score; }
|
168
|
+
|
169
|
+
void SetEnemy_HP(int hp) { Enemy_initHP = hp; }
|
170
|
+
|
171
|
+
void SetinitX(int m_x) { Player_initX = m_x; }
|
172
|
+
|
173
|
+
void SetinitY(int m_y) { Player_initY = m_y; }
|
174
|
+
|
175
|
+
char* GetKey() { return key; }
|
176
|
+
|
177
|
+
void Init();
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
void Update();
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
void SaveFile();
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
void end();
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
};
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
```
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
```mainadmin.cpp
|
204
|
+
|
205
|
+
void MainAdmin::Init()
|
206
|
+
|
207
|
+
{
|
208
|
+
|
209
|
+
ifstream fileinput;
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
fileinput.open("savefile.txt");
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
//ファイルに書き込みがあったらファイルの値を読み込む
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
fileinput >> Player_initX >> Player_initY
|
228
|
+
|
229
|
+
>> Player_initHP >> Enemy_initHP
|
230
|
+
|
231
|
+
>> Clear_Score_init;
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
fileinput.close();
|
240
|
+
|
241
|
+
|
242
|
+
|
43
243
|
}
|
44
244
|
|
45
|
-
|
245
|
+
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
246
|
+
|
50
|
-
|
247
|
+
|
248
|
+
|
51
|
-
void MainAdmin::
|
249
|
+
void MainAdmin::SaveFile()
|
52
250
|
|
53
251
|
{
|
54
252
|
|
55
|
-
|
253
|
+
ofstream fileoutput;
|
254
|
+
|
56
|
-
|
255
|
+
if (!fileoutput.is_open()) {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
256
|
+
|
61
|
-
file
|
257
|
+
fileoutput.open(filename);
|
258
|
+
|
62
|
-
|
259
|
+
}
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
260
|
+
|
67
|
-
//ファイルに
|
261
|
+
//ファイルに出力する
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
262
|
+
|
73
|
-
|
263
|
+
fileoutput<< 200 << 200
|
74
|
-
|
75
|
-
|
264
|
+
|
76
|
-
|
77
|
-
|
265
|
+
<< 200 << 200
|
266
|
+
|
78
|
-
|
267
|
+
<< 200;
|
268
|
+
|
269
|
+
|
270
|
+
|
79
|
-
|
271
|
+
DrawString(320, 240, "セーブしました", GetColor(255, 255, 255));
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
272
|
+
|
85
|
-
file
|
273
|
+
fileoutput.close();
|
274
|
+
|
275
|
+
|
86
276
|
|
87
277
|
|
88
278
|
|
@@ -90,42 +280,6 @@
|
|
90
280
|
|
91
281
|
|
92
282
|
|
93
|
-
|
94
|
-
|
95
|
-
void MainAdmin::SaveFile()
|
96
|
-
|
97
|
-
{
|
98
|
-
|
99
|
-
ofstream fileoutput;
|
100
|
-
|
101
|
-
if (!fileoutput.is_open()) {
|
102
|
-
|
103
|
-
fileoutput.open(filename);
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
//ファイルに出力する
|
108
|
-
|
109
|
-
fileoutput<< 200 << 200
|
110
|
-
|
111
|
-
<< 200 << 200
|
112
|
-
|
113
|
-
<< 200;
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
DrawString(320, 240, "セーブしました", GetColor(255, 255, 255));
|
118
|
-
|
119
|
-
fileoutput.close();
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
|
128
|
-
|
129
283
|
```
|
130
284
|
|
131
285
|
|
2
セーブ時のコード記述を追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -88,6 +88,44 @@
|
|
88
88
|
|
89
89
|
}
|
90
90
|
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
void MainAdmin::SaveFile()
|
96
|
+
|
97
|
+
{
|
98
|
+
|
99
|
+
ofstream fileoutput;
|
100
|
+
|
101
|
+
if (!fileoutput.is_open()) {
|
102
|
+
|
103
|
+
fileoutput.open(filename);
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
//ファイルに出力する
|
108
|
+
|
109
|
+
fileoutput<< 200 << 200
|
110
|
+
|
111
|
+
<< 200 << 200
|
112
|
+
|
113
|
+
<< 200;
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
DrawString(320, 240, "セーブしました", GetColor(255, 255, 255));
|
118
|
+
|
119
|
+
fileoutput.close();
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
91
129
|
```
|
92
130
|
|
93
131
|
|
1
MainAdminクラスのヘッダファイルを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,6 +25,28 @@
|
|
25
25
|
> 現在のコードとテキストファイルの状態
|
26
26
|
|
27
27
|
```C++
|
28
|
+
|
29
|
+
class MainAdmin
|
30
|
+
|
31
|
+
{
|
32
|
+
|
33
|
+
protected:
|
34
|
+
|
35
|
+
//エディターを読み込んだ時の、自機の初期位置
|
36
|
+
|
37
|
+
int Player_initX;
|
38
|
+
|
39
|
+
int Player_initY;
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
```mainadmin.cpp
|
28
50
|
|
29
51
|
void MainAdmin::Init()
|
30
52
|
|