34 lines
717 B
C++
34 lines
717 B
C++
#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;
|
|
// 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->GetXFromPhysicsSimulation();
|
|
return;
|
|
}
|
|
|
|
private:
|
|
static int instance_counter;
|
|
int instance_num;
|
|
};
|
|
|
|
int Ball::instance_counter = 0;
|
|
|
|
#endif
|