Initial Commit with small working example.
This commit is contained in:
28
Ball.h
Normal file
28
Ball.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#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;
|
||||
}
|
||||
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
|
||||
return;
|
||||
}
|
||||
|
||||
private:
|
||||
static int instance_counter;
|
||||
int instance_num;
|
||||
};
|
||||
|
||||
int Ball::instance_counter = 0;
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user