CharacterGame.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef CHARACTERGAME_H_
  2. #define CHARACTERGAME_H_
  3. #include "gameplay.h"
  4. using namespace gameplay;
  5. /**
  6. * This is a mesh demo game for rendering Mesh.
  7. */
  8. class CharacterGame: public Game, public AnimationClip::Listener, public PhysicsCollisionObject::CollisionListener
  9. {
  10. public:
  11. /**
  12. * Constructor.
  13. */
  14. CharacterGame();
  15. /**
  16. * @see Game::keyEvent
  17. */
  18. void keyEvent(Keyboard::KeyEvent evt, int key);
  19. /**
  20. * @see Game::touchEvent
  21. */
  22. void touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
  23. /**
  24. * @see Game::mouseEvent
  25. */
  26. bool mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta);
  27. /**
  28. * @see Game::gamepadEvent
  29. */
  30. void gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad);
  31. /**
  32. * @see AnimationClip::Listener::animationEvent
  33. */
  34. void animationEvent(AnimationClip* clip, AnimationClip::Listener::EventType type);
  35. /**
  36. * @see PhysicsCollisionObject::CollisionListener::collisionEvent
  37. */
  38. void collisionEvent(PhysicsCollisionObject::CollisionListener::EventType type,
  39. const PhysicsCollisionObject::CollisionPair& collisionPair,
  40. const Vector3& contactPointA = Vector3::zero(),
  41. const Vector3& contactPointB = Vector3::zero());
  42. protected:
  43. /**
  44. * @see Game::initialize
  45. */
  46. void initialize();
  47. /**
  48. * @see Game::finalize
  49. */
  50. void finalize();
  51. /**
  52. * @see Game::update
  53. */
  54. void update(float elapsedTime);
  55. /**
  56. * @see Game::render
  57. */
  58. void render(float elapsedTime);
  59. private:
  60. bool initializeScene(Node* node);
  61. void initializeMaterial(Scene* scene, Node* node, Material* material);
  62. void initializeCharacter();
  63. void drawSplash(void* param);
  64. bool drawScene(Node* node, bool transparent);
  65. void play(const char* id, bool repeat, float speed = 1.0f);
  66. void jump();
  67. void kick();
  68. void adjustCamera(float elapsedTime);
  69. bool isOnFloor() const;
  70. void clone();
  71. void grabBall();
  72. void releaseBall();
  73. Font* _font;
  74. Scene* _scene;
  75. PhysicsCharacter* _character;
  76. Node* _characterNode;
  77. Node* _characterMeshNode;
  78. Node* _characterShadowNode;
  79. Node* _basketballNode;
  80. float _floorLevel;
  81. Animation* _animation;
  82. AnimationClip* _currentClip;
  83. AnimationClip* _jumpClip;
  84. AnimationClip* _kickClip;
  85. int _rotateX;
  86. MaterialParameter* _materialParameterAlpha;
  87. unsigned int _keyFlags;
  88. bool _physicsDebug;
  89. bool _wireframe;
  90. Vector3 _oldBallPosition;
  91. bool _hasBall;
  92. bool _applyKick;
  93. bool _kicking;
  94. float _kickDelay;
  95. bool* _buttonPressed;
  96. Vector2 _currentDirection;
  97. Gamepad* _gamepad;
  98. };
  99. #endif