-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdawn.js
More file actions
38 lines (31 loc) · 1.43 KB
/
dawn.js
File metadata and controls
38 lines (31 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// insantiate decorators
var decoratedEngine = new DecoratedEngine();
var decoratedRender = new DecoratedRender();
var decoratedRunner = new DecoratedRunner();
// instantiate controllers
var eventController = new EventController(decoratedEngine);
var simulation = new Simulation(decoratedEngine, decoratedRender);
// instantiate services
var rgbFormatter = new RgbFormatter();
var mutator = new Mutator();
// instantiate inheritors
var colourInheritor = new ColourInheritor(rgbFormatter, mutator);
var positionInheritor = new PositionInheritor();
var shapeInheritor = new ShapeInheritor();
// instantiate factories and repositories
var cellRepository = new CellRepository();
var cellFactory = new CellFactory(simulation, cellRepository, positionInheritor, shapeInheritor, colourInheritor);
// instantiate listeners
var animateCells = new AnimateCells(cellRepository);
var birthCell = new BirthCell(cellFactory, cellRepository);
var fadeCells = new FadeCells(cellRepository);
var growCells = new GrowCells(cellRepository);
var killCells = new KillCells(cellRepository, simulation);
// create render
var render = decoratedRender.createRender(decoratedEngine.matterEngine());
// register listeners
eventController.register('afterUpdate', animateCells);
eventController.register('collisionStart', birthCell);
eventController.register('afterUpdate', fadeCells);
eventController.register('afterUpdate', growCells);
eventController.register('afterUpdate', killCells);