| 1 |
|
var MT = (function () { |
| 2 |
|
function MT(seed) { |
| 3 |
|
if(seed === undefined) { |
| 4 |
|
seed = new Date().getTime(); |
| 5 |
|
} |
| 6 |
|
this._mt = new Array(624); |
| 7 |
|
this.setSeed(seed); |
| 8 |
|
} |
| 9 |
|
MT._mulUint32 = function _mulUint32(a, b) { |
| 10 |
|
var a1 = a >> 16, a2 = a & 65535; |
| 11 |
|
var b1 = b >> 16, b2 = b & 65535; |
| 12 |
|
return (((a1 * b2 + a2 * b1) << 16) + a2 * b2); |
| 13 |
|
}; |
| 14 |
|
MT.prototype.setSeed = function (seed) { |
| 15 |
|
var mt = this._mt; |
| 16 |
|
if(typeof seed == "number") { |
| 17 |
|
mt[0] = seed; |
| 18 |
|
for(var i = 1; i < mt.length; i++) { |
| 19 |
|
var x = mt[i - 1] ^ (mt[i - 1] >> 30); |
| 20 |
|
mt[i] = MT._mulUint32(1812433253, x) + i; |
| 21 |
|
} |
| 22 |
|
this._index = mt.length; |
| 23 |
|
} else if(seed instanceof Array) { |
| 24 |
|
var i = 1, j = 0; |
| 25 |
|
this.setSeed(19650218); |
| 26 |
|
for(var k = Math.max(mt.length, seed.length); k > 0; k--) { |
| 27 |
|
var x = mt[i - 1] ^ (mt[i - 1] >> 30); |
| 28 |
|
x = MT._mulUint32(x, 1664525); |
| 29 |
|
mt[i] = (mt[i] ^ x) + (seed[j]) + j; |
| 30 |
|
if(++i >= mt.length) { |
| 31 |
|
mt[0] = mt[mt.length - 1]; |
| 32 |
|
i = 1; |
| 33 |
|
} |
| 34 |
|
if(++j >= seed.length) { |
| 35 |
|
j = 0; |
| 36 |
|
} |
| 37 |
|
} |
| 38 |
|
for(var k = mt.length - 1; k > 0; k--) { |
| 39 |
|
var x = mt[i - 1] ^ (mt[i - 1] >> 30); |
| 40 |
|
x = MT._mulUint32(x, 1566083941); |
| 41 |
|
mt[i] = (mt[i] ^ x) - i; |
| 42 |
|
if(++i >= mt.length) { |
| 43 |
|
mt[0] = mt[mt.length - 1]; |
| 44 |
|
i = 1; |
| 45 |
|
} |
| 46 |
|
} |
| 47 |
|
mt[0] = 2147483648; |
| 48 |
|
} else { |
| 49 |
|
throw new TypeError("MersenneTwister: illegal seed."); |
| 50 |
|
} |
| 51 |
|
}; |
| 52 |
|
MT.prototype._nextInt = function () { |
| 53 |
|
var mt = this._mt, value; |
| 54 |
|
if(this._index >= mt.length) { |
| 55 |
|
var k = 0, N = mt.length, M = 397; |
| 56 |
|
do { |
| 57 |
|
value = (mt[k] & 2147483648) | (mt[k + 1] & 2147483647); |
| 58 |
|
mt[k] = mt[k + M] ^ (value >> 1) ^ ((value & 1) ? 2567483615 : 0); |
| 59 |
|
}while(++k < N - M); |
| 60 |
|
do { |
| 61 |
|
value = (mt[k] & 2147483648) | (mt[k + 1] & 2147483647); |
| 62 |
|
mt[k] = mt[k + M - N] ^ (value >> 1) ^ ((value & 1) ? 2567483615 : 0); |
| 63 |
|
}while(++k < N - 1); |
| 64 |
|
value = (mt[N - 1] & 2147483648) | (mt[0] & 2147483647); |
| 65 |
|
mt[N - 1] = mt[M - 1] ^ (value >> 1) ^ ((value & 1) ? 2567483615 : 0); |
| 66 |
|
this._index = 0; |
| 67 |
|
} |
| 68 |
|
value = mt[this._index++]; |
| 69 |
|
value ^= value >> 11; |
| 70 |
|
value ^= (value << 7) & 2636928640; |
| 71 |
|
value ^= (value << 15) & 4022730752; |
| 72 |
|
value ^= value >> 18; |
| 73 |
|
return value; |
| 74 |
|
}; |
| 75 |
|
MT.prototype.next = function () { |
| 76 |
|
var a = this._nextInt() >> 5, b = this._nextInt() >> 6; |
| 77 |
|
return (a * 67108864 + b) / 4503599627370496; |
| 78 |
|
}; |
| 79 |
|
MT.prototype.nextInt = function (min, sup) { |
| 80 |
|
if(!(0 < sup && sup < 4294967296)) { |
| 81 |
|
return this._nextInt() + min; |
| 82 |
|
} |
| 83 |
|
if((sup & (~sup + 1)) == sup) { |
| 84 |
|
return ((sup - 1) & this._nextInt()) + min; |
| 85 |
|
} |
| 86 |
|
var value; |
| 87 |
|
do { |
| 88 |
|
value = this._nextInt(); |
| 89 |
|
}while(sup > 2147483647 - (value - (value %= sup))); |
| 90 |
|
return value + min; |
| 91 |
|
}; |
| 92 |
|
return MT; |
| 93 |
|
})(); |
| 94 |
window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || ((function () { |
window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || ((function () { |
| 95 |
var lastTime = Date.now ? Date.now() : new Date().getTime(); |
var lastTime = Date.now ? Date.now() : new Date().getTime(); |
| 96 |
var frame = 1000 / 60; |
var frame = 1000 / 60; |
| 502 |
} |
} |
| 503 |
return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b; |
return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b; |
| 504 |
}; |
}; |
| 505 |
Easing.RANDOM = function RANDOM() { |
Easing.RANDOM = function RANDOM(game) { |
| 506 |
var ary = []; |
var ary = []; |
| 507 |
for(var i in Easing) { |
for(var i in Easing) { |
| 508 |
if(i != "RANDOM") { |
if(i != "RANDOM") { |
| 509 |
ary.push(i); |
ary.push(i); |
| 510 |
} |
} |
| 511 |
} |
} |
| 512 |
return Easing[ary[Math.floor(Math.random() * ary.length)]]; |
return Easing[ary[game.random(0, ary.length - 1)]]; |
| 513 |
}; |
}; |
| 514 |
return Easing; |
return Easing; |
| 515 |
})(); |
})(); |
| 2770 |
if(document.getElementById("fps_show")) { |
if(document.getElementById("fps_show")) { |
| 2771 |
this.fps = document.getElementById("fps_show"); |
this.fps = document.getElementById("fps_show"); |
| 2772 |
} |
} |
| 2773 |
|
this.setSeed(); |
| 2774 |
this.main(); |
this.main(); |
| 2775 |
} |
} |
| 2776 |
|
Game.prototype.setSeed = function (seed) { |
| 2777 |
|
this.seed = seed === undefined ? new Date().getTime() : seed; |
| 2778 |
|
this.mt = new MT(seed); |
| 2779 |
|
}; |
| 2780 |
|
Game.prototype.random = function (min, max) { |
| 2781 |
|
return this.mt.nextInt(min, max - min + 1); |
| 2782 |
|
}; |
| 2783 |
Game.prototype.getWindowSize = function () { |
Game.prototype.getWindowSize = function () { |
| 2784 |
return { |
return { |
| 2785 |
width: document.documentElement.clientWidth, |
width: document.documentElement.clientWidth, |
| 3302 |
})(); |
})(); |
| 3303 |
ImageFilter.FilterChain = FilterChain; |
ImageFilter.FilterChain = FilterChain; |
| 3304 |
var Filter = (function () { |
var Filter = (function () { |
| 3305 |
function Filter() { |
function Filter(game) { |
| 3306 |
this.opt = { |
this.opt = { |
| 3307 |
}; |
}; |
| 3308 |
|
this.game = game; |
| 3309 |
} |
} |
| 3310 |
Filter.prototype.filter = function (pixels) { |
Filter.prototype.filter = function (pixels) { |
| 3311 |
}; |
}; |
| 3367 |
ImageFilter.Filter = Filter; |
ImageFilter.Filter = Filter; |
| 3368 |
var UniversalTransitionFilter = (function (_super) { |
var UniversalTransitionFilter = (function (_super) { |
| 3369 |
__extends(UniversalTransitionFilter, _super); |
__extends(UniversalTransitionFilter, _super); |
| 3370 |
function UniversalTransitionFilter(image, amount, repeat) { |
function UniversalTransitionFilter(game, image, amount, repeat) { |
| 3371 |
_super.call(this); |
_super.call(this, game); |
| 3372 |
this.opt.amount = amount; |
this.opt.amount = amount; |
| 3373 |
this.opt.image = image; |
this.opt.image = image; |
| 3374 |
this.opt.repeat = repeat; |
this.opt.repeat = repeat; |
| 3513 |
ImageFilter.ReverseUniversalTransitionFilter = ReverseUniversalTransitionFilter; |
ImageFilter.ReverseUniversalTransitionFilter = ReverseUniversalTransitionFilter; |
| 3514 |
var GreyscaleFilter = (function (_super) { |
var GreyscaleFilter = (function (_super) { |
| 3515 |
__extends(GreyscaleFilter, _super); |
__extends(GreyscaleFilter, _super); |
| 3516 |
function GreyscaleFilter(opacity) { |
function GreyscaleFilter(game, opacity) { |
| 3517 |
_super.call(this); |
_super.call(this, game); |
| 3518 |
this.opt.opacity = opacity; |
this.opt.opacity = opacity; |
| 3519 |
} |
} |
| 3520 |
GreyscaleFilter.prototype.filter = function (pixels) { |
GreyscaleFilter.prototype.filter = function (pixels) { |
| 3534 |
ImageFilter.GreyscaleFilter = GreyscaleFilter; |
ImageFilter.GreyscaleFilter = GreyscaleFilter; |
| 3535 |
var SepiaFilter = (function (_super) { |
var SepiaFilter = (function (_super) { |
| 3536 |
__extends(SepiaFilter, _super); |
__extends(SepiaFilter, _super); |
| 3537 |
function SepiaFilter(opacity) { |
function SepiaFilter(game, opacity) { |
| 3538 |
_super.call(this); |
_super.call(this, game); |
| 3539 |
this.opt.opacity = opacity; |
this.opt.opacity = opacity; |
| 3540 |
} |
} |
| 3541 |
SepiaFilter.prototype.filter = function (pixels) { |
SepiaFilter.prototype.filter = function (pixels) { |
| 3554 |
ImageFilter.SepiaFilter = SepiaFilter; |
ImageFilter.SepiaFilter = SepiaFilter; |
| 3555 |
var TintFilter = (function (_super) { |
var TintFilter = (function (_super) { |
| 3556 |
__extends(TintFilter, _super); |
__extends(TintFilter, _super); |
| 3557 |
function TintFilter(color, opacity) { |
function TintFilter(game, color, opacity) { |
| 3558 |
_super.call(this); |
_super.call(this, game); |
| 3559 |
this.opt.color = color; |
this.opt.color = color; |
| 3560 |
this.opt.opacity = opacity; |
this.opt.opacity = opacity; |
| 3561 |
} |
} |
| 3578 |
ImageFilter.TintFilter = TintFilter; |
ImageFilter.TintFilter = TintFilter; |
| 3579 |
var EdgesFilter = (function (_super) { |
var EdgesFilter = (function (_super) { |
| 3580 |
__extends(EdgesFilter, _super); |
__extends(EdgesFilter, _super); |
| 3581 |
function EdgesFilter(amount) { |
function EdgesFilter(game, amount) { |
| 3582 |
_super.call(this); |
_super.call(this, game); |
| 3583 |
this.opt.amount = amount; |
this.opt.amount = amount; |
| 3584 |
} |
} |
| 3585 |
EdgesFilter.prototype.filter = function (pixels) { |
EdgesFilter.prototype.filter = function (pixels) { |
| 3601 |
ImageFilter.EdgesFilter = EdgesFilter; |
ImageFilter.EdgesFilter = EdgesFilter; |
| 3602 |
var EmbossFilter = (function (_super) { |
var EmbossFilter = (function (_super) { |
| 3603 |
__extends(EmbossFilter, _super); |
__extends(EmbossFilter, _super); |
| 3604 |
function EmbossFilter(amount) { |
function EmbossFilter(game, amount) { |
| 3605 |
_super.call(this); |
_super.call(this, game); |
| 3606 |
this.opt.amount = amount; |
this.opt.amount = amount; |
| 3607 |
} |
} |
| 3608 |
EmbossFilter.prototype.filter = function (pixels) { |
EmbossFilter.prototype.filter = function (pixels) { |
| 3624 |
ImageFilter.EmbossFilter = EmbossFilter; |
ImageFilter.EmbossFilter = EmbossFilter; |
| 3625 |
var SharpenFilter = (function (_super) { |
var SharpenFilter = (function (_super) { |
| 3626 |
__extends(SharpenFilter, _super); |
__extends(SharpenFilter, _super); |
| 3627 |
function SharpenFilter(amount) { |
function SharpenFilter(game, amount) { |
| 3628 |
_super.call(this); |
_super.call(this, game); |
| 3629 |
this.opt.amount = amount; |
this.opt.amount = amount; |
| 3630 |
} |
} |
| 3631 |
SharpenFilter.prototype.filter = function (pixels) { |
SharpenFilter.prototype.filter = function (pixels) { |
| 3647 |
ImageFilter.SharpenFilter = SharpenFilter; |
ImageFilter.SharpenFilter = SharpenFilter; |
| 3648 |
var MatrixFilter = (function (_super) { |
var MatrixFilter = (function (_super) { |
| 3649 |
__extends(MatrixFilter, _super); |
__extends(MatrixFilter, _super); |
| 3650 |
function MatrixFilter(amount, matrix) { |
function MatrixFilter(game, amount, matrix) { |
| 3651 |
_super.call(this); |
_super.call(this, game); |
| 3652 |
this.opt.amount = amount; |
this.opt.amount = amount; |
| 3653 |
this.opt.matrix = matrix; |
this.opt.matrix = matrix; |
| 3654 |
} |
} |
| 3671 |
ImageFilter.MatrixFilter = MatrixFilter; |
ImageFilter.MatrixFilter = MatrixFilter; |
| 3672 |
var BlurFilter = (function (_super) { |
var BlurFilter = (function (_super) { |
| 3673 |
__extends(BlurFilter, _super); |
__extends(BlurFilter, _super); |
| 3674 |
function BlurFilter(amount) { |
function BlurFilter(game, amount) { |
| 3675 |
_super.call(this); |
_super.call(this, game); |
| 3676 |
this.opt.amount = amount; |
this.opt.amount = amount; |
| 3677 |
} |
} |
| 3678 |
BlurFilter.prototype.filter = function (pixels) { |
BlurFilter.prototype.filter = function (pixels) { |
| 3767 |
ImageFilter.BlurFilter = BlurFilter; |
ImageFilter.BlurFilter = BlurFilter; |
| 3768 |
var MosaicFilter = (function (_super) { |
var MosaicFilter = (function (_super) { |
| 3769 |
__extends(MosaicFilter, _super); |
__extends(MosaicFilter, _super); |
| 3770 |
function MosaicFilter(size, opacity) { |
function MosaicFilter(game, size, opacity) { |
| 3771 |
_super.call(this); |
_super.call(this, game); |
| 3772 |
this.opt.size = size; |
this.opt.size = size; |
| 3773 |
this.opt.opacity = opacity; |
this.opt.opacity = opacity; |
| 3774 |
} |
} |
| 3809 |
var NoiseType = ImageFilter.NoiseType; |
var NoiseType = ImageFilter.NoiseType; |
| 3810 |
var NoiseFilter = (function (_super) { |
var NoiseFilter = (function (_super) { |
| 3811 |
__extends(NoiseFilter, _super); |
__extends(NoiseFilter, _super); |
| 3812 |
function NoiseFilter(amount, type) { |
function NoiseFilter(game, amount, type) { |
| 3813 |
_super.call(this); |
_super.call(this, game); |
| 3814 |
this.opt.amount = amount; |
this.opt.amount = amount; |
| 3815 |
this.opt.type = type; |
this.opt.type = type; |
| 3816 |
} |
} |
| 3817 |
NoiseFilter.prototype.filter = function (pixels) { |
NoiseFilter.prototype.filter = function (pixels) { |
| 3818 |
var amount = this.getOption("amount", 30); |
var amount = this.getOption("amount", 30); |
| 3819 |
var type = this.getOption("type", NoiseType.Mono); |
var type = this.getOption("type", NoiseType.Mono); |
| 3820 |
|
var max = (amount >> 1) - 1; |
| 3821 |
|
var min = max - amount; |
| 3822 |
for(var i = 0, data = pixels.data, length = data.length; i < length >> 2; i++) { |
for(var i = 0, data = pixels.data, length = data.length; i < length >> 2; i++) { |
| 3823 |
var index = i << 2; |
var index = i << 2; |
| 3824 |
var r = data[index], g = data[index + 1], b = data[index + 2]; |
var r = data[index], g = data[index + 1], b = data[index + 2]; |
| 3825 |
if(type == NoiseType.Mono) { |
if(type == NoiseType.Mono) { |
| 3826 |
var val = Math.floor((amount >> 1) - (Math.random() * amount)); |
var val = this.game.random(min, max); |
| 3827 |
data[index] = this.checkRGBBoundary(r + val); |
data[index] = this.checkRGBBoundary(r + val); |
| 3828 |
data[index + 1] = this.checkRGBBoundary(g + val); |
data[index + 1] = this.checkRGBBoundary(g + val); |
| 3829 |
data[index + 2] = this.checkRGBBoundary(b + val); |
data[index + 2] = this.checkRGBBoundary(b + val); |
| 3830 |
} else { |
} else { |
| 3831 |
data[index] = this.checkRGBBoundary(r + Math.floor((amount >> 1) - (Math.random() * amount))); |
data[index] = this.checkRGBBoundary(r + this.game.random(min, max)); |
| 3832 |
data[index + 1] = this.checkRGBBoundary(g + Math.floor((amount >> 1) - (Math.random() * amount))); |
data[index + 1] = this.checkRGBBoundary(g + this.game.random(min, max)); |
| 3833 |
data[index + 2] = this.checkRGBBoundary(b + Math.floor((amount >> 1) - (Math.random() * amount))); |
data[index + 2] = this.checkRGBBoundary(b + this.game.random(min, max)); |
| 3834 |
} |
} |
| 3835 |
} |
} |
| 3836 |
}; |
}; |
| 3839 |
ImageFilter.NoiseFilter = NoiseFilter; |
ImageFilter.NoiseFilter = NoiseFilter; |
| 3840 |
var PosterizeFilter = (function (_super) { |
var PosterizeFilter = (function (_super) { |
| 3841 |
__extends(PosterizeFilter, _super); |
__extends(PosterizeFilter, _super); |
| 3842 |
function PosterizeFilter(amount, opacity) { |
function PosterizeFilter(game, amount, opacity) { |
| 3843 |
_super.call(this); |
_super.call(this, game); |
| 3844 |
this.opt.opacity = opacity; |
this.opt.opacity = opacity; |
| 3845 |
this.opt.amount = amount; |
this.opt.amount = amount; |
| 3846 |
} |
} |
| 4040 |
Tween.prototype.actionStart = function (e) { |
Tween.prototype.actionStart = function (e) { |
| 4041 |
for(var prop in this.props) { |
for(var prop in this.props) { |
| 4042 |
if(prop == "filter") { |
if(prop == "filter") { |
| 4043 |
var filter = new this.props[prop].targetClass(); |
var filter = new this.props[prop].targetClass(this.entity.scene.game); |
| 4044 |
if(!this.entity.filter) { |
if(!this.entity.filter) { |
| 4045 |
this.entity.filter = new ImageFilter.FilterChain(); |
this.entity.filter = new ImageFilter.FilterChain(); |
| 4046 |
} |
} |