Make Engine Gridsize configurable
This commit is contained in:
parent
8a6538aa5e
commit
dd18fc3bc7
1 changed files with 9 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:html' as html;
|
import 'dart:html' as html;
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:rules_of_living/src/Grid.dart';
|
import 'package:rules_of_living/src/Grid.dart';
|
||||||
|
|
||||||
|
@ -28,9 +29,10 @@ class Engine {
|
||||||
// ms stuck in updateloop after which game will declare itself unresponsive
|
// ms stuck in updateloop after which game will declare itself unresponsive
|
||||||
final int SAFETY_TIMEOUT = 2000;
|
final int SAFETY_TIMEOUT = 2000;
|
||||||
|
|
||||||
// Grid Size TODO add as configurable option
|
/// Grid Size
|
||||||
static final GRID_X = 100;
|
///
|
||||||
static final GRID_Y = 100;
|
/// Number of cells on x coordinate and y coordinate. Can be set individually.
|
||||||
|
Point gridSize = Point<int>(100, 100);
|
||||||
|
|
||||||
num _updateLag = 0.0;
|
num _updateLag = 0.0;
|
||||||
num _drawLag = 0.0;
|
num _drawLag = 0.0;
|
||||||
|
@ -41,10 +43,12 @@ 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 = new Grid(GRID_X, GRID_Y);
|
Grid _grid;
|
||||||
bool running = false;
|
bool running = false;
|
||||||
|
|
||||||
Engine([this.canvas]) {
|
Engine([this.canvas]) {
|
||||||
|
_grid = Grid(gridSize.x, gridSize.y);
|
||||||
|
|
||||||
_elapsed.start();
|
_elapsed.start();
|
||||||
_grid.addPattern(amount: 15, dispersal: 5);
|
_grid.addPattern(amount: 15, dispersal: 5);
|
||||||
html.window.animationFrame.then(animFrame);
|
html.window.animationFrame.then(animFrame);
|
||||||
|
@ -61,7 +65,7 @@ class Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
_grid = new Grid(GRID_X, GRID_Y);
|
_grid = new Grid(gridSize.x, gridSize.y);
|
||||||
running = false;
|
running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue