Hi Avi,
I'm still new to TDD and I'm not sure, if I really understand your
specific problem, so maybe this is rubbish not how it should be done.
I'll try anyway:
If I understand this correctly, there is no trivial algorithm to compute
the position of the marker, because the 'algorithm' is the behaviour of
the game engine, isn't it?
So the position of the marker is determined by the level design, the
collision detection (or physics system and properties like gravity) of
the game engine and the game objects' properties (velocity, friction, ?)
over time.
If that is correct, it should be possible to write a top-down test like
this (for your example):
// pseudo code
penguin = new GameObject( position, velocity, rotation, shape, whatever );
// let's say physicsWorld computes the position and collisions of the
gameObjects
physicsWorld.add( penguin );
// deltaTime in Milliseconds
fixedDeltaTimeMS = 20;
numFrames = 100;
// evaluate the position for the next two seconds
for ( i=0; i < numFrames; i++ ) {
physicsWorld.update( fixedDeltaTimeMS );
}
// check the position of our hero
assert( penguin.position, whereEverYouWantItToBe );
If you can test like this, you can break the tests down:
shouldMove100PixelWithVelocity100PerSecond();
shouldBounceFiveTimesInSixSecondsWhenFallingFromHeight200(); // whatever :)
If your systems allow testing like this, it should always be possible to
"peek into the future" to determine the position of a game object in x
milliseconds. And then it is not be too complicated to determine whether
the marker is onscreen or offscreen.
Hth,
Stefan