parent
a92b864dfa
commit
b6919cff6b
3 changed files with 12 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
|||
import 'dart:html' as html;
|
||||
|
||||
import 'package:angular/angular.dart';
|
||||
import 'package:rules_of_living/service/control_service.dart';
|
||||
import 'package:rules_of_living/service/configuration_service.dart';
|
||||
|
||||
@Component(
|
||||
selector: 'gol-simulation',
|
||||
|
@ -10,9 +10,9 @@ import 'package:rules_of_living/service/control_service.dart';
|
|||
providers: [],
|
||||
)
|
||||
class SimulationComponent implements OnInit {
|
||||
final ControlService ctrl;
|
||||
final ConfigurationService config;
|
||||
|
||||
SimulationComponent(this.ctrl);
|
||||
SimulationComponent(this.config);
|
||||
|
||||
@override
|
||||
void ngOnInit() {
|
||||
|
@ -29,6 +29,6 @@ class SimulationComponent implements OnInit {
|
|||
|
||||
the canvas did not load correctly :(
|
||||
''', canvas.width / 2 - 50, canvas.height / 2);
|
||||
ctrl.canvas = canvas;
|
||||
config.canvas = canvas;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:html' as html;
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:rules_of_living/service/engine_service.dart';
|
||||
|
@ -9,6 +10,11 @@ class ConfigurationService {
|
|||
|
||||
int _simSpeed;
|
||||
|
||||
ConfigurationService(this._es) {
|
||||
showGrid = false;
|
||||
simSpeed = 5;
|
||||
}
|
||||
|
||||
/// Simulation Speed
|
||||
///
|
||||
/// Sets the number of updates the simulation takes per second. Can range from
|
||||
|
@ -20,10 +26,8 @@ class ConfigurationService {
|
|||
_es.engine.stepsPerSecond = simSpeed;
|
||||
}
|
||||
|
||||
ConfigurationService(this._es) {
|
||||
showGrid = false;
|
||||
simSpeed = 5;
|
||||
}
|
||||
void set canvas(html.CanvasElement canvas) => _es.engine.canvas = canvas;
|
||||
html.CanvasElement get canvas => _es.engine.canvas;
|
||||
|
||||
void toggleGrid() {
|
||||
showGrid = !showGrid;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import 'dart:html' as html;
|
||||
|
||||
import 'package:rules_of_living/service/engine_service.dart';
|
||||
|
||||
class ControlService {
|
||||
|
@ -7,9 +5,6 @@ class ControlService {
|
|||
|
||||
ControlService(this._es);
|
||||
|
||||
void set canvas(html.CanvasElement canvas) => _es.engine.canvas = canvas;
|
||||
html.CanvasElement get canvas => _es.engine.canvas;
|
||||
|
||||
void run() {
|
||||
_es.engine.running = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue