Skip to content

Commit 57ac33d

Browse files
committed
Correct jump direction in skylaunch. Fix #296.
1 parent 86a4cb9 commit 57ac33d

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

code/cpp/subclass-sandbox.h

+33-33
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ namespace SimpleExample
1414
{
1515
public:
1616
virtual ~Superpower() {}
17-
17+
1818
protected:
1919
virtual void activate() = 0;
20-
20+
2121
void move(double x, double y, double z)
2222
{
2323
// Code here...
2424
}
25-
25+
2626
void playSound(SoundId sound, double volume)
2727
{
2828
// Code here...
@@ -34,7 +34,7 @@ namespace SimpleExample
3434
}
3535
};
3636
//^1
37-
37+
3838
//^2
3939
class SkyLaunch : public Superpower
4040
{
@@ -69,15 +69,15 @@ namespace Elaborated
6969
return 0;
7070
//^omit
7171
}
72-
72+
7373
double getHeroY()
7474
{
7575
// Code here...
7676
//^omit
7777
return 0;
7878
//^omit
7979
}
80-
80+
8181
double getHeroZ()
8282
{
8383
// Code here...
@@ -89,7 +89,7 @@ namespace Elaborated
8989
// Existing stuff...
9090
};
9191
//^3
92-
92+
9393
//^4
9494
class SkyLaunch : public Superpower
9595
{
@@ -107,7 +107,7 @@ namespace Elaborated
107107
{
108108
// Near the ground, so do a double jump.
109109
playSound(SOUND_SWOOP, 1.0f);
110-
move(0, 0, getHeroZ() - 20);
110+
move(0, 0, getHeroZ() + 20);
111111
}
112112
else
113113
{
@@ -127,9 +127,9 @@ namespace Forwarding
127127
{
128128
void play(SoundId sound, double volume) {}
129129
};
130-
130+
131131
SoundEngine soundEngine_;
132-
132+
133133
//^5
134134
void playSound(SoundId sound, double volume)
135135
{
@@ -153,12 +153,12 @@ namespace HelperClassBefore
153153
{
154154
// Code here...
155155
}
156-
156+
157157
void setVolume(SoundId sound)
158158
{
159159
// Code here...
160160
}
161-
161+
162162
// Sandbox method and other operations...
163163
};
164164
//^6
@@ -173,19 +173,19 @@ namespace HelperClassAfter
173173
{
174174
// Code here...
175175
}
176-
176+
177177
void stopSound(SoundId sound)
178178
{
179179
// Code here...
180180
}
181-
181+
182182
void setVolume(SoundId sound)
183183
{
184184
// Code here...
185185
}
186186
};
187187
//^7
188-
188+
189189
//^8
190190
class Superpower
191191
{
@@ -194,9 +194,9 @@ namespace HelperClassAfter
194194
{
195195
return soundPlayer_;
196196
}
197-
197+
198198
// Sandbox method and other operations...
199-
199+
200200
private:
201201
SoundPlayer soundPlayer_;
202202
};
@@ -206,19 +206,19 @@ namespace HelperClassAfter
206206
namespace PassToConstructor
207207
{
208208
class ParticleSystem {};
209-
209+
210210
//^pass-to-ctor-base
211211
class Superpower
212212
{
213213
public:
214214
Superpower(ParticleSystem* particles)
215215
: particles_(particles)
216216
{}
217-
217+
218218
// Sandbox method and other operations...
219-
219+
220220
private:
221-
ParticleSystem* particles_;
221+
ParticleSystem* particles_;
222222
};
223223
//^pass-to-ctor-base
224224

@@ -236,15 +236,15 @@ namespace PassToConstructor
236236
namespace TwoStageInit
237237
{
238238
class ParticleSystem {};
239-
239+
240240
class Superpower
241241
{
242242
public:
243243
void init(ParticleSystem* particles) {}
244244
};
245-
245+
246246
ParticleSystem* particles;
247-
247+
248248
class SkyLaunch : public Superpower {};
249249

250250
void foo()
@@ -259,15 +259,15 @@ namespace TwoStageInit
259259
namespace TwoStageInitEncapsulated
260260
{
261261
class ParticleSystem {};
262-
262+
263263
class Superpower
264264
{
265265
public:
266266
void init(ParticleSystem* audio) {}
267267
};
268-
268+
269269
class SkyLaunch : public Superpower {};
270-
270+
271271
//^10
272272
Superpower* createSkyLaunch(ParticleSystem* particles)
273273
{
@@ -281,7 +281,7 @@ namespace TwoStageInitEncapsulated
281281
namespace StaticState
282282
{
283283
class ParticleSystem {};
284-
284+
285285
//^11
286286
class Superpower
287287
{
@@ -290,7 +290,7 @@ namespace StaticState
290290
{
291291
particles_ = particles;
292292
}
293-
293+
294294
// Sandbox method and other operations...
295295

296296
private:
@@ -305,15 +305,15 @@ namespace UseServiceLocator
305305
{
306306
void spawn(ParticleType type, int count);
307307
};
308-
308+
309309
ParticleSystem particles;
310-
310+
311311
class Locator
312312
{
313313
public:
314314
static ParticleSystem& getParticles() { return particles; }
315315
};
316-
316+
317317
//^12
318318
class Superpower
319319
{
@@ -323,7 +323,7 @@ namespace UseServiceLocator
323323
ParticleSystem& particles = Locator::getParticles();
324324
particles.spawn(type, count);
325325
}
326-
326+
327327
// Sandbox method and other operations...
328328
};
329329
//^12

0 commit comments

Comments
 (0)