From 964db120ffca949c3bc88d1ab52689a7d071a64e Mon Sep 17 00:00:00 2001 From: David Vereb Date: Tue, 23 May 2017 17:02:23 -0400 Subject: [PATCH] Switched it to allow for up to 100 test objects before you can't prove which object is which via instance count. --- Ball.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Ball.h b/Ball.h index 520bae2..a0deac7 100644 --- a/Ball.h +++ b/Ball.h @@ -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(instance); - ball->x = ball->instance_num; // prove we're accessing the right one + ball->GetXFromPhysicsSimulation(); return; }