Skip to content

Commit

Permalink
update v2.2.1
Browse files Browse the repository at this point in the history
update v2.2.1
  • Loading branch information
ajie committed Sep 10, 2017
1 parent e6840ea commit 3a17260
Show file tree
Hide file tree
Showing 60 changed files with 1,326 additions and 695 deletions.
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,33 @@ Check out examples at http://a-jie.github.io/Proton/
- Integratable into any game engine
- Veriety of behaviors
- Three kinds of emitters which can simulate many different physical effects
- The 3d version of the proton engine is here https://a-jie.github.io/three.proton/
- The __3D version__ of the proton engine is here [https://a-jie.github.io/three.proton/](https://a-jie.github.io/three.proton/)

## Usage
```javascript
var proton = new Proton();
var emitter = new Proton.Emitter();

//set Rate
emitter.rate = new Proton.Rate(Proton.getSpan(10, 20), 0.1);

//add Initialize
emitter.addInitialize(new Proton.Radius(1, 12));
emitter.addInitialize(new Proton.Life(2, 4));
emitter.addInitialize(new Proton.Velocity(3, Proton.getSpan(0, 360), 'polar'));

//add Behaviour
emitter.addBehaviour(new Proton.Color('ff0000', 'random'));
emitter.addBehaviour(new Proton.Alpha(1, 0));

//set emitter position
emitter.p.x = canvas.width / 2;
emitter.p.y = canvas.height / 2;
emitter.emit();

//add emitter to the proton
proton.addEmitter(emitter);

// add canvas renderer
var renderer = new Proton.Renderer('canvas', proton, canvas);
renderer.start();
Expand All @@ -48,12 +54,24 @@ Proton.USE_CLOCK = false or true;
```

## Building Proton
Node is a dependency, use terminal to install it with with:<br>
`git clone git://github.com/a-jie/Proton.git`<br>
Then navigate to the build directory by running:<br>
`cd ./build`<br>
Finally run the build command:<br>
`node build.js`
Node is a dependency, use terminal to install it with with:
`git clone git://github.com/a-jie/Proton.git`

Then navigate to the build directory by running:

```
cd ./build
node build.js
```

Or use npm script
```
npm run build
```

## Changelog
Detailed changes for each release are documented in the [release notes](https://github.com/a-jie/Proton/releases).


## License
Proton is released under the MIT License. http://www.opensource.org/licenses/mit-license
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Proton",
"version": "2.1.0",
"version": "2.2.1",
"homepage": "http://a-jie.github.io/Proton",
"authors": [
"a-jie <[email protected]>"
],
"description": "Proton is an easily customizable html5 particle engine including five different types of renderers.",
"main": "build/proton-2.1.0.min.js",
"main": "build/proton.min.js",
"license": "MIT",
"ignore": [
"**/.*",
Expand Down
105 changes: 48 additions & 57 deletions build/build.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,71 @@
var fs = require("fs"),
uglify = {
parser: require("./lib/parse-js.js"),
processor: require("./lib/process.js")
},

// Set the config filename
configfile = "config",
config, version, source_dir, output_full, output_min, head, filenames, foot, i,
ast, minified_source,
files = [],
numFiles = 0,
source = "";
uglify = {
parser: require("./lib/parse-js.js"),
processor: require("./lib/process.js")
},

// Set the config filename
configfile = "config",

config, version, source_dir, output_full, output_min, head, umd, filenames, foot, i,
ast, minified_source,

files = [],
numFiles = 0,

source = "";

// Get config file
console.log("Reading config file...");
config = fs.readFileSync(configfile, "UTF-8");

// Get variables from config file
version = /^version = (.*)$/m.exec(config)[1],
source_dir = /^source_dir = (.*)$/m.exec(config)[1],
output_full = /^output_full = (.*)$/m.exec(config)[1].replace("{version}", version),
output_min = /^output_min = (.*)$/m.exec(config)[1].replace("{version}", version),
head = /head\s-----\s([\s\S]*?)-----\s/g.exec(config)[1].replace("{version}", version).replace("{year}", "2011-" + (new Date()).getFullYear()),
filenames = /files\s-----\s([\s\S]*?)\s-----/g.exec(config)[1].split(/\s/);
foot = /foot\s-----\s([\s\S]*?)\s-----/g.exec(config)[1].split(/\s/);
source_dir = /^source_dir = (.*)$/m.exec(config)[1],
output_full = /^output_full = (.*)$/m.exec(config)[1].replace("{version}", version),
output_min = /^output_min = (.*)$/m.exec(config)[1].replace("{version}", version),
head = /head\s-----\s([\s\S]*?)-----\s/g.exec(config)[1].replace("{version}", version).replace("{year}", "2011-" + (new Date()).getFullYear()),
umd = /umd\s-----\s([\s\S]*?)-----\s/g.exec(config)[1],
filenames = /files\s-----\s([\s\S]*?)\s-----/g.exec(config)[1].split(/\s/);

numFiles = filenames.length;
filenames = filenames.concat(foot);

// Get all the source files
for (i = 0; i < filenames.length; i++) {
console.log("Reading file: " + filenames[i]);
// Add current file
files.push({
name: filenames[i],
content: fs.readFileSync(source_dir + filenames[i], "UTF-8")
});
console.log("Reading file: " + filenames[i]);

// Add current file
files.push({
name: filenames[i],
content: fs.readFileSync(source_dir + filenames[i], "UTF-8")
});
}

// Start the building process
console.log("Building source file...");

// Add the head code to the top of the file
source = head;

// Loop through all files and append the source
source = head + umd;
for (i = 0; i < numFiles; i++) {

// Replace the self executing anonymous functions that wrap each file
// Only the end of core will be removed, and added to the end of the new file
if (files[i].name === "core/Proton.js") {
files[i].content = files[i].content.replace(/\}(\s|)\)(\s|)\(window(\s|)\);/, "");
} else {
files[i].content = files[i].content.replace(/\(function(\s|)\((\s|)Proton,(\s|)undefined(\s|)\)(\s|)\{/, "");
files[i].content = files[i].content.replace(/\}(\s|)\)(\s|)\((\s|)Proton(\s|)\);/, "");
}

// Append the file to the full source
source += "\n" + files[i].content;

// Append the end of the core wrapper
if (i === numFiles - 1) {
source += "\n})(window);";
}
}
if (files[i].name === "core/Proton.js") {
files[i].content = files[i].content.replace(/\}(\s|)\)(\s|)\(window(\s|)\);/, "");
files[i].content = files[i].content.replace(/\(function\(window\,\sundefined\)\s\{/, "");
files[i].content = files[i].content.replace(/window\.Proton\s\=\sProton\;/, "");
} else {
files[i].content = files[i].content.replace(/\(function(\s|)\((\s|)Proton,(\s|)undefined(\s|)\)(\s|)\{/, "");
files[i].content = files[i].content.replace(/\}(\s|)\)(\s|)\((\s|)Proton(\s|)\);/, "");
}

// Loop through all foot files
for (i = numFiles; i < numFiles + foot.length; i++) {
// Append the file to the full source
source += "\n" + files[i].content;

// Append the file to the full source
source += "\n" + files[i].content;
// Append the end of the core wrapper
if (i === numFiles - 1) {
//source += "\n})(window);";
source += "\n\n return Proton;\n}));";
}
}

///console.log(umd);
// Save source to output file
fs.writeFile(output_full, source, "UTF-8");
console.log("Source file saved as: " + output_full);
Expand All @@ -89,4 +80,4 @@ minified_source = uglify.processor.gen_code(ast);

// Save minified source file
fs.writeFile(output_min, head + minified_source, "UTF-8");
console.log("Minified source file saved as: " + output_min);
console.log("Minified source file saved as: " + output_min);
24 changes: 16 additions & 8 deletions build/config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version = 2.1.0
version = 2.2.1
source_dir = ../src/
output_full = proton-{version}.js
output_min = proton-{version}.min.js
output_full = proton.js
output_min = proton.min.js

head
-----
Expand All @@ -16,6 +16,19 @@ head
*/
-----

umd
-----
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = factory();
} else {
root.Proton = factory();
}
}(this, function () {
-----

files
-----
core/Proton.js
Expand Down Expand Up @@ -73,11 +86,6 @@ zone/CircleZone.js
zone/PointZone.js
zone/RectZone.js
zone/ImageZone.js
debug/log.js
debug/Debug.js
-----

foot
-----
plus/requestAnimationFrame.js
-----
10 changes: 0 additions & 10 deletions build/proton-2.1.0.min.js

This file was deleted.

Loading

0 comments on commit 3a17260

Please sign in to comment.