File prop.hpp¶
Typedefs
-
using json = nlohmann::json
-
class Prop : public ISaveable
- #include <prop.hpp>
A Prop is an object in the world that has an image and optionally has an Interactable.
Public Functions
-
Prop()
Empty constructor
-
Prop(const std::string &filePath)
Construct from a file.
-
Prop(Rectangle atlasRect, Vector2 worldPos)
Construct from an atlas rect and an absolute world position.
-
explicit Prop(PropBin bin)
Construct from a binary structure.
-
std::string getSourcePath() const
Get the source file, used for instantiating this Prop.
-
void setTexture(Texture2D texture)
Set the Texture for this Prop.
-
Texture2D getTexture() const
Get the Texture for this Prop.
-
void setTextureFromPath(const std::string &imagePath)
Set the Texture, using an image path.
-
const char *getImagePath() const
Get the path to the image used for this Prop.
-
void setCollisionRect(Rectangle collisionRect)
Set the collision rectangle.
-
void setWorldTilePos(Vector2 worldPos, int tileSize)
Set the tile position of this Prop.
-
void setWorldPos(Vector2 worldPos)
Set the absolute world position of this Prop.
-
Vector2 getWorldPos() const
Get the absolute world position of this Prop.
-
Vector2 getWorldTilePos() const
Get the tile position of this Prop.
-
void setAtlasRect(Rectangle atlasRect)
Set the Atlas rectangle of this Prop. (which part of the image is used for drawing)
-
Rectangle getAtlasRect() const
Get the Atlas rectangle of this Prop.
-
Rectangle getCollisionRect() const
Get the collision rectangle of this Prop, relative to the Prop itself.
-
Rectangle getWorldCollisionRect() const
Get the collision rectangle with position relative to the World. (absolute)
-
Vector2 getCollisionCenter() const
Get the position of the center of the collision rectangle.
-
bool getHasInteractable() const
Whether this Prop has an Interactangle or not.
-
void setHasInteractable(bool value)
Set the ‘hasInteractable’ flag.
-
Interactable *getInteractable() const
Get a pointer to the Interactable of this Prop.
-
void setInteractableType(const std::string &type)
Set the type of this Prop’s Interactable.
-
std::string getInteractableType() const
Get the type of this Prop’s Interactable.
-
void draw() const
Draw routine.
Private Members
-
Rectangle atlasRect¶
Atlas Rectangle which defines which part of the image is used for drawing this Prop.
-
Rectangle collisionRect¶
Collision Rectangle which defines where exactly is the collision.
-
bool hasInteractable = false¶
Whether this Prop has an Interactable.
-
std::unique_ptr<Interactable> interactable¶
Smart pointer that owns the Interactable
-
Prop()