FastEngine
0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
includes
FastEngine
object
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
26
namespace
fge
27
{
28
29
class
FGE_API
ObjSprite
:
public
fge::Object
30
{
31
public
:
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
62
fge::RectFloat
getGlobalBounds
()
const override
;
63
fge::RectFloat
getLocalBounds
()
const override
;
64
65
private
:
66
void
updatePositions();
67
void
updateTexCoords();
68
69
fge::vulkan::VertexBuffer
g_vertices;
70
fge::Texture
g_texture;
71
fge::RectInt
g_textureRect;
72
};
73
74
}
// namespace fge
75
76
#endif
// _FGE_C_OBJSPRITE_HPP_INCLUDED
fge::Color
Definition
C_color.hpp:35
fge::ObjSprite
Definition
C_objSprite.hpp:30
fge::ObjSprite::getLocalBounds
fge::RectFloat getLocalBounds() const override
Get the local bounds of the object (without any transformations)
fge::ObjSprite::save
void save(nlohmann::json &jsonObject, fge::Scene *scene) override
Save the object to a json object.
fge::ObjSprite::getReadableClassName
char const * getReadableClassName() const override
Get a readable version of the class name.
fge::ObjSprite::unpack
void unpack(fge::net::Packet const &pck) override
Unpack the object from a packet.
fge::ObjSprite::pack
void pack(fge::net::Packet &pck) override
Pack the object into a packet.
fge::ObjSprite::load
void load(nlohmann::json &jsonObject, fge::Scene *scene) override
Load the object from a json object.
fge::ObjSprite::getClassName
char const * getClassName() const override
Get the unique class name of the object.
fge::ObjSprite::getGlobalBounds
fge::RectFloat getGlobalBounds() const override
Get the global bounds of the object.
fge::Object
The Object class is the base class for all objects in the engine.
Definition
C_object.hpp:102
fge::Rect< int32_t >
fge::Scene
A scene contain a collection of object and handle them.
Definition
C_scene.hpp:450
fge::Texture
This class is a wrapper for the texture manager to allow easy manipulation.
Definition
C_texture.hpp:36
fge::net::Packet
Definition
C_packet.hpp:70
fge::vulkan::VertexBuffer
Definition
C_vertexBuffer.hpp:45
Generated by
1.12.0