Game Development Reference
In-Depth Information
The following pseudocode shows an updated version of the impulse-
application routine.
ApplyRopeImpulse( float P) {
bodies[0].ApplyImpulse(d[0]
P);
for ( int i=1; i < N; i++) {
// most of the math here should of course be computed
// only once and stored
float cos2a =
1]);
float cosa = sqrt((1+cos2a) 0.5);
float sina = sqrt((1 cos2a) 0.5);
P/=sina+mue cosa;
bodies[i].ApplyImpulse(
((d[i] d[i 1]) sina + (d[i 1]+d[i]) mue cosa) P);
P =sina mue cosa;
bodies[N].ApplyImpulse(d[N 1] ∗− P);
(d[i]
d[i
}
As tempted as I am to use the word “voila,” I'll refrain and will instead just
casually note that this is pretty much everything needed to efficiently simulate
a rope that can wrap around objects (I'll also refrain from calling this rope “ad-
vanced,” since the word quickly lost its value after a couple of iterations of engine
marketing). Now it's time to put it to good use. Or bad—the choice is yours, as it
always is.
You are in a room larger than the first two. Although it may just seem larger
because you can no longer stand upright. The hunger is excruciating—no wonder,
since you didn't eat the last time. You are standing—or rather crouching—close
to an edge, with a rope hanging from the ceiling next to you. Down below you see
several crates of different sizes.
> look at crates > wrap rope around neck
You quickly wrap the rope around your neck. This seems to have drawn the
attention of your captors, and a lot of it.
> jump down
As you jump down the edge, you see the figures running out of their room.
Bright lights turn on with distinct loud cracks, doors open on what seemed to be
perfectly smooth walls, and several people run toward you. As your vision fades,
you move your hands away from your neck and look at them. They are human.