FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
C_objSprite.hpp
1/*
2 * Copyright 2024 Guillaume Guillet
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _FGE_C_OBJSPRITE_HPP_INCLUDED
18#define _FGE_C_OBJSPRITE_HPP_INCLUDED
19
20#include "FastEngine/fge_extern.hpp"
21#include "C_object.hpp"
22#include "FastEngine/accessor/C_texture.hpp"
23
24#define FGE_OBJSPRITE_CLASSNAME "FGE:OBJ:SPRITE"
25
26namespace fge
27{
28
29class FGE_API ObjSprite : public fge::Object
30{
31public:
32 ObjSprite();
33 explicit ObjSprite(fge::Texture const& texture, fge::Vector2f const& position = fge::Vector2f());
34 ObjSprite(fge::Texture const& texture,
35 fge::RectInt const& rectangle,
36 fge::Vector2f const& position = fge::Vector2f());
37
38 FGE_OBJ_DEFAULT_COPYMETHOD(fge::ObjSprite)
39
40 void setTexture(fge::Texture const& texture, bool resetRect = false);
41 void setTextureRect(fge::RectInt const& rectangle);
42 void flipHorizontal();
43 void flipVertical();
44
45 void setColor(fge::Color const& color);
46
47 fge::Texture const& getTexture() const;
48 fge::RectInt const& getTextureRect() const;
49
50 fge::Color getColor() const;
51
52 FGE_OBJ_DRAW_DECLARE
53
54 void save(nlohmann::json& jsonObject, fge::Scene* scene) override;
55 void load(nlohmann::json& jsonObject, fge::Scene* scene) override;
56 void pack(fge::net::Packet& pck) override;
57 void unpack(fge::net::Packet const& pck) override;
58
59 char const* getClassName() const override;
60 char const* getReadableClassName() const override;
61
64
65private:
66 void updatePositions();
67 void updateTexCoords();
68
70 fge::Texture g_texture;
71 fge::RectInt g_textureRect;
72};
73
74} // namespace fge
75
76#endif // _FGE_C_OBJSPRITE_HPP_INCLUDED
Definition C_color.hpp:35
Definition C_objSprite.hpp:30
fge::RectFloat getLocalBounds() const override
Get the local bounds of the object (without any transformations)
void save(nlohmann::json &jsonObject, fge::Scene *scene) override
Save the object to a json object.
char const * getReadableClassName() const override
Get a readable version of the class name.
void unpack(fge::net::Packet const &pck) override
Unpack the object from a packet.
void pack(fge::net::Packet &pck) override
Pack the object into a packet.
void load(nlohmann::json &jsonObject, fge::Scene *scene) override
Load the object from a json object.
char const * getClassName() const override
Get the unique class name of the object.
fge::RectFloat getGlobalBounds() const override
Get the global bounds of the object.
The Object class is the base class for all objects in the engine.
Definition C_object.hpp:102
A scene contain a collection of object and handle them.
Definition C_scene.hpp:450
This class is a wrapper for the texture manager to allow easy manipulation.
Definition C_texture.hpp:36
Definition C_packet.hpp:70
Definition C_vertexBuffer.hpp:45