Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
daishihmr committed Nov 5, 2016
1 parent 5a33110 commit 911893e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 31 deletions.
45 changes: 21 additions & 24 deletions README.md
@@ -1,16 +1,7 @@
bulletml.js
===========

弾幕記述言語BulletMLをJavaScriptで利用するためのユーティリティ集。

enchant.js用プラグイン、tmlib.js用プラグインもあるよ。

Modules
=======

- bulletml.js ... BulletMLをJavaScriptで読み込んでいろいろやるためのライブラリ。
- bulletml.enchant.js ... enchant.jsでBulletMLを利用するためのプラグイン。
- tmlib.bulletml.js ... tmlib.jsでBulletMLを利用するためのプラグイン。
JavaScript BulletML library.

Download
========
Expand Down Expand Up @@ -49,7 +40,7 @@ DEMO
This library is used by ...
============================

<a href="http://tmshooter.net/"><img width="140" src="http://tmshooter.net/tmshooter/glshooter2.png"/></a>
<a href="http://tmshooter.net/"><img width="140" src="https://raw.githubusercontent.com/daishihmr/glshooter2/master/glshooter2.png"/></a>
<a href="http://9leap.net/games/2877/"><img src="http://9leap.net/screenshots//140x140/2877_140"/></a>
<a href="http://9leap.net/games/2995/"><img src="http://9leap.net/screenshots//140x140/2995_140"/></a>

Expand All @@ -58,27 +49,34 @@ This library is used by ...
FEATURES
========

Parser
Runner
------

従来型の、XMLで記述されたBulletMLをロードして実行することができます

~~~~javascript
// enchant.js
var game = new Game();
game.preload("bulletml.xml");
game.onload = function() {
var attackPattern = game.assets["bulletml.xml");
// setup
var bml = bulletml.buildXML("<bulletml>...</bulletml>");
var runner = bml.createRunner({
target: playerShip, // enemy's attack target (has 'x' and 'y' property)
createNewBullet: function(bulletRunner) { // function to be called when new bullet has been fired
var bullet = new Bullet();
bullet.runner = bulletRunner;
scene.addChild(bullet);
}
});
runner.x = enemy.x;
runner.y = enemy.y;

enemy.update = function() {
// every frame
runner.x = this.x;
runner.y = this.y;
runner.update();
};
game.start();
~~~~

DSL
---

JavaScriptによるDSLで弾幕定義を記述することができます

XMLで書くとこんな弾幕も…
~~~~xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE bulletml SYSTEM "http://www.asahi-net.or.jp/~cs8k-cyu/bulletml/bulletml.dtd">
Expand All @@ -98,7 +96,6 @@ XMLで書くとこんな弾幕も…
</bulletml>
~~~~

DSLで書くとこんなにスッキリ!
~~~~javascript
var spec = new bulletml.Root({
top: action([
Expand Down
8 changes: 6 additions & 2 deletions build/bulletml.js
Expand Up @@ -860,6 +860,10 @@ if (typeof module === 'object') {
*/
this._localScope = {};
};
/**
* return random number[0.0 - 1.0]
*/
bulletml.Walker.random = Math.random;

/**
* @return {bulletml.Command}
Expand Down Expand Up @@ -1014,7 +1018,7 @@ if (typeof module === 'object') {
} else if (n = bulletml.Walker.globalScope[exp]) {
return n;
} else if (exp === "$rand") {
return Math.random();
return bulletml.Walker.random();
}

var scope = {};
Expand All @@ -1028,7 +1032,7 @@ if (typeof module === 'object') {
scope[prop] = this._localScope[prop];
}
}
scope["$rand"] = Math.random();
scope["$rand"] = bulletml.Walker.random();
var upperScope = this._stack[this._stack.length - 1];
if (upperScope) {
scope["$loop"] = {
Expand Down
4 changes: 2 additions & 2 deletions build/bulletml.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/bulletml.min.js.map

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/main/bulletml.walker.js
Expand Up @@ -26,6 +26,10 @@
*/
this._localScope = {};
};
/**
* return random number[0.0 - 1.0]
*/
bulletml.Walker.random = Math.random;

/**
* @return {bulletml.Command}
Expand Down Expand Up @@ -180,7 +184,7 @@
} else if (n = bulletml.Walker.globalScope[exp]) {
return n;
} else if (exp === "$rand") {
return Math.random();
return bulletml.Walker.random();
}

var scope = {};
Expand All @@ -194,7 +198,7 @@
scope[prop] = this._localScope[prop];
}
}
scope["$rand"] = Math.random();
scope["$rand"] = bulletml.Walker.random();
var upperScope = this._stack[this._stack.length - 1];
if (upperScope) {
scope["$loop"] = {
Expand Down

0 comments on commit 911893e

Please sign in to comment.