raylibstarter 0.1.0
actor.h
Go to the documentation of this file.
1#pragma once
2
3#include "sprite.h"
4
5namespace game::core {
6 /**
7 * @brief Actor base class. Actors represent all game objects, such as players, enemies and other obstacles.
8 *
9 * Graphically, actors are represented via a sprite object associated with them. The sprite must be passed in the constructor call.
10 *
11 * Actors can be placed in the actor-map of a scene object and will be drawn automatically if their visible
12 * attribute is true. If actor objects are supposed to be available across scenes, they can be stored in
13 * game::core::actors. Objects that are only referenced there will not be drawn automatically.
14 * The position and appearance of an actor object in the game depends on attributes (e.g. position and rotation) of its sprite member.
15 */
16 class Actor {
17 private:
18 std::shared_ptr<game::core::Sprite> sprite_;
19
20 public:
21 Actor() = delete;
22
23 /**
24 * @brief Constructor.
25 *
26 * Create a new Actor object.
27 * @param sprite Sprite object that is assigned to the Actor.
28 */
29 explicit Actor(std::shared_ptr<game::core::Sprite> sprite);
30
31 Actor(const game::core::Actor &actor) = delete;
32
33 Actor &operator=(const Actor &) = delete;
34
35 virtual ~Actor();
36
37 /**
38 * @brief Returns the sprite object of the actor
39 * @return Shared pointer of the objects Sprite.
40 */
41 [[nodiscard]] const std::shared_ptr<game::core::Sprite> &sprite() const;
42
43 /**
44 * @brief Replaces the current sprite object of the actor.
45 */
46 void sprite(std::shared_ptr<game::core::Sprite> sprite);
47 };
48}
Actor base class. Actors represent all game objects, such as players, enemies and other obstacles.
Definition: actor.h:16
const std::shared_ptr< game::core::Sprite > & sprite() const
Returns the sprite object of the actor.
Definition: actor.cpp:13
virtual ~Actor()
Definition: actor.cpp:9
std::shared_ptr< game::core::Sprite > sprite_
Definition: actor.h:18
Actor & operator=(const Actor &)=delete
Actor(const game::core::Actor &actor)=delete