PongObject.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. #ifndef __PONGPAD__
  5. #define __PONGPAD__
  6. class PongApp;
  7. #define PAD_HOR_R 0.03f
  8. #define PAD_VER_R 0.2f
  9. #define BALL_R 0.04f
  10. #define AI_PAD_MAXYMOVE 1.0f
  11. #define AI_PADMOVE_SPEED 20.0f
  12. enum PONG_OBJECT_TYPE { PO_BALL, PO_COMPUTERPAD, PO_PLAYERPAD, PO_PLAYERPAD2 };
  13. class PongObject {
  14. public:
  15. PongObject( PongApp *app, PONG_OBJECT_TYPE t );
  16. ~PongObject();
  17. void update( const float frameTime, PongObject *ball,
  18. bool buttonDown=false, float pointerX=0.0f, float pointerY=0.0f );
  19. void ballHitCheck( const float frameTime, PongObject *ball );
  20. void render(float visibility);
  21. void controlWithGravity( const float frameTime, float *gravity );
  22. inline float *position() { return pos; };
  23. inline float *direction() { return dir; }
  24. inline float *getColor() { return color; }
  25. protected:
  26. PongApp *pongApp;
  27. void runAI( const float frameTime, PongObject *ball );
  28. PONG_OBJECT_TYPE type;
  29. float gravityAffectTime;
  30. float color[4];
  31. float size[2];
  32. float orientation[2];
  33. float travelled;
  34. float expos[3];
  35. float pos[3];
  36. float dir[3];
  37. float gravityVector[3];
  38. float curving;
  39. bool aiAttacking;
  40. };
  41. #endif