Manifest Entities
These entities exist inside the game realm and are mostly
loaded from the manifest files one way or another. They all
derieve from the base class dook::Entity.
Base Entity Class
Every single entity inherits this class, this class holds the general bookkeeping information on entites to keep track of where they were initiated.
Each entity includes a dook::EntityType for
easier distinguishing.
Each of these object also often carry a
dook::SourceInfo field to see where in the manifest
file they are included.
-
struct SourceInfo
Holds debug info about a src file.
Used to hold which file and line pair a specific resource originates from.
-
enum dook::EntityType
Values:
-
enumerator STATE
-
enumerator COMMAND
-
enumerator LEVEL
-
enumerator CHARACTER
-
enumerator OBJECT
-
enumerator STATE
-
class Entity
Subclassed by dook::Command, dook::Level, dook::Object, dook::State
Public Functions
-
inline const SourceInfo &source_info() const
Location the entity parsed from.
Return the originating filename and line.
-
inline const EntityType &type() const
Get the type of the entity.
-
inline Entity(std::string name, EntityType type, SourceInfo source)
Construct a new Entity object.
- Parameters:
name – Name of the entity.
source – Source file/call the entity. originates from.
type – Type of the entity.
-
inline const SourceInfo &source_info() const
Media files
Used by object and characters to hold multimedia info.
-
class Texture
Subclassed by dook::NullTexture, dook::SDLTexture
Public Functions
-
void animate()
Take a step in animation.
Loops back to texture resource.
-
void reset()
Reset the animation.
-
bool is_animation_completed() const
Check if animation step is the last one.
True if this is the final possible animation to draw.
- Returns:
true If the draw rectangle touches the end of the texture.
- Returns:
false otherwise.
-
void animate()
-
class NullTexture : public dook::Texture
Empty texture object.
Noop texture class to use for null service providers or testing.
-
class Audio
Subclassed by dook::NullAudio
Objects & Characters
Objects & Characters are the moving parts of the engine, they use the above Entities to interact with each other.
-
class Object : public dook::Entity
Subclassed by dook::Character
Public Functions
-
inline Object(std::string name, State base_state, State terminal_state, Position position, SourceInfo source)
Construct a new Object object.
- Parameters:
name – Name of the object.
base_state – Base state of the object, initilizes as this and eventually reverts to this when, if, the time comes.
terminal_state – When reached, object is determined to be removable.
position – The location of the object in 2D space.
source – Information about the parsing source for this object.
-
inline Object(std::string name, State base_state, State terminal_state, Position position)
Construct a new Object object.
- Parameters:
name – Name of the object.
base_state – Base state of the object, initilizes as this and eventually reverts to this when, if, the time comes.
terminal_state – When reached, object is determined
position – Position of the object in 2D space. to be removable.
-
bool can_remove() const
Check if the object is in terminal state with completed anim.
-
Texture &texture()
Get a modifiable reference to the current texture.
- Returns:
Texture& texture reference.
-
virtual void tick()
Perform a tick on an object.
-
void reset()
Reset the object to its initial state.
-
bool at_base_state()
Check if the object is at base state.
- Returns:
true
- Returns:
false
-
inline Object(std::string name, State base_state, State terminal_state, Position position, SourceInfo source)
-
struct CharacterStates
Each character must have these states.
Define which concrete dook::State objects each character’s state is assigned to.
-
struct CharacterStats
Holds information about character behaviour and abilities.
Public Members
-
AIType behaviour
Determines AI behaviour.
-
float max_health
Max health this character can hae.
-
float health
Current character health.
-
float detection_range
Range in metres this character can detect other characters
-
float attack_range
Range at which the character can hurt other characters.
-
float attack
Amount of attack points, ie: when attacking the other character’s health is subtracted by this amount.
-
float health_recovery_per_tick
Amount of health points recovered per tick when the character have not been damaged for some ticks.
-
float speed
Walking speed of the character.
-
AIType behaviour
-
class Character : public dook::Object
Moving objects that interact with the player.
- Template Parameters:
T – Type of their raw texture.
S – Type of their raw audio.
Public Functions
-
inline Character(std::string name, CharacterStats stats, CharacterStates states, Position position, SourceInfo source)
Construct a new Character object.
- Parameters:
name – Name of the character.
base_state – Base state for the object, initilized and reverts to this state.
terminal_state – When reached, the character is deemed removable.
stats – Stats for character.
source – Information about the entity parse.
-
inline Character(std::string name, CharacterStats stats, CharacterStates states, Position position)
Construct a new Character object.
- Parameters:
name – Name of the character.
base_state – Base state for the object, initilized and reverts to this state.
terminal_state – When reached, the character is deemed removable.
stats – Stats for character.
position – Position of the character.
-
inline const CharacterStats &stats() const
Get a readonly reference to the stats object.
-
virtual void tick() override
Perform a tick on an object.
-
void hurt(float damage)
Hurt a character by applying damage.
- Parameters:
damage – Damage to be applied to health.
Levels
Finally, levels tie all of these things together.
-
class Level : public dook::Entity
Contains information about a single level.
Public Functions
-
inline Level(std::string name, std::unique_ptr<Texture> background, std::unique_ptr<Texture> foreground, std::unique_ptr<Texture> passability, SourceInfo source)
Construct a new Level object.
- Parameters:
name – Entity name of the level.
background – Background texture that will be rendered before the characters.
foreground – Foreground texture that will be rendered in front of the characters.
passability – Passability layer that decides which tiles are passable.
source – Information about source file.
-
inline Level(std::string name, std::unique_ptr<Texture> background, std::unique_ptr<Texture> foreground, std::unique_ptr<Texture> passability)
Construct a new Level object.
- Parameters:
name – Entity name of the level.
background – Background texture that will be rendered before the characters.
foreground – Foreground texture that will be rendered in front of the characters.
passability – Passability layer that decides which tiles are passable.
Include a character in this level.
- Parameters:
character –
-
std::shared_ptr<Character> main_character()
Get the main character.
Character with ID 0 is the main character.
- Returns:
std::shared_ptr<Character> The main character.
-
std::vector<std::shared_ptr<Object>> objects_within_region(const Rect ®ion)
Get the objects within the given region.
- Parameters:
region – Region to get the objects within.
- Returns:
A vector of shared pointers to objects that fall within the region.
-
void tick()
Let objects take their turns.
-
inline Level(std::string name, std::unique_ptr<Texture> background, std::unique_ptr<Texture> foreground, std::unique_ptr<Texture> passability, SourceInfo source)