-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngineCellularAutomaton.class.js
More file actions
51 lines (35 loc) · 1014 Bytes
/
EngineCellularAutomaton.class.js
File metadata and controls
51 lines (35 loc) · 1014 Bytes
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
39
40
41
42
43
44
45
46
47
48
49
50
51
var EngineCellularAutomaton = function() {
var that = new ObjectStatic();
// size in px
that.cellSize = 4;
that.collide = function() {
/*
* alert("CeullarAutomaton");
*/
};
that.initAutomaton = function() {
// create array of grid
var grid_width = that.getWidth() / that.cellSize
var grid_height = that.getHeight() / that.cellSize;
that.grid = new Array( grid_width * grid_height );
};
that.initSensors = function() {
that.sensors = [];
var new_sensor = SensorAutomaton();
new_sensor.setHeight(that.getHeight());
new_sensor.setWidth(that.getWidth());
// TODO wrong place , this first update should be taken care of by the engine
new_sensor.update(that); // important!
that.sensors.push(new_sensor);
};
that.initFlippedSensors = function() {
that.sensors_flipped = [];
that.sensors_flipped.push(that.sensors);
};
/*
* Create new State Machine
*/
that.sm = new EngineStateMachine();
that.sm.changeState( that.Chill(), that );
return that;
};