Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

142 jasmine node #145

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5ae94af
Add jasmine node module
rcvink Apr 11, 2018
1939e4a
Update Age flavour
rcvink Apr 11, 2018
1b4ac7b
Initialise jasmine
rcvink Apr 11, 2018
b8e49ad
Update gait
rcvink Apr 11, 2018
b3f3ddf
Update AnimateCells for testing
rcvink Apr 11, 2018
a0c86a1
Update BirthCell listener for testing
rcvink Apr 11, 2018
baab299
Update Cell and CellFactory for testing
rcvink Apr 11, 2018
4f9767e
Update CellRepository for testing
rcvink Apr 11, 2018
72efbfe
Remove empty spec
rcvink Apr 11, 2018
2877c8d
Update DecoratedEngine for testing
rcvink Apr 11, 2018
f697e18
Update DecoratedRender for testing
rcvink Apr 11, 2018
7b29e0c
Update DecoratedRunner for testing
rcvink Apr 11, 2018
4f72286
Update EventController for testing
rcvink Apr 11, 2018
0009c14
Update FadeCells for testing
rcvink Apr 11, 2018
a4488b1
Update GrowCells for testing
rcvink Apr 11, 2018
60fdb20
Update KillCells for testing
rcvink Apr 11, 2018
367eda3
Update PositionInheritor for testing
rcvink Apr 11, 2018
bee5e59
Update RgbFormatter for testing
rcvink Apr 11, 2018
2f3a281
Update ShapeInheritor for testing
rcvink Apr 11, 2018
5d8f82e
Update Simulation for testing
rcvink Apr 11, 2018
b565d70
Update module pattern
rcvink Apr 11, 2018
09923dd
Add browserify for bundling
rcvink Apr 11, 2018
5588ae8
Ignore bundled output
rcvink Apr 11, 2018
f0218fc
Relocate jQuery to entry point
rcvink Apr 11, 2018
100ffc6
Remove jQuery-only file - code moved to dawn.js
rcvink Apr 11, 2018
71bce07
Remove module imports, add bundled file
rcvink Apr 11, 2018
787a2c0
Update getting started instructions
rcvink Apr 11, 2018
4949287
Exchange var for const
rcvink Apr 11, 2018
175e4ad
Update module pattern
rcvink Apr 11, 2018
f935209
Remove standalone jasmine
rcvink Apr 11, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Bundled entry point
bundle.js

# Logs
logs
*.log
Expand Down Expand Up @@ -56,4 +59,3 @@ typings/

# dotenv environment variables file
.env

29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ _dawn_ is a procedurally generated socio-genetic simulation. What does that mean
- Procedurally generated
- None of the outcomes are predefined; they are based purely on the results of the random algorithms.
- Socio-genetic simulation
- _dawn_ is inspired by Conway's Game of Life and Spore (also No Man's Sky regarding the procedural generation).
- _dawn_ is inspired by Conway's Game of Life, Spore and No Man's Sky.
- The user observes 'cells' interacting with each other in an environment; living, breeding, inheriting properties, and eventually dying.

## getting started
Expand All @@ -21,8 +21,9 @@ _dawn_ is a procedurally generated socio-genetic simulation. What does that mean
The lengthier way:
* `git clone` this repository.
* `cd dawn`.
* `npm install` to install dependencies for development.
* `open specRunner.html` (OSX) or `xdg-open specRunner.html` (Linux) to run unit tests.
* `npm install` to install dependencies.
* `npm run build` to bundle dependencies.
* `npm test` to run unit tests.
* `open dawn.html` (OSX) or `xdg-open dawn.html` (Linux) to observe _dawn_

## process
Expand All @@ -37,7 +38,7 @@ The lengthier way:

## user stories

### mvp/v1
### mvp
```
as an observer
because I am interested in life simulations
Expand Down Expand Up @@ -97,18 +98,12 @@ i want there to be a sound on creation
```


## web stack
* [Node.js](https://nodejs.org/en/).
* [NPM](https://www.npmjs.com/) for dependencies.
* [Matter.js](http://brm.io/matter-js/) for physics, with the following plugin:
* [matter-attractors](https://github.com/liabru/matter-attractors)
## stack
* [NPM](https://www.npmjs.com/) for package management.
* [Matter-js](http://brm.io/matter-js/) for physics.
* [p5-sound](https://p5js.org/reference/#/libraries/p5.sound) for sound.
* [Jasmine](https://jasmine.github.io/) for unit and integration testing.
<!-- * [webpack](https://webpack.js.org/) for bundling on deployment. -->
* [Jasmine](https://jasmine.github.io/) for unit testing.
* [Browserify](http://browserify.org/) for bundling.

# Points for development:
* mutation in shape
* update code to ES6
* improved deployment (e.g. using Webpack)

for more points for development, you can check out our [issues](https://github.com/jenniferemshepherd/dawn/issues).
# points for development
Check out our [issues](https://github.com/jenniferemshepherd/dawn/issues).
65 changes: 0 additions & 65 deletions SpecRunner.html

This file was deleted.

24 changes: 11 additions & 13 deletions controllers/event-controller.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
'use strict';

(function(exports) {
const Matter = require('../node_modules/matter-js/build/matter');

function EventController(decoratedEngine, eventsModule = Matter.Events) {
this._decoratedEngine = decoratedEngine;
this._eventsModule = eventsModule;
}
function EventController(decoratedEngine, eventsModule = Matter.Events) {
this._decoratedEngine = decoratedEngine;
this._eventsModule = eventsModule;
}

EventController.prototype.register = function(eventString, listener) {
this._eventsModule.on(this._decoratedEngine.matterEngine(), eventString, function(event) {
listener.action(event);
});
};
EventController.prototype.register = function(eventString, listener) {
this._eventsModule.on(this._decoratedEngine.matterEngine(), eventString, function(event) {
listener.action(event);
});
};

exports.EventController = EventController;

})(this);
module.exports = EventController;
122 changes: 60 additions & 62 deletions controllers/simulation.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,62 @@
'use strict';

(function(exports) {

function Simulation(
decoratedEngine,
decoratedRender,
worldModule = Matter.World,
engineModule = Matter.Engine,
renderModule = Matter.Render
) {
this._decoratedEngine = decoratedEngine;
this._decoratedRender = decoratedRender;
this._worldModule = worldModule;
this._engineModule = engineModule;
this._renderModule = renderModule;
}

Simulation.prototype.decoratedEngine = function() {
return this._decoratedEngine;
};

Simulation.prototype.decoratedRender = function() {
return this._decoratedRender;
};

Simulation.prototype.world = function() {
return this._decoratedEngine.matterEngine().world;
};

Simulation.prototype.addToWorld = function (cell) {
this._worldModule.add(this.world(), cell.body());
};

Simulation.prototype.removeFromWorld = function(cell) {
this._worldModule.remove(this.world(), cell.body());
};

Simulation.prototype.setup = function() {
this.addWalls();
this._decoratedEngine.disableGravity();
};

Simulation.prototype.addWalls = function() {
this._worldModule.add(this.world(), [
Matter.Bodies.rectangle(400, -50, 1200, 100, { isStatic: true, label: 'Boundary' }),
Matter.Bodies.rectangle(850, 300, 100, 600, { isStatic: true, label: 'Boundary' }),
Matter.Bodies.rectangle(400, 650, 1200, 100, { isStatic: true, label: 'Boundary' }),
Matter.Bodies.rectangle(-50, 300, 100, 600, { isStatic: true, label: 'Boundary' })
]);
// top, right, bottom, left
};

Simulation.prototype.runRender = function() {
this._renderModule.run(this._decoratedRender.matterRender());
};

Simulation.prototype.emptyWorld = function() {
this.world().bodies = []
};

exports.Simulation = Simulation;

})(this);
const Matter = require('../node_modules/matter-js/build/matter');

function Simulation(
decoratedEngine,
decoratedRender,
worldModule = Matter.World,
engineModule = Matter.Engine,
renderModule = Matter.Render
) {
this._decoratedEngine = decoratedEngine;
this._decoratedRender = decoratedRender;
this._worldModule = worldModule;
this._engineModule = engineModule;
this._renderModule = renderModule;
}

Simulation.prototype.decoratedEngine = function() {
return this._decoratedEngine;
};

Simulation.prototype.decoratedRender = function() {
return this._decoratedRender;
};

Simulation.prototype.world = function() {
return this._decoratedEngine.matterEngine().world;
};

Simulation.prototype.addToWorld = function (cell) {
this._worldModule.add(this.world(), cell.body());
};

Simulation.prototype.removeFromWorld = function(cell) {
this._worldModule.remove(this.world(), cell.body());
};

Simulation.prototype.setup = function() {
this.addWalls();
this._decoratedEngine.disableGravity();
};

Simulation.prototype.addWalls = function() {
this._worldModule.add(this.world(), [
Matter.Bodies.rectangle(400, -50, 1200, 100, { isStatic: true, label: 'Boundary' }),
Matter.Bodies.rectangle(850, 300, 100, 600, { isStatic: true, label: 'Boundary' }),
Matter.Bodies.rectangle(400, 650, 1200, 100, { isStatic: true, label: 'Boundary' }),
Matter.Bodies.rectangle(-50, 300, 100, 600, { isStatic: true, label: 'Boundary' })
]);
// top, right, bottom, left
};

Simulation.prototype.runRender = function() {
this._renderModule.run(this._decoratedRender.matterRender());
};

Simulation.prototype.emptyWorld = function() {
this.world().bodies = []
};

module.exports = Simulation;
28 changes: 2 additions & 26 deletions dawn.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<title>dawn</title>
<link href="./public/dawn_stylesheet.css" type="text/css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Sacramento|Ubuntu:300,400" rel="stylesheet">
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="./public/dawn-jquery.js"></script>
</head>
<body>
<header>
Expand All @@ -24,30 +22,8 @@ <h1>dawn</h1>
<script src="./node_modules/matter-js/build/matter.js"></script>
<script src="./node_modules/p5/lib/p5.js"></script>
<script src="./node_modules/p5/lib/addons/p5.sound.js"></script>

<script src="./controllers/event-controller.js"></script>
<script src="./controllers/simulation.js"></script>
<script src="./decorators/decorated-engine.js"></script>
<script src="./decorators/decorated-render.js"></script>
<script src="./decorators/decorated-runner.js"></script>
<script src="./inheritors/colour-inheritor.js"></script>
<script src="./inheritors/position-inheritor.js"></script>
<script src="./inheritors/shape-inheritor.js"></script>
<script src="./listeners/animate-cells.js"></script>
<script src="./listeners/birth-cell.js"></script>
<script src="./listeners/fade-cells.js"></script>
<script src="./listeners/grow-cells.js"></script>
<script src="./listeners/kill-cells.js"></script>
<script src="./models/cell.js"></script>
<script src="./models/cell-factory.js"></script>
<script src="./models/cell-repository.js"></script>
<script src="./properties/age.js"></script>
<script src="./properties/gait.js"></script>
<script src="./properties/voice.js"></script>
<script src="./services/mutator.js"></script>
<script src="./services/rgb-formatter.js"></script>

<script src="./dawn.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="bundle.js"></script>

<div class="buttons" style="text-align:center;">
<button id="start" type="button">start</button>
Expand Down
Loading