Rename Grid to Simulation
in order to craft an actual grid data structure
This commit is contained in:
parent
7db2e73f53
commit
0c487f3427
2 changed files with 7 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
||||||
import 'dart:html' as html;
|
import 'dart:html' as html;
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:rules_of_living/src/Grid.dart';
|
import 'package:rules_of_living/src/Simulation.dart';
|
||||||
|
|
||||||
class Engine {
|
class Engine {
|
||||||
// Elapsed Time Counter - useful for Safety Timeout
|
// Elapsed Time Counter - useful for Safety Timeout
|
||||||
|
@ -36,7 +36,7 @@ class Engine {
|
||||||
void set gridSize(Point<int> value) {
|
void set gridSize(Point<int> value) {
|
||||||
if (value.x <= 0 || value.y <= 0)
|
if (value.x <= 0 || value.y <= 0)
|
||||||
throw ArgumentError("grid size must not be smaller than 1");
|
throw ArgumentError("grid size must not be smaller than 1");
|
||||||
_grid = Grid(value.x, value.y);
|
_grid = Simulation(value.x, value.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
num _updateLag = 0.0;
|
num _updateLag = 0.0;
|
||||||
|
@ -48,11 +48,11 @@ class Engine {
|
||||||
/// be used if no canvas was defined at engine creation and it should be
|
/// be used if no canvas was defined at engine creation and it should be
|
||||||
/// rendered later.
|
/// rendered later.
|
||||||
html.CanvasElement canvas;
|
html.CanvasElement canvas;
|
||||||
Grid _grid;
|
Simulation _grid;
|
||||||
bool running = false;
|
bool running = false;
|
||||||
|
|
||||||
Engine([x = 100, y = 100, this.canvas]) {
|
Engine([x = 100, y = 100, this.canvas]) {
|
||||||
_grid = Grid(x, y);
|
_grid = Simulation(x, y);
|
||||||
|
|
||||||
_elapsed.start();
|
_elapsed.start();
|
||||||
_grid.addPattern(amount: 15, dispersal: 5);
|
_grid.addPattern(amount: 15, dispersal: 5);
|
||||||
|
@ -70,7 +70,7 @@ class Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
_grid = new Grid(gridSize.x, gridSize.y);
|
_grid = new Simulation(gridSize.x, gridSize.y);
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import 'package:rules_of_living/src/Rule.dart';
|
||||||
|
|
||||||
enum CellPattern { SpaceShip, Blinker }
|
enum CellPattern { SpaceShip, Blinker }
|
||||||
|
|
||||||
class Grid {
|
class Simulation {
|
||||||
final int w;
|
final int w;
|
||||||
final int h;
|
final int h;
|
||||||
final List<List<Cell>> map;
|
final List<List<Cell>> map;
|
||||||
|
@ -21,7 +21,7 @@ class Grid {
|
||||||
int _dispersal;
|
int _dispersal;
|
||||||
CellPattern _pattern;
|
CellPattern _pattern;
|
||||||
|
|
||||||
Grid(int w, int h)
|
Simulation(int w, int h)
|
||||||
: this.w = w,
|
: this.w = w,
|
||||||
this.h = h,
|
this.h = h,
|
||||||
this.map = new List() {
|
this.map = new List() {
|
Loading…
Reference in a new issue