Move Render Methods into SimulationService
This commit is contained in:
parent
58971016da
commit
45e8f01acb
4 changed files with 13 additions and 12 deletions
|
@ -49,6 +49,6 @@ class ConfigurationComponent {
|
||||||
ConfigurationComponent(this.engine, this.sim);
|
ConfigurationComponent(this.engine, this.sim);
|
||||||
|
|
||||||
void onEdgesClicked() {
|
void onEdgesClicked() {
|
||||||
engine.toggleGrid();
|
sim.toggleGrid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:html' as html;
|
||||||
|
|
||||||
import 'package:angular/angular.dart';
|
import 'package:angular/angular.dart';
|
||||||
import 'package:rules_of_living/service/engine_service.dart';
|
import 'package:rules_of_living/service/engine_service.dart';
|
||||||
|
import 'package:rules_of_living/service/simulation_service.dart';
|
||||||
|
|
||||||
@Component(
|
@Component(
|
||||||
selector: 'gol-simulation',
|
selector: 'gol-simulation',
|
||||||
|
@ -11,6 +12,7 @@ import 'package:rules_of_living/service/engine_service.dart';
|
||||||
)
|
)
|
||||||
class SimulationComponent implements OnInit {
|
class SimulationComponent implements OnInit {
|
||||||
final EngineService engine;
|
final EngineService engine;
|
||||||
|
final SimulationService sim;
|
||||||
|
|
||||||
SimulationComponent(this.engine);
|
SimulationComponent(this.engine);
|
||||||
|
|
||||||
|
@ -29,6 +31,6 @@ class SimulationComponent implements OnInit {
|
||||||
|
|
||||||
the canvas did not load correctly :(
|
the canvas did not load correctly :(
|
||||||
''', canvas.width / 2 - 50, canvas.height / 2);
|
''', canvas.width / 2 - 50, canvas.height / 2);
|
||||||
engine.canvas = canvas;
|
sim.canvas = canvas;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import 'dart:html' as html;
|
|
||||||
|
|
||||||
import 'package:rules_of_living/src/Engine.dart';
|
import 'package:rules_of_living/src/Engine.dart';
|
||||||
|
|
||||||
class EngineService {
|
class EngineService {
|
||||||
|
@ -43,14 +41,6 @@ class EngineService {
|
||||||
int get simSpeed => engine.stepsPerSecond;
|
int get simSpeed => engine.stepsPerSecond;
|
||||||
void set simSpeed(int val) => engine.stepsPerSecond = val;
|
void set simSpeed(int val) => engine.stepsPerSecond = val;
|
||||||
|
|
||||||
//TODO split into RenderService when rendering is decoupled from engine.
|
|
||||||
html.CanvasElement get canvas => engine.canvas;
|
|
||||||
void set canvas(html.CanvasElement canvas) => engine.canvas = canvas;
|
|
||||||
|
|
||||||
void toggleGrid() {
|
|
||||||
engine.toggleEdgeRendering();
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
engine.reset();
|
engine.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'dart:html' as html;
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:rules_of_living/service/engine_service.dart';
|
import 'package:rules_of_living/service/engine_service.dart';
|
||||||
|
@ -24,4 +25,12 @@ class SimulationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Point<int> get gridSize => _engine.engine.gridSize;
|
Point<int> get gridSize => _engine.engine.gridSize;
|
||||||
|
|
||||||
|
//TODO split into RenderService when rendering is decoupled from engine.
|
||||||
|
html.CanvasElement get canvas => _engine.engine.canvas;
|
||||||
|
void set canvas(html.CanvasElement canvas) => _engine.engine.canvas = canvas;
|
||||||
|
|
||||||
|
void toggleGrid() {
|
||||||
|
_engine.engine.toggleEdgeRendering();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue