Add Variable Color Switch for VariableTimestep
This commit is contained in:
parent
d6c6abf3f6
commit
1c3264f33c
|
@ -21,11 +21,12 @@ class Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
// In-World Logic Updates
|
// In-World Logic Updates
|
||||||
void update([num dt]) {
|
void update([num speed]) {
|
||||||
|
print(speed);
|
||||||
Point next = isRandom ? nextPosRandom() : nextPosOrdered(_curPos);
|
Point next = isRandom ? nextPosRandom() : nextPosOrdered(_curPos);
|
||||||
if (_curPos.x < 0) _curPos = Point(0, _curPos.y);
|
if (_curPos.x < 0) _curPos = Point(0, _curPos.y);
|
||||||
Color newColor = isRandom ? randomColor() : nextColor(
|
Color newColor = isRandom ? randomColor() : nextColor(
|
||||||
grid[_curPos.y][_curPos.x]);
|
grid[_curPos.y][_curPos.x], step: speed ?? 1);
|
||||||
grid[next.y][next.x] = newColor;
|
grid[next.y][next.x] = newColor;
|
||||||
_curPos = next;
|
_curPos = next;
|
||||||
}
|
}
|
||||||
|
@ -47,14 +48,14 @@ class Game {
|
||||||
return new Color(rng.nextInt(max), rng.nextInt(max), rng.nextInt(max));
|
return new Color(rng.nextInt(max), rng.nextInt(max), rng.nextInt(max));
|
||||||
}
|
}
|
||||||
|
|
||||||
Color nextColor(Color col) {
|
Color nextColor(Color col, {int step = 1}) {
|
||||||
if (col.r > 254 || col.g > 254 || col.b > 254) return randomColor(100);
|
if (col.r > 254 || col.g > 254 || col.b > 254) return randomColor(100);
|
||||||
if (col.r > col.g && col.r > col.b)
|
if (col.r > col.g && col.r > col.b)
|
||||||
return Color(col.r + 1, col.g, col.b);
|
return Color(col.r + step, col.g, col.b);
|
||||||
else if (col.b > col.r && col.b > col.g)
|
else if (col.b > col.r && col.b > col.g)
|
||||||
return Color(col.r, col.g, col.b + 1);
|
return Color(col.r, col.g, col.b + step);
|
||||||
else
|
else
|
||||||
return Color(col.r, col.g + 1, col.b);
|
return Color(col.r, col.g + step, col.b);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render Pipeline
|
// Render Pipeline
|
||||||
|
|
Loading…
Reference in New Issue