-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demo (./Menu): Example of Menu scene with fade
- Loading branch information
1 parent
eb2f845
commit fe29ee7
Showing
15 changed files
with
555 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Entities: | ||
- Entity: 956230123451 | ||
TagComponent: | ||
Tag: Press Start | ||
TransformComponent: | ||
Translation: [0, 0, 0] | ||
Rotation: [0, 0, 0] | ||
Scale: [0.25, 0.25, 1] | ||
TextRendererComponent: | ||
Text: PRESS START | ||
Color: [1, 1, 1, 1] | ||
Font: 45121874124124 | ||
Kerning: 0 | ||
LineSpacing: 0 | ||
FadeComponent: | ||
Opacity: 0 | ||
FadeInSpeed: 0.4 | ||
FadeOutSpeed: 0.4 | ||
ShouldFadeIn: true | ||
ShouldFadeOut: false | ||
Repeat: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Project: | ||
Name: R-Type | ||
StartScene: 7402922757700725494 | ||
StartScene: 6925943162598913395 | ||
AssetsDirectory: "" | ||
AssetRegistryPath: "AssetRegistry.asset" | ||
ScriptsDirectory: "Scripts" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,47 @@ | ||
Scene: Menu | ||
Scene: Loading | ||
Entities: | ||
- Entity: 15835038643471288681 | ||
- Entity: 455125451521210515 | ||
TransformComponent: | ||
Translation: [0, 0, 15] | ||
Translation: [0, 0, 6] | ||
Rotation: [0, 0, 0] | ||
Scale: [1, 1, 1] | ||
TagComponent: | ||
Tag: Camera | ||
CameraComponent: | ||
Camera: | ||
ProjectionType: 0 | ||
PerspectiveFOV: 0.785398185 | ||
PerspectiveFOV: 45 | ||
PerspectiveNear: 0.00999999978 | ||
PerspectiveFar: 1000 | ||
OrthographicSize: 10 | ||
OrthographicNear: -1 | ||
OrthographicFar: 1 | ||
Primary: true | ||
FixedAspectRatio: false | ||
- Entity: 13934990193259798511 | ||
FixedAspectRatio: true | ||
- Entity: 458541471201584 | ||
TransformComponent: | ||
Translation: [0, 0, 0] | ||
Translation: [0, 0, -0.5] | ||
Rotation: [0, 0, 0] | ||
Scale: [1, 1, 1] | ||
Scale: [13, 8, 1] | ||
TagComponent: | ||
Tag: Pata-Pata | ||
Tag: LoadingBackground | ||
ScriptComponent: | ||
Name: PataPata | ||
RigidBody2DComponent: | ||
BodyType: Dynamic | ||
Velocity: [0, 0] | ||
GravityScale: 1 | ||
Mass: 1 | ||
Name: Intro | ||
SpriteRendererComponent: | ||
Color: [1, 1, 1, 1] | ||
TilingFactor: 1 | ||
Texture: | ||
AssetHandle: 8451244120254815212 | ||
Coords: [0, 0] | ||
CellSize: [1, 1] | ||
SpriteSize: [512, 512] | ||
FadeComponent: | ||
Opacity: 0 | ||
FadeInSpeed: 0.4 | ||
FadeOutSpeed: 0.4 | ||
ShouldFadeIn: true | ||
ShouldFadeOut: false | ||
Repeat: true | ||
Systems: | ||
- System: AnimationSystem | ||
- System: MovingSystem | ||
- System: FadeSystem |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Type | ||
** File description: | ||
** Fade | ||
*/ | ||
|
||
#ifndef FADE_HPP_ | ||
#define FADE_HPP_ | ||
|
||
// Exodia includes | ||
#include "Exodia.hpp" | ||
|
||
namespace RType { | ||
|
||
struct FadeComponent : public Exodia::Component { | ||
float Opacity; | ||
|
||
float FadeInSpeed; | ||
float FadeOutSpeed; | ||
|
||
bool ShouldFadeIn; | ||
bool ShouldFadeOut; | ||
|
||
bool Repeat; | ||
|
||
FadeComponent(const FadeComponent &other) = default; | ||
FadeComponent(float opacity = 1.0f, float fadeInSpeed = 1.0f, float fadeOutSpeed = 1.0f) : Opacity(opacity), FadeInSpeed(fadeInSpeed), FadeOutSpeed(fadeOutSpeed), ShouldFadeIn(false), ShouldFadeOut(false), Repeat(false) {}; | ||
|
||
void Serialize(YAML::Emitter &out) override | ||
{ | ||
out << YAML::Key << "FadeComponent"; | ||
out << YAML::BeginMap; | ||
{ | ||
out << YAML::Key << "Opacity" << YAML::Value << Opacity; | ||
out << YAML::Key << "FadeInSpeed" << YAML::Value << FadeInSpeed; | ||
out << YAML::Key << "FadeOutSpeed" << YAML::Value << FadeOutSpeed; | ||
out << YAML::Key << "ShouldFadeIn" << YAML::Value << ShouldFadeIn; | ||
out << YAML::Key << "ShouldFadeOut" << YAML::Value << ShouldFadeOut; | ||
out << YAML::Key << "Repeat" << YAML::Value << Repeat; | ||
} | ||
out << YAML::EndMap; | ||
} | ||
|
||
void Deserialize(const YAML::Node &node) | ||
{ | ||
try { | ||
auto fade = node["FadeComponent"]; | ||
|
||
Opacity = fade["Opacity"].as<float>(); | ||
FadeInSpeed = fade["FadeInSpeed"].as<float>(); | ||
FadeOutSpeed = fade["FadeOutSpeed"].as<float>(); | ||
ShouldFadeIn = fade["ShouldFadeIn"].as<bool>(); | ||
ShouldFadeOut = fade["ShouldFadeOut"].as<bool>(); | ||
Repeat = fade["Repeat"].as<bool>(); | ||
} catch (YAML::BadConversion &error) { | ||
EXODIA_CORE_WARN("FadeComponent deserialization failed:\n\t{0}", error.what()); | ||
} | ||
} | ||
|
||
void DeserializeData(Exodia::Buffer data) override | ||
{ | ||
if (!data || data.Size == 0) | ||
return; | ||
try { | ||
size_t offset = 0; | ||
|
||
Memcopy(&Opacity, data.Data, sizeof(Opacity)); | ||
offset += sizeof(Opacity); | ||
|
||
Memcopy(&FadeInSpeed, data.Data + offset, sizeof(FadeInSpeed)); | ||
offset += sizeof(FadeInSpeed); | ||
|
||
Memcopy(&FadeOutSpeed, data.Data + offset, sizeof(FadeOutSpeed)); | ||
offset += sizeof(FadeOutSpeed); | ||
|
||
Memcopy(&ShouldFadeIn, data.Data + offset, sizeof(ShouldFadeIn)); | ||
offset += sizeof(ShouldFadeIn); | ||
|
||
Memcopy(&ShouldFadeOut, data.Data + offset, sizeof(ShouldFadeOut)); | ||
offset += sizeof(ShouldFadeOut); | ||
|
||
Memcopy(&Repeat, data.Data + offset, sizeof(Repeat)); | ||
} catch (std::exception &e) { | ||
EXODIA_CORE_WARN("FadeComponent deserialization failed:\n\t{0}", e.what()); | ||
} | ||
} | ||
|
||
Exodia::Buffer SerializeData() override | ||
{ | ||
try { | ||
Exodia::Buffer buffer(sizeof(float) * 3 + sizeof(bool) * 3); | ||
size_t offset = 0; | ||
|
||
std::memcpy(buffer.Data, &Opacity, sizeof(Opacity)); | ||
offset += sizeof(Opacity); | ||
|
||
std::memcpy(buffer.Data + offset, &FadeInSpeed, sizeof(FadeInSpeed)); | ||
offset += sizeof(FadeInSpeed); | ||
|
||
std::memcpy(buffer.Data + offset, &FadeOutSpeed, sizeof(FadeOutSpeed)); | ||
offset += sizeof(FadeOutSpeed); | ||
|
||
std::memcpy(buffer.Data + offset, &ShouldFadeIn, sizeof(ShouldFadeIn)); | ||
offset += sizeof(ShouldFadeIn); | ||
|
||
std::memcpy(buffer.Data + offset, &ShouldFadeOut, sizeof(ShouldFadeOut)); | ||
offset += sizeof(ShouldFadeOut); | ||
|
||
std::memcpy(buffer.Data + offset, &Repeat, sizeof(Repeat)); | ||
|
||
return buffer; | ||
} catch (std::exception &e) { | ||
EXODIA_CORE_WARN("FadeComponent serialization failed:\n\t{0}", e.what()); | ||
|
||
return Exodia::Buffer(); | ||
} | ||
} | ||
}; | ||
}; | ||
|
||
#endif /* !FADE_HPP_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Type | ||
** File description: | ||
** FadeEvent | ||
*/ | ||
|
||
#ifndef FADEEVENT_HPP_ | ||
#define FADEEVENT_HPP_ | ||
|
||
// Exodia includes | ||
#include "Exodia.hpp" | ||
|
||
namespace RType::Events { | ||
|
||
struct FadeOutEndEvent { | ||
Exodia::Entity *Entity; | ||
}; | ||
}; | ||
|
||
#endif /* !FADEEVENT_HPP_ */ |
Oops, something went wrong.