Guest User

Untitled

a guest
May 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. class GameObject {
  2. int objectType;
  3. // Split logical domain into seperate components.
  4. PhysicsComponent *physics;
  5. GraphicsComponent *graphics;
  6.  
  7. void update(Input *input) {
  8. physics -> update(input);
  9. }
  10.  
  11. void draw(Canvas *canvas) {
  12. graphics -> draw(canvas);
  13. }
  14. }
  15.  
  16. // Responsible for Game Object `draw`
  17. class GraphicsComponent {
  18. public:
  19. virtual void draw ( Canvas *canvas ) {};
  20. };
  21.  
  22. // Responsible for Game Object `update`
  23. class PhysicsComponent {
  24.  
  25. public:
  26. // Relevant properties
  27. double x, y;
  28. double w, h;
  29. Vec2d velocity;
  30.  
  31. PhysicsComponent() {};
  32. // ... Other Constructors
  33.  
  34. virtual void update(Input *input) {};
  35. virtual void onCollision(PhysicsComponent *otherPhysics, int objectType) {};
  36. };
Add Comment
Please, Sign In to add comment