Skip to content

Preliminary effort to add a full screen flash - #48

Merged
huboyuan2 merged 16 commits into
mainfrom
taro/screen-flash
Jul 11, 2026
Merged

Preliminary effort to add a full screen flash#48
huboyuan2 merged 16 commits into
mainfrom
taro/screen-flash

Conversation

@japtar10101

@japtar10101 japtar10101 commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

Here's my preliminary, compiling effort to add in a full screen flash, using SpriteFader component. This adds a ScreenFlashSystem to allow global access to a SpriteFader instance.

Completely untested. I'm working on a new PR to actually test what I've added in, here, but wanted to keep the PR small for the time being.

@japtar10101
japtar10101 requested a review from nbekris June 21, 2026 01:25
@japtar10101 japtar10101 self-assigned this Jun 21, 2026

AudioSource::AudioSource(const AudioSource &other)
: Cloneable<Component, AudioSource>{}
: Cloneable<Component, AudioSource>{other}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated bug-fix on AudioSource copy constructor.


MusicFader::MusicFader(const MusicFader &other)
: Cloneable<Component, MusicFader>{}
: Cloneable<Component, MusicFader>{other}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated bug-fix on MusicFader copy constructor.

class CheatSystem : public ICheatSystem {
public:
CheatSystem(const std::initializer_list<std::string_view> &scenePaths);
CheatSystem(std::initializer_list<std::string_view> scenePaths);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated bug-fix on CheatSystem list constructor.

Comment thread Source/Stream.h
#include "Systems/Logging/ILoggingSystem.h"
#include "Utils.h"

using json = nlohmann::json;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated refactor of removing using from Stream

Comment thread Source/TweenCurve.h
virtual ~TweenCurve() = default;

template<class T>
void Set(float startValue, T begin, T end);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defining set to allow re-using an existing TweenCurve instance to change its internal member values.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial infrastructure for a global full-screen flash effect by reusing the existing SpriteFader component and introducing a ScreenFlashSystem that locates and drives a dedicated ScreenFlash entity in scenes.

Changes:

  • Extends TweenCurve and SpriteFader to support curve-driven fades and programmatic triggering.
  • Introduces IScreenFlashSystem/ScreenFlashSystem and registers it in GameRass/Main.cpp.
  • Adds a ScreenFlash entity asset and wires it into multiple scenes.

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
Source/TweenCurve.h Adds curve setter helpers and query APIs used by fade logic.
Source/TweenCurve.cpp Fixes keyframe search ordering and adds duration/ending-value helpers.
Source/Systems/Cheat/CheatSystem.h Adjusts ctor signature for initializer_list handling.
Source/Systems/Cheat/CheatSystem.cpp Matches ctor signature change in implementation.
Source/Stream.h Removes json alias usage in header, uses fully-qualified nlohmann::json.
Source/Components/SpriteFader.h Expands SpriteFader to support curve-based fades and a Show() API.
Source/Components/SpriteFader.cpp Implements curve-driven fade behavior, caching, and auto-disable support.
Source/Components/MusicFader.cpp Fixes clone/copy construction to copy base state.
Source/Components/AudioSource.cpp Fixes clone/copy construction to copy base state.
Source/Component.h Changes SetEnabled signature to virtual void.
GameRass/Systems/ScreenFlash/ScreenFlashSystem.h Declares system that finds a SpriteFader for screen flashing.
GameRass/Systems/ScreenFlash/ScreenFlashSystem.cpp Implements scene bind/unbind and Show() forwarding to SpriteFader.
GameRass/Systems/ScreenFlash/IScreenFlashSystem.h Adds global system interface for triggering flashes.
GameRass/Main.cpp Registers ScreenFlashSystem as a global system.
GameRass/Assets/Scenes/VerticalSlicePuzzle.json Adds ScreenFlash entity to scene contents.
GameRass/Assets/Scenes/VerticalSlicePlat.json Adds ScreenFlash entity to scene contents.
GameRass/Assets/Scenes/Level4Puzzle.json Adds ScreenFlash entity to scene contents.
GameRass/Assets/Scenes/Level2Puzzle.json Adds ScreenFlash entity to scene contents.
GameRass/Assets/Scenes/Level2Plat.json Adds ScreenFlash entity to scene contents.
GameRass/Assets/Scenes/Level1Puzzle.json Adds ScreenFlash entity to scene contents.
GameRass/Assets/Scenes/Level1Plat.json Adds ScreenFlash entity to scene contents.
GameRass/Assets/Entities/ScreenFlash.json Introduces the flash overlay entity with Sprite + SpriteFader setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Source/TweenCurve.h
Comment on lines +80 to +87
// Empty key frames
this->keyFrames.clear();
this->keyFrames.reserve(keyFrames.size());

// Populate it with the setter
std::for_each(begin, end, [this] (const KeyFrame &key) {
this->keyFrames.emplace_back(key);
});
Comment thread Source/TweenCurve.cpp
Comment on lines +129 to +142
float TweenCurve::GetTotalDuration() const {
// Check if there are any keyframes
float toReturn = 0.0f;
if(keyFrames.size() == 0) {
// If not, return 0
return toReturn;
}

// Sum the times of all keyframes
for(const KeyFrame &key : keyFrames) {
toReturn += key.time;
}
return toReturn;
}
Comment thread Source/Component.h
Comment on lines +54 to 56
inline virtual void SetEnabled(bool flag) {
isEnabled = flag;
}
// Author(s): main Steven Yacoub, secondary Taro Omiya, Niko Bekris
// Course: GAM541
// Project: RASS
// Purpose: System providing custom memory allocation.
onSceneLoaded{this, &ScreenFlashSystem::OnSceneLoaded}
, onSceneUnloaded{this, &ScreenFlashSystem::OnSceneUnloaded} {}

ScreenFlashSystem::~ScreenFlashSystem() {}
Comment on lines +51 to +60
void ScreenFlashSystem::Shutdown() {
if(!IGlobalEventsSystem::Get()) {
LOG_ERROR("{}: failed to initialize: no global events system", NameClass());
return;
}

// Unbind to scene load/unload events
IGlobalEventsSystem::Get()->unbind(SceneChange::AfterInitialize, &onSceneLoaded);
IGlobalEventsSystem::Get()->unbind(SceneChange::BeforeShutdown, &onSceneUnloaded);
}
@huboyuan2
huboyuan2 merged commit 19f4a4a into main Jul 11, 2026
1 check passed
@japtar10101
japtar10101 deleted the taro/screen-flash branch July 16, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants