cellular-automata/lib/service/configuration_service.dart

38 lines
875 B
Dart
Raw Normal View History

2018-08-27 17:55:30 +00:00
import 'dart:math';
import 'package:rules_of_living/service/engine_service.dart';
class ConfigurationService {
final EngineService engineService;
bool showGrid;
int _simSpeed;
2018-08-25 14:41:11 +00:00
/// Simulation Speed
///
/// Sets the number of updates the simulation takes per second. Can range from
/// 1 to arbitrarily high numbers (though setting it too high can potentially
/// make the app brittle).
int get simSpeed => _simSpeed;
void set simSpeed(int val) {
_simSpeed = val;
engineService.engine.stepsPerSecond = simSpeed;
}
ConfigurationService(this.engineService) {
showGrid = false;
simSpeed = 5;
}
void toggleGrid() {
showGrid = !showGrid;
}
2018-08-27 17:55:30 +00:00
void setGridSize({int x, int y}) {
x = x ?? engineService.engine.gridSize.x;
y = y ?? engineService.engine.gridSize.y;
engineService.engine.gridSize = Point(x, y);
}
}