Character2D.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include <Urho3D/Scene/LogicComponent.h>
  5. // All Urho3D classes reside in namespace Urho3D
  6. using namespace Urho3D;
  7. const float MOVE_SPEED_X = 4.0f;
  8. const int LIFES = 3;
  9. /// Character2D component controling Imp behavior.
  10. class Character2D : public LogicComponent
  11. {
  12. URHO3D_OBJECT(Character2D, LogicComponent);
  13. public:
  14. /// Construct.
  15. explicit Character2D(Context* context);
  16. /// Register object factory and attributes.
  17. static void RegisterObject(Context* context);
  18. /// Handle update. Called by LogicComponent base class.
  19. void Update(float timeStep) override;
  20. /// Handle player state/behavior when wounded.
  21. void HandleWoundedState(float timeStep);
  22. /// Handle death of the player.
  23. void HandleDeath();
  24. /// Flag when player is wounded.
  25. bool wounded_;
  26. /// Flag when player is dead.
  27. bool killed_;
  28. /// Timer for particle emitter duration.
  29. float timer_;
  30. /// Number of coins in the current level.
  31. int maxCoins_;
  32. /// Counter for remaining coins to pick.
  33. int remainingCoins_;
  34. /// Counter for remaining lifes.
  35. int remainingLifes_;
  36. /// Scaling factor based on tiles' aspect ratio (definitively set at tile map creation).
  37. float moveSpeedScale_;
  38. /// Camera's zoom (used to scale movement speed based on camera zoom).
  39. float zoom_;
  40. };