diff --git a/Ball.h b/Ball.h index a0deac7..a16ced0 100644 --- a/Ball.h +++ b/Ball.h @@ -12,14 +12,16 @@ public: instance_num = ++instance_counter; // NOTE(dev): don't go above 100, please, for the sake of the example. } - void GetXFromPhysicsSimulation() + int GetXFromPhysicsSimulation() { - x = instance_num + ((rand() % 10) * 100); // move around by ten, but keep single digit + // NOTE(dev): move around by 100 to show that the number is different each time, + // but keep the instance number to show you're on the same one. + return instance_num + ((rand() % 10) * 100); } static void SetX(int &x, void *instance) { Ball *ball = static_cast(instance); - ball->GetXFromPhysicsSimulation(); + x = ball->GetXFromPhysicsSimulation(); return; } diff --git a/GraphicsObject.h b/GraphicsObject.h index 8a2476e..b94fe2e 100644 --- a/GraphicsObject.h +++ b/GraphicsObject.h @@ -25,10 +25,9 @@ public: callback(x, user_data); return x; // either this was just set by callback, or it was always set by constructor. } -//private: +private: int x; void *user_data; -private: void (*callback)(int&, void*); }; diff --git a/PhysicsObject.h b/PhysicsObject.h deleted file mode 100644 index e26c7bb..0000000 --- a/PhysicsObject.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef PHYSICSOBJECT_H -#define PHYSICSOBJECT_H - -#include "IPhysics.h" - -class PhysicsObject - : public IPhysics -{ -public: - PhysicsObject() : IPhysics(&x) {} - int GetX() { Update(); return x; } -private: - int x; -}; - -#endif