2017-05-23 16:40:02 -04:00
|
|
|
#ifndef BALL_H
|
|
|
|
#define BALL_H
|
|
|
|
|
|
|
|
#include "GraphicsObject.h"
|
|
|
|
//#include "PhysicsObject.h"
|
|
|
|
|
|
|
|
class Ball : public GraphicsObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Ball() : GraphicsObject(&Ball::SetX, this) // pointer to self (specific instance)
|
|
|
|
{
|
|
|
|
instance_num = ++instance_counter;
|
2017-05-23 17:02:23 -04:00
|
|
|
// NOTE(dev): don't go above 100, please, for the sake of the example.
|
|
|
|
}
|
2017-05-23 17:04:35 -04:00
|
|
|
int GetXFromPhysicsSimulation()
|
2017-05-23 17:02:23 -04:00
|
|
|
{
|
2017-05-23 17:04:35 -04:00
|
|
|
// 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);
|
2017-05-23 16:40:02 -04:00
|
|
|
}
|
|
|
|
static void SetX(int &x, void *instance)
|
|
|
|
{
|
|
|
|
Ball *ball = static_cast<Ball*>(instance);
|
2017-05-23 17:04:35 -04:00
|
|
|
x = ball->GetXFromPhysicsSimulation();
|
2017-05-23 16:40:02 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static int instance_counter;
|
|
|
|
int instance_num;
|
|
|
|
};
|
|
|
|
|
|
|
|
int Ball::instance_counter = 0;
|
|
|
|
|
|
|
|
#endif
|