Switched it to allow for up to 100 test objects before you can't prove which object is which via instance count.

This commit is contained in:
David Vereb 2017-05-23 17:02:23 -04:00
parent b0e17c96d3
commit 964db120ff

7
Ball.h
View File

@ -10,11 +10,16 @@ public:
Ball() : GraphicsObject(&Ball::SetX, this) // pointer to self (specific instance)
{
instance_num = ++instance_counter;
// NOTE(dev): don't go above 100, please, for the sake of the example.
}
void GetXFromPhysicsSimulation()
{
x = instance_num + ((rand() % 10) * 100); // move around by ten, but keep single digit
}
static void SetX(int &x, void *instance)
{
Ball *ball = static_cast<Ball*>(instance);
ball->x = ball->instance_num; // prove we're accessing the right one
ball->GetXFromPhysicsSimulation();
return;
}