Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
sprite.h
Go to the documentation of this file.
1#pragma once
2
8
9#include <optional>
10#include <string>
11
27class Sprite final : public Renderable {
28 private:
29 std::reference_wrapper<Texture> texture_;
30 int flip_x_;
31 int flip_y_;
32 int sorting_layer_;
33 int ordering_layer_;
34 Color color_;
35
36 std::reference_wrapper<Texture> get_texture_for(const std::string& sprite);
37
38 public:
39 Sprite(const std::string& sprite, Color color, bool flip_x, bool flip_y,
41
42 [[nodiscard]] bool flip_x() const;
43 Sprite& flip_x(bool val);
44
45 [[nodiscard]] bool flip_y() const;
46 Sprite& flip_y(bool val);
47
48 [[nodiscard]] int sorting_layer() const;
50
51 [[nodiscard]] int ordering_layer() const;
53
54 [[nodiscard]] Color color() const;
56
57 [[nodiscard]] const Texture& texture() const;
58 Sprite& texture(const std::string& name);
60
61 void update(float dt) override;
62
63 std::string type_name() const override;
64};
Represents a color with red, green, blue, and alpha components. Each component is represented as an u...
Definition color.h:7
Base class for renderable components in the engine.
Definition renderable.h:16
Component that represents a 2D sprite to be rendered. The Sprite component holds a reference to a Tex...
Definition sprite.h:27
int sorting_layer() const
const Texture & texture() const
Sprite & sorting_layer(int val)
Sprite & texture(Texture &texture)
void update(float dt) override
Sprite(const std::string &sprite, Color color, bool flip_x, bool flip_y, int sorting_layer, int ordering_layer)
Sprite & ordering_layer(int val)
int ordering_layer() const
Sprite & flip_y(bool val)
bool flip_y() const
Color color() const
Sprite & flip_x(bool val)
std::string type_name() const override
Provides a consistent type name for the component.
Sprite & texture(const std::string &name)
bool flip_x() const
Sprite & color(Color color)
Represents a texture used in rendering game objects. Encapsulates an SDL_Texture and provides access ...
Definition texture.h:10