Initial Commit with small working example.

This commit is contained in:
David Vereb
2017-05-23 16:40:02 -04:00
commit b0e17c96d3
7 changed files with 124 additions and 0 deletions

28
Ball.h Normal file
View 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