Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GameObject {
- int objectType;
- // Split logical domain into seperate components.
- PhysicsComponent *physics;
- GraphicsComponent *graphics;
- void update(Input *input) {
- physics -> update(input);
- }
- void draw(Canvas *canvas) {
- graphics -> draw(canvas);
- }
- }
- // Responsible for Game Object `draw`
- class GraphicsComponent {
- public:
- virtual void draw ( Canvas *canvas ) {};
- };
- // Responsible for Game Object `update`
- class PhysicsComponent {
- public:
- // Relevant properties
- double x, y;
- double w, h;
- Vec2d velocity;
- PhysicsComponent() {};
- // ... Other Constructors
- virtual void update(Input *input) {};
- virtual void onCollision(PhysicsComponent *otherPhysics, int objectType) {};
- };
Add Comment
Please, Sign In to add comment