Skip to content

Commit

Permalink
Only swap colours if more than 300ms has passed since last swap
Browse files Browse the repository at this point in the history
prevents quick flashing which could possibly cause epilepsy?
  • Loading branch information
opcon committed Sep 26, 2016
1 parent 10d85b7 commit 6b69098
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/TurntNinja/Game/StageGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class StageGeometry : IDisposable
private double _extraHue = 0.0;
private double _hueWobbleAmount = 30;
private bool _swapColours = false;
private double _lastSwapTime = -10.0f;
const double MIN_COLOUR_SWAP_TIME = 0.3f;
private HUSLColor _baseColour;
public Stage ParentStage;

Expand Down Expand Up @@ -302,14 +304,18 @@ public void UpdateColours(double time)
}

//_baseColour.H += time*50f*(!OutOfBeats ? BeatFrequencies[_beats.Index] : 1);
bool swapColours = false;

// Only update colours if more than 3 beats have passed since last time
if (CurrentOnset - _previousBeat < 3) return;

_previousBeat = CurrentOnset;
_extraHue = ((_random.NextDouble() > 0.5) ? -1 : 1) * (90 + (_hueWobbleAmount * _random.NextDouble() - _hueWobbleAmount / 2));
_swapColours = (_random.NextDouble() > 0.95) ? !_swapColours : _swapColours;
double swapChance = CurrentColourMode == ColourMode.BlackAndWhite ? 0.9 : 0.95;
if ((_elapsedTime - _lastSwapTime) > MIN_COLOUR_SWAP_TIME && _random.NextDouble() > swapChance)
{
_swapColours = !_swapColours;
_lastSwapTime = _elapsedTime;
}

_baseColour.H = _initialHue + (CurrentOnset) * 5;
_baseColour.L = ColourModifiers.baseLightness;
Expand Down

0 comments on commit 6b69098

Please sign in to comment.