Файловый менеджер - Редактировать - /home/jogoso94/public_html/jogos/8_ball_pro/js/main.js
�азад
/* TweenJS Visit http://createjs.com/ for documentation, updates and examples. Copyright (c) 2010 gskinner.com, inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. screenfull v5.0.0 - 2019-09-09 (c) Sindre Sorhus; MIT License Platform.js <https://mths.be/platform> Copyright 2014-2018 Benjamin Tan <https://bnjmnt4n.now.sh/> Copyright 2011-2013 John-David Dalton Available under MIT license <https://mths.be/mit> */ this.createjs = this.createjs || {}; createjs.extend = function(a, c) { function b() { this.constructor = a } b.prototype = c.prototype; return a.prototype = new b }; this.createjs = this.createjs || {}; createjs.promote = function(a, c) { var b = a.prototype, e = Object.getPrototypeOf && Object.getPrototypeOf(b) || b.__proto__; if (e) { b[(c += "_") + "constructor"] = e.constructor; for (var d in e) b.hasOwnProperty(d) && "function" == typeof e[d] && (b[c + d] = e[d]) } return a }; this.createjs = this.createjs || {}; createjs.deprecate = function(a, c) { return function() { var b = "Deprecated property or method '" + c + "'. See docs for info."; console && (console.warn ? console.warn(b) : console.log(b)); return a && a.apply(this, arguments) } }; this.createjs = this.createjs || {}; (function() { function a(b, e, d) { this.type = b; this.currentTarget = this.target = null; this.eventPhase = 0; this.bubbles = !!e; this.cancelable = !!d; this.timeStamp = (new Date).getTime(); this.removed = this.immediatePropagationStopped = this.propagationStopped = this.defaultPrevented = !1 } var c = a.prototype; c.preventDefault = function() { this.defaultPrevented = this.cancelable && !0 }; c.stopPropagation = function() { this.propagationStopped = !0 }; c.stopImmediatePropagation = function() { this.immediatePropagationStopped = this.propagationStopped = !0 }; c.remove = function() { this.removed = !0 }; c.clone = function() { return new a(this.type, this.bubbles, this.cancelable) }; c.set = function(b) { for (var e in b) this[e] = b[e]; return this }; c.toString = function() { return "[Event (type=" + this.type + ")]" }; createjs.Event = a })(); this.createjs = this.createjs || {}; (function() { function a() { this._captureListeners = this._listeners = null } var c = a.prototype; a.initialize = function(b) { b.addEventListener = c.addEventListener; b.on = c.on; b.removeEventListener = b.off = c.removeEventListener; b.removeAllEventListeners = c.removeAllEventListeners; b.hasEventListener = c.hasEventListener; b.dispatchEvent = c.dispatchEvent; b._dispatchEvent = c._dispatchEvent; b.willTrigger = c.willTrigger }; c.addEventListener = function(b, e, d) { var f = d ? this._captureListeners = this._captureListeners || {} : this._listeners = this._listeners || {}; var g = f[b]; g && this.removeEventListener(b, e, d); (g = f[b]) ? g.push(e): f[b] = [e]; return e }; c.on = function(b, e, d, f, g, h) { e.handleEvent && (d = d || e, e = e.handleEvent); d = d || this; return this.addEventListener(b, function(k) { e.call(d, k, g); f && k.remove() }, h) }; c.removeEventListener = function(b, e, d) { if (d = d ? this._captureListeners : this._listeners) { var f = d[b]; if (f) for (var g = 0, h = f.length; g < h; g++) if (f[g] == e) { 1 == h ? delete d[b] : f.splice(g, 1); break } } }; c.off = c.removeEventListener; c.removeAllEventListeners = function(b) { b ? (this._listeners && delete this._listeners[b], this._captureListeners && delete this._captureListeners[b]) : this._listeners = this._captureListeners = null }; c.dispatchEvent = function(b, e, d) { if ("string" == typeof b) { var f = this._listeners; if (!(e || f && f[b])) return !0; b = new createjs.Event(b, e, d) } else b.target && b.clone && (b = b.clone()); try { b.target = this } catch (g) {} if (b.bubbles && this.parent) { d = this; for (e = [d]; d.parent;) e.push(d = d.parent); f = e.length; for (d = f - 1; 0 <= d && !b.propagationStopped; d--) e[d]._dispatchEvent(b, 1 + (0 == d)); for (d = 1; d < f && !b.propagationStopped; d++) e[d]._dispatchEvent(b, 3) } else this._dispatchEvent(b, 2); return !b.defaultPrevented }; c.hasEventListener = function(b) { var e = this._listeners, d = this._captureListeners; return !!(e && e[b] || d && d[b]) }; c.willTrigger = function(b) { for (var e = this; e;) { if (e.hasEventListener(b)) return !0; e = e.parent } return !1 }; c.toString = function() { return "[EventDispatcher]" }; c._dispatchEvent = function(b, e) { var d, f, g = 2 >= e ? this._captureListeners : this._listeners; if (b && g && (f = g[b.type]) && (d = f.length)) { try { b.currentTarget = this } catch (k) {} try { b.eventPhase = e | 0 } catch (k) {} b.removed = !1; f = f.slice(); for (g = 0; g < d && !b.immediatePropagationStopped; g++) { var h = f[g]; h.handleEvent ? h.handleEvent(b) : h(b); b.removed && (this.off(b.type, h, 1 == e), b.removed = !1) } } 2 === e && this._dispatchEvent(b, 2.1) }; createjs.EventDispatcher = a })(); this.createjs = this.createjs || {}; (function() { function a() { throw "Ticker cannot be instantiated."; } a.RAF_SYNCHED = "synched"; a.RAF = "raf"; a.TIMEOUT = "timeout"; a.timingMode = null; a.maxDelta = 0; a.paused = !1; a.removeEventListener = null; a.removeAllEventListeners = null; a.dispatchEvent = null; a.hasEventListener = null; a._listeners = null; createjs.EventDispatcher.initialize(a); a._addEventListener = a.addEventListener; a.addEventListener = function() { !a._inited && a.init(); return a._addEventListener.apply(a, arguments) }; a._inited = !1; a._startTime = 0; a._pausedTime = 0; a._ticks = 0; a._pausedTicks = 0; a._interval = 50; a._lastTime = 0; a._times = null; a._tickTimes = null; a._timerId = null; a._raf = !0; a._setInterval = function(e) { a._interval = e; a._inited && a._setupTick() }; a.setInterval = createjs.deprecate(a._setInterval, "Ticker.setInterval"); a._getInterval = function() { return a._interval }; a.getInterval = createjs.deprecate(a._getInterval, "Ticker.getInterval"); a._setFPS = function(e) { a._setInterval(1E3 / e) }; a.setFPS = createjs.deprecate(a._setFPS, "Ticker.setFPS"); a._getFPS = function() { return 1E3 / a._interval }; a.getFPS = createjs.deprecate(a._getFPS, "Ticker.getFPS"); try { Object.defineProperties(a, { interval: { get: a._getInterval, set: a._setInterval }, framerate: { get: a._getFPS, set: a._setFPS } }) } catch (e) { console.log(e) } a.init = function() { a._inited || (a._inited = !0, a._times = [], a._tickTimes = [], a._startTime = a._getTime(), a._times.push(a._lastTime = 0), a.interval = a._interval) }; a.reset = function() { if (a._raf) { var e = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame; e && e(a._timerId) } else clearTimeout(a._timerId); a.removeAllEventListeners("tick"); a._timerId = a._times = a._tickTimes = null; a._startTime = a._lastTime = a._ticks = a._pausedTime = 0; a._inited = !1 }; a.getMeasuredTickTime = function(e) { var d = 0, f = a._tickTimes; if (!f || 1 > f.length) return -1; e = Math.min(f.length, e || a._getFPS() | 0); for (var g = 0; g < e; g++) d += f[g]; return d / e }; a.getMeasuredFPS = function(e) { var d = a._times; if (!d || 2 > d.length) return -1; e = Math.min(d.length - 1, e || a._getFPS() | 0); return 1E3 / ((d[0] - d[e]) / e) }; a.getTime = function(e) { return a._startTime ? a._getTime() - (e ? a._pausedTime : 0) : -1 }; a.getEventTime = function(e) { return a._startTime ? (a._lastTime || a._startTime) - (e ? a._pausedTime : 0) : -1 }; a.getTicks = function(e) { return a._ticks - (e ? a._pausedTicks : 0) }; a._handleSynch = function() { a._timerId = null; a._setupTick(); a._getTime() - a._lastTime >= .97 * (a._interval - 1) && a._tick() }; a._handleRAF = function() { a._timerId = null; a._setupTick(); a._tick() }; a._handleTimeout = function() { a._timerId = null; a._setupTick(); a._tick() }; a._setupTick = function() { if (null == a._timerId) { var e = a.timingMode; if (e == a.RAF_SYNCHED || e == a.RAF) { var d = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame; if (d) { a._timerId = d(e == a.RAF ? a._handleRAF : a._handleSynch); a._raf = !0; return } } a._raf = !1; a._timerId = setTimeout(a._handleTimeout, a._interval) } }; a._tick = function() { var e = a.paused, d = a._getTime(), f = d - a._lastTime; a._lastTime = d; a._ticks++; e && (a._pausedTicks++, a._pausedTime += f); if (a.hasEventListener("tick")) { var g = new createjs.Event("tick"), h = a.maxDelta; g.delta = h && f > h ? h : f; g.paused = e; g.time = d; g.runTime = d - a._pausedTime; a.dispatchEvent(g) } for (a._tickTimes.unshift(a._getTime() - d); 100 < a._tickTimes.length;) a._tickTimes.pop(); for (a._times.unshift(d); 100 < a._times.length;) a._times.pop() }; var c = window, b = c.performance.now || c.performance.mozNow || c.performance.msNow || c.performance.oNow || c.performance.webkitNow; a._getTime = function() { return (b && b.call(c.performance) || (new Date).getTime()) - a._startTime }; createjs.Ticker = a })(); this.createjs = this.createjs || {}; (function() { function a(b) { this.EventDispatcher_constructor(); this.ignoreGlobalPause = !1; this.loop = 0; this.bounce = this.reversed = this.useTicks = !1; this.timeScale = 1; this.position = this.duration = 0; this.rawPosition = -1; this._paused = !0; this._labelList = this._labels = this._parent = this._prev = this._next = null; b && (this.useTicks = !!b.useTicks, this.ignoreGlobalPause = !!b.ignoreGlobalPause, this.loop = !0 === b.loop ? -1 : b.loop || 0, this.reversed = !!b.reversed, this.bounce = !!b.bounce, this.timeScale = b.timeScale || 1, b.onChange && this.addEventListener("change", b.onChange), b.onComplete && this.addEventListener("complete", b.onComplete)) } var c = createjs.extend(a, createjs.EventDispatcher); c._setPaused = function(b) { createjs.Tween._register(this, b); return this }; c.setPaused = createjs.deprecate(c._setPaused, "AbstractTween.setPaused"); c._getPaused = function() { return this._paused }; c.getPaused = createjs.deprecate(c._getPaused, "AbstactTween.getPaused"); c._getCurrentLabel = function(b) { var e = this.getLabels(); null == b && (b = this.position); for (var d = 0, f = e.length; d < f && !(b < e[d].position); d++); return 0 === d ? null : e[d - 1].label }; c.getCurrentLabel = createjs.deprecate(c._getCurrentLabel, "AbstractTween.getCurrentLabel"); try { Object.defineProperties(c, { paused: { set: c._setPaused, get: c._getPaused }, currentLabel: { get: c._getCurrentLabel } }) } catch (b) {} c.advance = function(b, e) { this.setPosition(this.rawPosition + b * this.timeScale, e) }; c.setPosition = function(b, e, d, f) { var g = this.duration, h = this.loop, k = this.rawPosition, n = 0; 0 > b && (b = 0); if (0 === g) { var l = !0; if (-1 !== k) return l } else { var t = b / g | 0; n = b - t * g; (l = -1 !== h && b >= h * g + g) && (b = (n = g) * (t = h) + g); if (b === k) return l; !this.reversed !== !(this.bounce && t % 2) && (n = g - n) } this.position = n; this.rawPosition = b; this._updatePosition(d, l); l && (this.paused = !0); f && f(this); e || this._runActions(k, b, d, !d && -1 === k); this.dispatchEvent("change"); l && this.dispatchEvent("complete") }; c.calculatePosition = function(b) { var e = this.duration, d = this.loop, f = 0; if (0 === e) return 0; - 1 !== d && b >= d * e + e ? (b = e, f = d) : 0 > b ? b = 0 : (f = b / e | 0, b -= f * e); return !this.reversed !== !(this.bounce && f % 2) ? e - b : b }; c.getLabels = function() { var b = this._labelList; if (!b) { b = this._labelList = []; var e = this._labels, d; for (d in e) b.push({ label: d, position: e[d] }); b.sort(function(f, g) { return f.position - g.position }) } return b }; c.setLabels = function(b) { this._labels = b; this._labelList = null }; c.addLabel = function(b, e) { this._labels || (this._labels = {}); this._labels[b] = e; var d = this._labelList; if (d) { for (var f = 0, g = d.length; f < g && !(e < d[f].position); f++); d.splice(f, 0, { label: b, position: e }) } }; c.gotoAndPlay = function(b) { this.paused = !1; this._goto(b) }; c.gotoAndStop = function(b) { this.paused = !0; this._goto(b) }; c.resolve = function(b) { var e = Number(b); isNaN(e) && (e = this._labels && this._labels[b]); return e }; c.toString = function() { return "[AbstractTween]" }; c.clone = function() { throw "AbstractTween can not be cloned."; }; c._init = function(b) { b && b.paused || (this.paused = !1); b && null != b.position && this.setPosition(b.position) }; c._updatePosition = function(b, e) {}; c._goto = function(b) { b = this.resolve(b); null != b && this.setPosition(b, !1, !0) }; c._runActions = function(b, e, d, f) { if (this._actionHead || this.tweens) { var g = this.duration, h = this.reversed, k = this.bounce, n = this.loop, l, t, w; if (0 === g) { var z = l = t = w = 0; h = k = !1 } else z = b / g | 0, l = e / g | 0, t = b - z * g, w = e - l * g; - 1 !== n && (l > n && (w = g, l = n), z > n && (t = g, z = n)); if (d) return this._runActionsRange(w, w, d, f); if (z !== l || t !== w || d || f) { -1 === z && (z = t = 0); b = b <= e; e = z; do { n = e === z ? t : b ? 0 : g; var v = e === l ? w : b ? g : 0; !h !== !(k && e % 2) && (n = g - n, v = g - v); if ((!k || e === z || n !== v) && this._runActionsRange(n, v, d, f || e !== z && !k)) return !0; f = !1 } while (b && ++e <= l || !b && --e >= l) } } }; c._runActionsRange = function(b, e, d, f) {}; createjs.AbstractTween = createjs.promote(a, "EventDispatcher") })(); this.createjs = this.createjs || {}; (function() { function a(d, f) { this.AbstractTween_constructor(f); this.pluginData = null; this.target = d; this.passive = !1; this._stepTail = this._stepHead = new c(null, 0, 0, {}, null, !0); this._stepPosition = 0; this._injected = this._pluginIds = this._plugins = this._actionTail = this._actionHead = null; f && (this.pluginData = f.pluginData, f.override && a.removeTweens(d)); this.pluginData || (this.pluginData = {}); this._init(f) } function c(d, f, g, h, k, n) { this.next = null; this.prev = d; this.t = f; this.d = g; this.props = h; this.ease = k; this.passive = n; this.index = d ? d.index + 1 : 0 } function b(d, f, g, h, k) { this.next = null; this.prev = d; this.t = f; this.d = 0; this.scope = g; this.funct = h; this.params = k } var e = createjs.extend(a, createjs.AbstractTween); a.IGNORE = {}; a._tweens = []; a._plugins = null; a._tweenHead = null; a._tweenTail = null; a.get = function(d, f) { return new a(d, f) }; a.tick = function(d, f) { for (var g = a._tweenHead; g;) { var h = g._next; f && !g.ignoreGlobalPause || g._paused || g.advance(g.useTicks ? 1 : d); g = h } }; a.handleEvent = function(d) { "tick" === d.type && this.tick(d.delta, d.paused) }; a.removeTweens = function(d) { if (d.tweenjs_count) { for (var f = a._tweenHead; f;) { var g = f._next; f.target === d && a._register(f, !0); f = g } d.tweenjs_count = 0 } }; a.removeAllTweens = function() { for (var d = a._tweenHead; d;) { var f = d._next; d._paused = !0; d.target && (d.target.tweenjs_count = 0); d._next = d._prev = null; d = f } a._tweenHead = a._tweenTail = null }; a.hasActiveTweens = function(d) { return d ? !!d.tweenjs_count : !!a._tweenHead }; a._installPlugin = function(d) { for (var f = d.priority = d.priority || 0, g = a._plugins = a._plugins || [], h = 0, k = g.length; h < k && !(f < g[h].priority); h++); g.splice(h, 0, d) }; a._register = function(d, f) { var g = d.target; if (!f && d._paused) g && (g.tweenjs_count = g.tweenjs_count ? g.tweenjs_count + 1 : 1), (g = a._tweenTail) ? (a._tweenTail = g._next = d, d._prev = g) : a._tweenHead = a._tweenTail = d, !a._inited && createjs.Ticker && (createjs.Ticker.addEventListener("tick", a), a._inited = !0); else if (f && !d._paused) { g && g.tweenjs_count--; g = d._next; var h = d._prev; g ? g._prev = h : a._tweenTail = h; h ? h._next = g : a._tweenHead = g; d._next = d._prev = null } d._paused = f }; e.wait = function(d, f) { 0 < d && this._addStep(+d, this._stepTail.props, null, f); return this }; e.to = function(d, f, g) { if (null == f || 0 > f) f = 0; f = this._addStep(+f, null, g); this._appendProps(d, f); return this }; e.label = function(d) { this.addLabel(d, this.duration); return this }; e.call = function(d, f, g) { return this._addAction(g || this.target, d, f || [this]) }; e.set = function(d, f) { return this._addAction(f || this.target, this._set, [d]) }; e.play = function(d) { return this._addAction(d || this, this._set, [{ paused: !1 }]) }; e.pause = function(d) { return this._addAction(d || this, this._set, [{ paused: !0 }]) }; e.w = e.wait; e.t = e.to; e.c = e.call; e.s = e.set; e.toString = function() { return "[Tween]" }; e.clone = function() { throw "Tween can not be cloned."; }; e._addPlugin = function(d) { var f = this._pluginIds || (this._pluginIds = {}), g = d.ID; if (g && !f[g]) { f[g] = !0; f = this._plugins || (this._plugins = []); g = d.priority || 0; for (var h = 0, k = f.length; h < k; h++) if (g < f[h].priority) { f.splice(h, 0, d); return } f.push(d) } }; e._updatePosition = function(d, f) { var g = this._stepHead.next, h = this.position, k = this.duration; if (this.target && g) { for (var n = g.next; n && n.t <= h;) g = g.next, n = g.next; this._updateTargetProps(g, f ? 0 === k ? 1 : h / k : (h - g.t) / g.d, f) } this._stepPosition = g ? h - g.t : 0 }; e._updateTargetProps = function(d, f, g) { if (!(this.passive = !!d.passive)) { var h, k = d.prev.props, n = d.props; if (h = d.ease) f = h(f, 0, 1, 1); h = this._plugins; var l; a: for (l in k) { var t = k[l]; var w = n[l]; t = t !== w && "number" === typeof t ? t + (w - t) * f : 1 <= f ? w : t; if (h) { w = 0; for (var z = h.length; w < z; w++) { var v = h[w].change(this, d, l, t, f, g); if (v === a.IGNORE) continue a; void 0 !== v && (t = v) } } this.target[l] = t } } }; e._runActionsRange = function(d, f, g, h) { var k = (g = d > f) ? this._actionTail : this._actionHead, n = f, l = d; g && (n = d, l = f); for (var t = this.position; k;) { var w = k.t; if (w === f || w > l && w < n || h && w === d) if (k.funct.apply(k.scope, k.params), t !== this.position) return !0; k = g ? k.prev : k.next } }; e._appendProps = function(d, f, g) { var h = this._stepHead.props, k = this.target, n = a._plugins, l, t, w = f.prev, z = w.props, v = f.props || (f.props = this._cloneProps(z)), G = {}; for (l in d) if (d.hasOwnProperty(l) && (G[l] = v[l] = d[l], void 0 === h[l])) { var C = void 0; if (n) for (t = n.length - 1; 0 <= t; t--) { var N = n[t].init(this, l, C); void 0 !== N && (C = N); if (C === a.IGNORE) { delete v[l]; delete G[l]; break } } C !== a.IGNORE && (void 0 === C && (C = k[l]), z[l] = void 0 === C ? null : C) } for (l in G) { var B; for (d = w; (B = d) && (d = B.prev);) if (d.props !== B.props) { if (void 0 !== d.props[l]) break; d.props[l] = z[l] } } if (!1 !== g && (n = this._plugins)) for (t = n.length - 1; 0 <= t; t--) n[t].step(this, f, G); if (g = this._injected) this._injected = null, this._appendProps(g, f, !1) }; e._injectProp = function(d, f) { (this._injected || (this._injected = {}))[d] = f }; e._addStep = function(d, f, g, h) { f = new c(this._stepTail, this.duration, d, f, g, h || !1); this.duration += d; return this._stepTail = this._stepTail.next = f }; e._addAction = function(d, f, g) { d = new b(this._actionTail, this.duration, d, f, g); this._actionTail ? this._actionTail.next = d : this._actionHead = d; this._actionTail = d; return this }; e._set = function(d) { for (var f in d) this[f] = d[f] }; e._cloneProps = function(d) { var f = {}, g; for (g in d) f[g] = d[g]; return f }; createjs.Tween = createjs.promote(a, "AbstractTween") })(); this.createjs = this.createjs || {}; (function() { function a(b) { if (b instanceof Array || null == b && 1 < arguments.length) { var e = b; var d = arguments[1]; b = arguments[2] } else b && (e = b.tweens, d = b.labels); this.AbstractTween_constructor(b); this.tweens = []; e && this.addTween.apply(this, e); this.setLabels(d); this._init(b) } var c = createjs.extend(a, createjs.AbstractTween); c.addTween = function(b) { b._parent && b._parent.removeTween(b); var e = arguments.length; if (1 < e) { for (var d = 0; d < e; d++) this.addTween(arguments[d]); return arguments[e - 1] } if (0 === e) return null; this.tweens.push(b); b._parent = this; b.paused = !0; e = b.duration; 0 < b.loop && (e *= b.loop + 1); e > this.duration && (this.duration = e); 0 <= this.rawPosition && b.setPosition(this.rawPosition); return b }; c.removeTween = function(b) { var e = arguments.length; if (1 < e) { for (var d = !0, f = 0; f < e; f++) d = d && this.removeTween(arguments[f]); return d } if (0 === e) return !0; e = this.tweens; for (f = e.length; f--;) if (e[f] === b) return e.splice(f, 1), b._parent = null, b.duration >= this.duration && this.updateDuration(), !0; return !1 }; c.updateDuration = function() { for (var b = this.duration = 0, e = this.tweens.length; b < e; b++) { var d = this.tweens[b], f = d.duration; 0 < d.loop && (f *= d.loop + 1); f > this.duration && (this.duration = f) } }; c.toString = function() { return "[Timeline]" }; c.clone = function() { throw "Timeline can not be cloned."; }; c._updatePosition = function(b, e) { for (var d = this.position, f = 0, g = this.tweens.length; f < g; f++) this.tweens[f].setPosition(d, !0, b) }; c._runActionsRange = function(b, e, d, f) { for (var g = this.position, h = 0, k = this.tweens.length; h < k; h++) if (this.tweens[h]._runActions(b, e, d, f), g !== this.position) return !0 }; createjs.Timeline = createjs.promote(a, "AbstractTween") })(); this.createjs = this.createjs || {}; (function() { function a() { throw "Ease cannot be instantiated."; } a.linear = function(c) { return c }; a.none = a.linear; a.get = function(c) { -1 > c ? c = -1 : 1 < c && (c = 1); return function(b) { return 0 == c ? b : 0 > c ? b * (b * -c + 1 + c) : b * ((2 - b) * c + (1 - c)) } }; a.getPowIn = function(c) { return function(b) { return Math.pow(b, c) } }; a.getPowOut = function(c) { return function(b) { return 1 - Math.pow(1 - b, c) } }; a.getPowInOut = function(c) { return function(b) { return 1 > (b *= 2) ? .5 * Math.pow(b, c) : 1 - .5 * Math.abs(Math.pow(2 - b, c)) } }; a.quadIn = a.getPowIn(2); a.quadOut = a.getPowOut(2); a.quadInOut = a.getPowInOut(2); a.cubicIn = a.getPowIn(3); a.cubicOut = a.getPowOut(3); a.cubicInOut = a.getPowInOut(3); a.quartIn = a.getPowIn(4); a.quartOut = a.getPowOut(4); a.quartInOut = a.getPowInOut(4); a.quintIn = a.getPowIn(5); a.quintOut = a.getPowOut(5); a.quintInOut = a.getPowInOut(5); a.sineIn = function(c) { return 1 - Math.cos(c * Math.PI / 2) }; a.sineOut = function(c) { return Math.sin(c * Math.PI / 2) }; a.sineInOut = function(c) { return -.5 * (Math.cos(Math.PI * c) - 1) }; a.getBackIn = function(c) { return function(b) { return b * b * ((c + 1) * b - c) } }; a.backIn = a.getBackIn(1.7); a.getBackOut = function(c) { return function(b) { return --b * b * ((c + 1) * b + c) + 1 } }; a.backOut = a.getBackOut(1.7); a.getBackInOut = function(c) { c *= 1.525; return function(b) { return 1 > (b *= 2) ? .5 * b * b * ((c + 1) * b - c) : .5 * ((b -= 2) * b * ((c + 1) * b + c) + 2) } }; a.backInOut = a.getBackInOut(1.7); a.circIn = function(c) { return -(Math.sqrt(1 - c * c) - 1) }; a.circOut = function(c) { return Math.sqrt(1 - --c * c) }; a.circInOut = function(c) { return 1 > (c *= 2) ? -.5 * (Math.sqrt(1 - c * c) - 1) : .5 * (Math.sqrt(1 - (c -= 2) * c) + 1) }; a.bounceIn = function(c) { return 1 - a.bounceOut(1 - c) }; a.bounceOut = function(c) { return c < 1 / 2.75 ? 7.5625 * c * c : c < 2 / 2.75 ? 7.5625 * (c -= 1.5 / 2.75) * c + .75 : c < 2.5 / 2.75 ? 7.5625 * (c -= 2.25 / 2.75) * c + .9375 : 7.5625 * (c -= 2.625 / 2.75) * c + .984375 }; a.bounceInOut = function(c) { return .5 > c ? .5 * a.bounceIn(2 * c) : .5 * a.bounceOut(2 * c - 1) + .5 }; a.getElasticIn = function(c, b) { var e = 2 * Math.PI; return function(d) { if (0 == d || 1 == d) return d; var f = b / e * Math.asin(1 / c); return -(c * Math.pow(2, 10 * --d) * Math.sin((d - f) * e / b)) } }; a.elasticIn = a.getElasticIn(1, .3); a.getElasticOut = function(c, b) { var e = 2 * Math.PI; return function(d) { return 0 == d || 1 == d ? d : c * Math.pow(2, -10 * d) * Math.sin((d - b / e * Math.asin(1 / c)) * e / b) + 1 } }; a.elasticOut = a.getElasticOut(1, .3); a.getElasticInOut = function(c, b) { var e = 2 * Math.PI; return function(d) { var f = b / e * Math.asin(1 / c); return 1 > (d *= 2) ? -.5 * c * Math.pow(2, 10 * --d) * Math.sin((d - f) * e / b) : c * Math.pow(2, -10 * --d) * Math.sin((d - f) * e / b) * .5 + 1 } }; a.elasticInOut = a.getElasticInOut(1, .3 * 1.5); createjs.Ease = a })(); this.createjs = this.createjs || {}; (function() { function a() { throw "MotionGuidePlugin cannot be instantiated."; } a.priority = 0; a.ID = "MotionGuide"; a.install = function() { createjs.Tween._installPlugin(a); return createjs.Tween.IGNORE }; a.init = function(c, b, e) { "guide" == b && c._addPlugin(a) }; a.step = function(c, b, e) { for (var d in e) if ("guide" === d) { var f = b.props.guide, g = a._solveGuideData(e.guide, f); f.valid = !g; var h = f.endData; c._injectProp("x", h.x); c._injectProp("y", h.y); if (g || !f.orient) break; f.startOffsetRot = (void 0 === b.prev.props.rotation ? c.target.rotation || 0 : b.prev.props.rotation) - f.startData.rotation; if ("fixed" == f.orient) f.endAbsRot = h.rotation + f.startOffsetRot, f.deltaRotation = 0; else { g = void 0 === e.rotation ? c.target.rotation || 0 : e.rotation; h = g - f.endData.rotation - f.startOffsetRot; var k = h % 360; f.endAbsRot = g; switch (f.orient) { case "auto": f.deltaRotation = h; break; case "cw": f.deltaRotation = (k + 360) % 360 + 360 * Math.abs(h / 360 | 0); break; case "ccw": f.deltaRotation = (k - 360) % 360 + -360 * Math.abs(h / 360 | 0) } } c._injectProp("rotation", f.endAbsRot) } }; a.change = function(c, b, e, d, f, g) { if ((d = b.props.guide) && b.props !== b.prev.props && d !== b.prev.props.guide) { if ("guide" === e && !d.valid || "x" == e || "y" == e || "rotation" === e && d.orient) return createjs.Tween.IGNORE; a._ratioToPositionData(f, d, c.target) } }; a.debug = function(c, b, e) { c = c.guide || c; var d = a._findPathProblems(c); d && console.error("MotionGuidePlugin Error found: \n" + d); if (!b) return d; var f, g = c.path, h = g.length; b.save(); b.lineCap = "round"; b.lineJoin = "miter"; b.beginPath(); b.moveTo(g[0], g[1]); for (f = 2; f < h; f += 4) b.quadraticCurveTo(g[f], g[f + 1], g[f + 2], g[f + 3]); b.strokeStyle = "black"; b.lineWidth = 4.5; b.stroke(); b.strokeStyle = "white"; b.lineWidth = 3; b.stroke(); b.closePath(); g = e.length; if (e && g) { h = {}; var k = {}; a._solveGuideData(c, h); for (f = 0; f < g; f++) h.orient = "fixed", a._ratioToPositionData(e[f], h, k), b.beginPath(), b.moveTo(k.x, k.y), b.lineTo(k.x + 9 * Math.cos(.0174533 * k.rotation), k.y + 9 * Math.sin(.0174533 * k.rotation)), b.strokeStyle = "black", b.lineWidth = 4.5, b.stroke(), b.strokeStyle = "red", b.lineWidth = 3, b.stroke(), b.closePath() } b.restore(); return d }; a._solveGuideData = function(c, b) { var e; if (e = a.debug(c)) return e; var d = b.path = c.path; b.orient = c.orient; b.subLines = []; b.totalLength = 0; b.startOffsetRot = 0; b.deltaRotation = 0; b.startData = { ratio: 0 }; b.endData = { ratio: 1 }; b.animSpan = 1; var f = d.length, g, h = {}; var k = d[0]; var n = d[1]; for (e = 2; e < f; e += 4) { var l = d[e]; var t = d[e + 1]; var w = d[e + 2]; var z = d[e + 3]; var v = { weightings: [], estLength: 0, portion: 0 }, G = k; var C = n; for (g = 1; 10 >= g; g++) a._getParamsForCurve(k, n, l, t, w, z, g / 10, !1, h), G = h.x - G, C = h.y - C, C = Math.sqrt(G * G + C * C), v.weightings.push(C), v.estLength += C, G = h.x, C = h.y; b.totalLength += v.estLength; for (g = 0; 10 > g; g++) C = v.estLength, v.weightings[g] /= C; b.subLines.push(v); k = w; n = z } C = b.totalLength; d = b.subLines.length; for (e = 0; e < d; e++) b.subLines[e].portion = b.subLines[e].estLength / C; e = isNaN(c.start) ? 0 : c.start; d = isNaN(c.end) ? 1 : c.end; a._ratioToPositionData(e, b, b.startData); a._ratioToPositionData(d, b, b.endData); b.startData.ratio = e; b.endData.ratio = d; b.animSpan = b.endData.ratio - b.startData.ratio }; a._ratioToPositionData = function(c, b, e) { var d = b.subLines, f, g = 0, h = c * b.animSpan + b.startData.ratio; var k = d.length; for (f = 0; f < k; f++) { var n = d[f].portion; if (g + n >= h) { var l = f; break } g += n } void 0 === l && (l = k - 1, g -= n); d = d[l].weightings; var t = n; k = d.length; for (f = 0; f < k; f++) { n = d[f] * t; if (g + n >= h) break; g += n } l = 4 * l + 2; k = b.path; a._getParamsForCurve(k[l - 2], k[l - 1], k[l], k[l + 1], k[l + 2], k[l + 3], f / 10 + (h - g) / n * .1, b.orient, e); b.orient && (e.rotation = .99999 <= c && 1.00001 >= c && void 0 !== b.endAbsRot ? b.endAbsRot : e.rotation + (b.startOffsetRot + c * b.deltaRotation)); return e }; a._getParamsForCurve = function(c, b, e, d, f, g, h, k, n) { var l = 1 - h; n.x = l * l * c + 2 * l * h * e + h * h * f; n.y = l * l * b + 2 * l * h * d + h * h * g; k && (n.rotation = 57.2957795 * Math.atan2((d - b) * l + (g - d) * h, (e - c) * l + (f - e) * h)) }; a._findPathProblems = function(c) { var b = c.path, e = b && b.length || 0; if (6 > e || (e - 2) % 4) return "\tCannot parse 'path' array due to invalid number of entries in path. There should be an odd number of points, at least 3 points, and 2 entries per point (x & y). See 'CanvasRenderingContext2D.quadraticCurveTo' for details as 'path' models a quadratic bezier.\n\nOnly [ " + (e + " ] values found. Expected: " + Math.max(4 * Math.ceil((e - 2) / 4) + 2, 6)); for (var d = 0; d < e; d++) if (isNaN(b[d])) return "All data in path array must be numeric"; b = c.start; if (isNaN(b) && void 0 !== b) return "'start' out of bounds. Expected 0 to 1, got: " + b; b = c.end; if (isNaN(b) && void 0 !== b) return "'end' out of bounds. Expected 0 to 1, got: " + b; if ((c = c.orient) && "fixed" != c && "auto" != c && "cw" != c && "ccw" != c) return 'Invalid orientation value. Expected ["fixed", "auto", "cw", "ccw", undefined], got: ' + c }; createjs.MotionGuidePlugin = a })(); this.createjs = this.createjs || {}; (function() { var a = createjs.TweenJS = createjs.TweenJS || {}; a.version = "1.0.0"; a.buildDate = "Thu, 14 Sep 2017 19:47:47 GMT" })(); ! function() { var a = "undefined" != typeof window && void 0 !== window.document ? window.document : {}, c = "undefined" != typeof module && module.exports, b = function() { for (var f, g = ["requestFullscreen exitFullscreen fullscreenElement fullscreenEnabled fullscreenchange fullscreenerror".split(" "), "webkitRequestFullscreen webkitExitFullscreen webkitFullscreenElement webkitFullscreenEnabled webkitfullscreenchange webkitfullscreenerror".split(" "), "webkitRequestFullScreen webkitCancelFullScreen webkitCurrentFullScreenElement webkitCancelFullScreen webkitfullscreenchange webkitfullscreenerror".split(" "), "mozRequestFullScreen mozCancelFullScreen mozFullScreenElement mozFullScreenEnabled mozfullscreenchange mozfullscreenerror".split(" "), "msRequestFullscreen msExitFullscreen msFullscreenElement msFullscreenEnabled MSFullscreenChange MSFullscreenError".split(" ") ], h = 0, k = g.length, n = {}; h < k; h++) if ((f = g[h]) && f[1] in a) { for (h = 0; h < f.length; h++) n[g[0][h]] = f[h]; return n } return !1 }(), e = { change: b.fullscreenchange, error: b.fullscreenerror }, d = { request: function(f) { return new Promise(function(g, h) { var k = function() { this.off("change", k); g() }.bind(this); this.on("change", k); f = f || a.documentElement; Promise.resolve(f[b.requestFullscreen]())["catch"](h) }.bind(this)) }, exit: function() { return new Promise(function(f, g) { if (this.isFullscreen) { var h = function() { this.off("change", h); f() }.bind(this); this.on("change", h); Promise.resolve(a[b.exitFullscreen]())["catch"](g) } else f() }.bind(this)) }, toggle: function(f) { return this.isFullscreen ? this.exit() : this.request(f) }, onchange: function(f) { this.on("change", f) }, onerror: function(f) { this.on("error", f) }, on: function(f, g) { var h = e[f]; h && a.addEventListener(h, g, !1) }, off: function(f, g) { var h = e[f]; h && a.removeEventListener(h, g, !1) }, raw: b }; b ? (Object.defineProperties(d, { isFullscreen: { get: function() { return !!a[b.fullscreenElement] } }, element: { enumerable: !0, get: function() { return a[b.fullscreenElement] } }, isEnabled: { enumerable: !0, get: function() { return !!a[b.fullscreenEnabled] } } }), c ? module.exports = d : window.screenfull = d) : c ? module.exports = { isEnabled: !1 } : window.screenfull = { isEnabled: !1 } }(); (function() { function a(B) { B = String(B); return B.charAt(0).toUpperCase() + B.slice(1) } function c(B, r) { var u = -1, F = B ? B.length : 0; if ("number" == typeof F && -1 < F && F <= z) for (; ++u < F;) r(B[u], u, B); else e(B, r) } function b(B) { B = String(B).replace(/^ +| +$/g, ""); return /^(?:webOS|i(?:OS|P))/.test(B) ? B : a(B) } function e(B, r) { for (var u in B) G.call(B, u) && r(B[u], u, B) } function d(B) { return null == B ? a(B) : C.call(B).slice(8, -1) } function f(B, r) { var u = null != B ? typeof B[r] : "number"; return !/^(?:boolean|number|string|undefined)$/.test(u) && ("object" == u ? !!B[r] : !0) } function g(B) { return String(B).replace(/([ -])(?!$)/g, "$1?") } function h(B, r) { var u = null; c(B, function(F, I) { u = r(u, F, I, B) }); return u } function k(B) { function r(ha) { return h(ha, function(da, U) { var ia = U.pattern || g(U); !da && (da = RegExp("\\b" + ia + " *\\d+[.\\w_]*", "i").exec(B) || RegExp("\\b" + ia + " *\\w+-[\\w]*", "i").exec(B) || RegExp("\\b" + ia + "(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)", "i").exec(B)) && ((da = String(U.label && !RegExp(ia, "i").test(U.label) ? U.label : da).split("/"))[1] && !/[\d.]+/.test(da[0]) && (da[0] += " " + da[1]), U = U.label || U, da = b(da[0].replace(RegExp(ia, "i"), U).replace(RegExp("; *(?:" + U + "[_-])?", "i"), " ").replace(RegExp("(" + U + ")[-_.]?(\\w)", "i"), "$1 $2"))); return da }) } function u(ha) { return h(ha, function(da, U) { return da || (RegExp(U + "(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)", "i").exec(B) || 0)[1] || null }) } var F = l, I = B && "object" == typeof B && "String" != d(B); I && (F = B, B = null); var y = F.navigator || {}, D = y.userAgent || ""; B || (B = D); var x = I ? !!y.likeChrome : /\bChrome\b/.test(B) && !/internal|\n/i.test(C.toString()), L = I ? "Object" : "ScriptBridgingProxyObject", P = I ? "Object" : "Environment", S = I && F.java ? "JavaPackage" : d(F.java), ea = I ? "Object" : "RuntimeObject"; P = (S = /\bJava/.test(S) && F.java) && d(F.environment) == P; var T = S ? "a" : "\u03b1", X = S ? "b" : "\u03b2", aa = F.document || {}, ka = F.operamini || F.opera, ma = v.test(ma = I && ka ? ka["[[Class]]"] : d(ka)) ? ma : ka = null, A, la = B; I = []; var fa = null, J = B == D; D = J && ka && "function" == typeof ka.version && ka.version(); var Z = function(ha) { return h(ha, function(da, U) { return da || RegExp("\\b" + (U.pattern || g(U)) + "\\b", "i").exec(B) && (U.label || U) }) }([{ label: "EdgeHTML", pattern: "Edge" }, "Trident", { label: "WebKit", pattern: "AppleWebKit" }, "iCab", "Presto", "NetFront", "Tasman", "KHTML", "Gecko"]), K = function(ha) { return h(ha, function(da, U) { return da || RegExp("\\b" + (U.pattern || g(U)) + "\\b", "i").exec(B) && (U.label || U) }) }(["Adobe AIR", "Arora", "Avant Browser", "Breach", "Camino", "Electron", "Epiphany", "Fennec", "Flock", "Galeon", "GreenBrowser", "iCab", "Iceweasel", "K-Meleon", "Konqueror", "Lunascape", "Maxthon", { label: "Microsoft Edge", pattern: "Edge" }, "Midori", "Nook Browser", "PaleMoon", "PhantomJS", "Raven", "Rekonq", "RockMelt", { label: "Samsung Internet", pattern: "SamsungBrowser" }, "SeaMonkey", { label: "Silk", pattern: "(?:Cloud9|Silk-Accelerated)" }, "Sleipnir", "SlimBrowser", { label: "SRWare Iron", pattern: "Iron" }, "Sunrise", "Swiftfox", "Waterfox", "WebPositive", "Opera Mini", { label: "Opera Mini", pattern: "OPiOS" }, "Opera", { label: "Opera", pattern: "OPR" }, "Chrome", { label: "Chrome Mobile", pattern: "(?:CriOS|CrMo)" }, { label: "Firefox", pattern: "(?:Firefox|Minefield)" }, { label: "Firefox for iOS", pattern: "FxiOS" }, { label: "IE", pattern: "IEMobile" }, { label: "IE", pattern: "MSIE" }, "Safari" ]), V = r([{ label: "BlackBerry", pattern: "BB10" }, "BlackBerry", { label: "Galaxy S", pattern: "GT-I9000" }, { label: "Galaxy S2", pattern: "GT-I9100" }, { label: "Galaxy S3", pattern: "GT-I9300" }, { label: "Galaxy S4", pattern: "GT-I9500" }, { label: "Galaxy S5", pattern: "SM-G900" }, { label: "Galaxy S6", pattern: "SM-G920" }, { label: "Galaxy S6 Edge", pattern: "SM-G925" }, { label: "Galaxy S7", pattern: "SM-G930" }, { label: "Galaxy S7 Edge", pattern: "SM-G935" }, "Google TV", "Lumia", "iPad", "iPod", "iPhone", "Kindle", { label: "Kindle Fire", pattern: "(?:Cloud9|Silk-Accelerated)" }, "Nexus", "Nook", "PlayBook", "PlayStation Vita", "PlayStation", "TouchPad", "Transformer", { label: "Wii U", pattern: "WiiU" }, "Wii", "Xbox One", { label: "Xbox 360", pattern: "Xbox" }, "Xoom" ]), ja = function(ha) { return h(ha, function(da, U, ia) { return da || (U[V] || U[/^[a-z]+(?: +[a-z]+\b)*/i.exec(V)] || RegExp("\\b" + g(ia) + "(?:\\b|\\w*\\d)", "i").exec(B)) && ia }) }({ Apple: { iPad: 1, iPhone: 1, iPod: 1 }, Archos: {}, Amazon: { Kindle: 1, "Kindle Fire": 1 }, Asus: { Transformer: 1 }, "Barnes & Noble": { Nook: 1 }, BlackBerry: { PlayBook: 1 }, Google: { "Google TV": 1, Nexus: 1 }, HP: { TouchPad: 1 }, HTC: {}, LG: {}, Microsoft: { Xbox: 1, "Xbox One": 1 }, Motorola: { Xoom: 1 }, Nintendo: { "Wii U": 1, Wii: 1 }, Nokia: { Lumia: 1 }, Samsung: { "Galaxy S": 1, "Galaxy S2": 1, "Galaxy S3": 1, "Galaxy S4": 1 }, Sony: { PlayStation: 1, "PlayStation Vita": 1 } }), R = function(ha) { return h(ha, function(da, U) { var ia = U.pattern || g(U); if (!da && (da = RegExp("\\b" + ia + "(?:/[\\d.]+|[ \\w.]*)", "i").exec(B))) { var na = da, oa = U.label || U, m = { "10.0": "10", "6.4": "10 Technical Preview", "6.3": "8.1", "6.2": "8", "6.1": "Server 2008 R2 / 7", "6.0": "Server 2008 / Vista", "5.2": "Server 2003 / XP 64-bit", "5.1": "XP", "5.01": "2000 SP1", "5.0": "2000", "4.0": "NT", "4.90": "ME" }; ia && oa && /^Win/i.test(na) && !/^Windows Phone /i.test(na) && (m = m[/[\d.]+$/.exec(na)]) && (na = "Windows " + m); na = String(na); ia && oa && (na = na.replace(RegExp(ia, "i"), oa)); da = na = b(na.replace(/ ce$/i, " CE").replace(/\bhpw/i, "web").replace(/\bMacintosh\b/, "Mac OS").replace(/_PowerPC\b/i, " OS").replace(/\b(OS X) [^ \d]+/i, "$1").replace(/\bMac (OS X)\b/, "$1").replace(/\/(\d)/, " $1").replace(/_/g, ".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i, "").replace(/\bx86\.64\b/gi, "x86_64").replace(/\b(Windows Phone) OS\b/, "$1").replace(/\b(Chrome OS \w+) [\d.]+\b/, "$1").split(" on ")[0]) } return da }) }(["Windows Phone", "Android", "CentOS", { label: "Chrome OS", pattern: "CrOS" }, "Debian", "Fedora", "FreeBSD", "Gentoo", "Haiku", "Kubuntu", "Linux Mint", "OpenBSD", "Red Hat", "SuSE", "Ubuntu", "Xubuntu", "Cygwin", "Symbian OS", "hpwOS", "webOS ", "webOS", "Tablet OS", "Tizen", "Linux", "Mac OS X", "Macintosh", "Mac", "Windows 98;", "Windows " ]); Z && (Z = [Z]); ja && !V && (V = r([ja])); if (A = /\bGoogle TV\b/.exec(V)) V = A[0]; /\bSimulator\b/i.test(B) && (V = (V ? V + " " : "") + "Simulator"); "Opera Mini" == K && /\bOPiOS\b/.test(B) && I.push("running in Turbo/Uncompressed mode"); "IE" == K && /\blike iPhone OS\b/.test(B) ? (A = k(B.replace(/like iPhone OS/, "")), ja = A.manufacturer, V = A.product) : /^iP/.test(V) ? (K || (K = "Safari"), R = "iOS" + ((A = / OS ([\d_]+)/i.exec(B)) ? " " + A[1].replace(/_/g, ".") : "")) : "Konqueror" != K || /buntu/i.test(R) ? ja && "Google" != ja && (/Chrome/.test(K) && !/\bMobile Safari\b/i.test(B) || /\bVita\b/.test(V)) || /\bAndroid\b/.test(R) && /^Chrome/.test(K) && /\bVersion\//i.test(B) ? (K = "Android Browser", R = /\bAndroid\b/.test(R) ? R : "Android") : "Silk" == K ? (/\bMobi/i.test(B) || (R = "Android", I.unshift("desktop mode")), /Accelerated *= *true/i.test(B) && I.unshift("accelerated")) : "PaleMoon" == K && (A = /\bFirefox\/([\d.]+)\b/.exec(B)) ? I.push("identifying as Firefox " + A[1]) : "Firefox" == K && (A = /\b(Mobile|Tablet|TV)\b/i.exec(B)) ? (R || (R = "Firefox OS"), V || (V = A[1])) : !K || (A = !/\bMinefield\b/i.test(B) && /\b(?:Firefox|Safari)\b/.exec(K)) ? (K && !V && /[\/,]|^[^(]+?\)/.test(B.slice(B.indexOf(A + "/") + 8)) && (K = null), (A = V || ja || R) && (V || ja || /\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(R)) && (K = /[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(R) ? R : A) + " Browser")) : "Electron" == K && (A = (/\bChrome\/([\d.]+)\b/.exec(B) || 0)[1]) && I.push("Chromium " + A) : R = "Kubuntu"; D || (D = u(["(?:Cloud9|CriOS|CrMo|Edge|FxiOS|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$))", "Version", g(K), "(?:Firefox|Minefield|NetFront)" ])); if (A = "iCab" == Z && 3 < parseFloat(D) && "WebKit" || /\bOpera\b/.test(K) && (/\bOPR\b/.test(B) ? "Blink" : "Presto") || /\b(?:Midori|Nook|Safari)\b/i.test(B) && !/^(?:Trident|EdgeHTML)$/.test(Z) && "WebKit" || !Z && /\bMSIE\b/i.test(B) && ("Mac OS" == R ? "Tasman" : "Trident") || "WebKit" == Z && /\bPlayStation\b(?! Vita\b)/i.test(K) && "NetFront") Z = [A]; "IE" == K && (A = (/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(B) || 0)[1]) ? (K += " Mobile", R = "Windows Phone " + (/\+$/.test(A) ? A : A + ".x"), I.unshift("desktop mode")) : /\bWPDesktop\b/i.test(B) ? (K = "IE Mobile", R = "Windows Phone 8.x", I.unshift("desktop mode"), D || (D = (/\brv:([\d.]+)/.exec(B) || 0)[1])) : "IE" != K && "Trident" == Z && (A = /\brv:([\d.]+)/.exec(B)) && (K && I.push("identifying as " + K + (D ? " " + D : "")), K = "IE", D = A[1]); if (J) { if (f(F, "global")) if (S && (A = S.lang.System, la = A.getProperty("os.arch"), R = R || A.getProperty("os.name") + " " + A.getProperty("os.version")), P) { try { D = F.require("ringo/engine").version.join("."), K = "RingoJS" } catch (ha) { (A = F.system) && A.global.system == F.system && (K = "Narwhal", R || (R = A[0].os || null)) } K || (K = "Rhino") } else "object" == typeof F.process && !F.process.browser && (A = F.process) && ("object" == typeof A.versions && ("string" == typeof A.versions.electron ? (I.push("Node " + A.versions.node), K = "Electron", D = A.versions.electron) : "string" == typeof A.versions.nw && (I.push("Chromium " + D, "Node " + A.versions.node), K = "NW.js", D = A.versions.nw)), K || (K = "Node.js", la = A.arch, R = A.platform, D = (D = /[\d.]+/.exec(A.version)) ? D[0] : null)); else d(A = F.runtime) == L ? (K = "Adobe AIR", R = A.flash.system.Capabilities.os) : d(A = F.phantom) == ea ? (K = "PhantomJS", D = (A = A.version || null) && A.major + "." + A.minor + "." + A.patch) : "number" == typeof aa.documentMode && (A = /\bTrident\/(\d+)/i.exec(B)) ? (D = [D, aa.documentMode], (A = +A[1] + 4) != D[1] && (I.push("IE " + D[1] + " mode"), Z && (Z[1] = ""), D[1] = A), D = "IE" == K ? String(D[1].toFixed(1)) : D[0]) : "number" == typeof aa.documentMode && /^(?:Chrome|Firefox)\b/.test(K) && (I.push("masking as " + K + " " + D), K = "IE", D = "11.0", Z = ["Trident"], R = "Windows"); R = R && b(R) } D && (A = /(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(D) || /(?:alpha|beta)(?: ?\d)?/i.exec(B + ";" + (J && y.appMinorVersion)) || /\bMinefield\b/i.test(B) && "a") && (fa = /b/i.test(A) ? "beta" : "alpha", D = D.replace(RegExp(A + "\\+?$"), "") + ("beta" == fa ? X : T) + (/\d+\+?/.exec(A) || "")); if ("Fennec" == K || "Firefox" == K && /\b(?:Android|Firefox OS)\b/.test(R)) K = "Firefox Mobile"; else if ("Maxthon" == K && D) D = D.replace(/\.[\d.]+/, ".x"); else if (/\bXbox\b/i.test(V)) "Xbox 360" == V && (R = null), "Xbox 360" == V && /\bIEMobile\b/.test(B) && I.unshift("mobile mode"); else if (!/^(?:Chrome|IE|Opera)$/.test(K) && (!K || V || /Browser|Mobi/.test(K)) || "Windows CE" != R && !/Mobi/i.test(B)) if ("IE" == K && J) try { null === F.external && I.unshift("platform preview") } catch (ha) { I.unshift("embedded") } else(/\bBlackBerry\b/.test(V) || /\bBB10\b/.test(B)) && (A = (RegExp(V.replace(/ +/g, " *") + "/([.\\d]+)", "i").exec(B) || 0)[1] || D) ? (A = [A, /BB10/.test(B)], R = (A[1] ? (V = null, ja = "BlackBerry") : "Device Software") + " " + A[0], D = null) : this != e && "Wii" != V && (J && ka || /Opera/.test(K) && /\b(?:MSIE|Firefox)\b/i.test(B) || "Firefox" == K && /\bOS X (?:\d+\.){2,}/.test(R) || "IE" == K && (R && !/^Win/.test(R) && 5.5 < D || /\bWindows XP\b/.test(R) && 8 < D || 8 == D && !/\bTrident\b/.test(B))) && !v.test(A = k.call(e, B.replace(v, "") + ";")) && A.name && (A = "ing as " + A.name + ((A = A.version) ? " " + A : ""), v.test(K) ? (/\bIE\b/.test(A) && "Mac OS" == R && (R = null), A = "identify" + A) : (A = "mask" + A, K = ma ? b(ma.replace(/([a-z])([A-Z])/g, "$1 $2")) : "Opera", /\bIE\b/.test(A) && (R = null), J || (D = null)), Z = ["Presto"], I.push(A)); else K += " Mobile"; if (A = (/\bAppleWebKit\/([\d.]+\+?)/i.exec(B) || 0)[1]) { A = [parseFloat(A.replace(/\.(\d)$/, ".0$1")), A]; if ("Safari" == K && "+" == A[1].slice(-1)) K = "WebKit Nightly", fa = "alpha", D = A[1].slice(0, -1); else if (D == A[1] || D == (A[2] = (/\bSafari\/([\d.]+\+?)/i.exec(B) || 0)[1])) D = null; A[1] = (/\bChrome\/([\d.]+)/i.exec(B) || 0)[1]; 537.36 == A[0] && 537.36 == A[2] && 28 <= parseFloat(A[1]) && "WebKit" == Z && (Z = ["Blink"]); J && (x || A[1]) ? (Z && (Z[1] = "like Chrome"), A = A[1] || (A = A[0], 530 > A ? 1 : 532 > A ? 2 : 532.05 > A ? 3 : 533 > A ? 4 : 534.03 > A ? 5 : 534.07 > A ? 6 : 534.1 > A ? 7 : 534.13 > A ? 8 : 534.16 > A ? 9 : 534.24 > A ? 10 : 534.3 > A ? 11 : 535.01 > A ? 12 : 535.02 > A ? "13+" : 535.07 > A ? 15 : 535.11 > A ? 16 : 535.19 > A ? 17 : 536.05 > A ? 18 : 536.1 > A ? 19 : 537.01 > A ? 20 : 537.11 > A ? "21+" : 537.13 > A ? 23 : 537.18 > A ? 24 : 537.24 > A ? 25 : 537.36 > A ? 26 : "Blink" != Z ? "27" : "28")) : (Z && (Z[1] = "like Safari"), A = (A = A[0], 400 > A ? 1 : 500 > A ? 2 : 526 > A ? 3 : 533 > A ? 4 : 534 > A ? "4+" : 535 > A ? 5 : 537 > A ? 6 : 538 > A ? 7 : 601 > A ? 8 : "8")); Z && (Z[1] += " " + (A += "number" == typeof A ? ".x" : /[.+]/.test(A) ? "" : "+")); "Safari" == K && (!D || 45 < parseInt(D)) && (D = A) } "Opera" == K && (A = /\bzbov|zvav$/.exec(R)) ? (K += " ", I.unshift("desktop mode"), "zvav" == A ? (K += "Mini", D = null) : K += "Mobile", R = R.replace(RegExp(" *" + A + "$"), "")) : "Safari" == K && /\bChrome\b/.exec(Z && Z[1]) && (I.unshift("desktop mode"), K = "Chrome Mobile", D = null, /\bOS X\b/.test(R) ? (ja = "Apple", R = "iOS 4.3+") : R = null); D && 0 == D.indexOf(A = /[\d.]+$/.exec(R)) && -1 < B.indexOf("/" + A + "-") && (R = String(R.replace(A, "")).replace(/^ +| +$/g, "")); Z && !/\b(?:Avant|Nook)\b/.test(K) && (/Browser|Lunascape|Maxthon/.test(K) || "Safari" != K && /^iOS/.test(R) && /\bSafari\b/.test(Z[1]) || /^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|Web)/.test(K) && Z[1]) && (A = Z[Z.length - 1]) && I.push(A); I.length && (I = ["(" + I.join("; ") + ")"]); ja && V && 0 > V.indexOf(ja) && I.push("on " + ja); V && I.push((/^on /.test(I[I.length - 1]) ? "" : "on ") + V); if (R) { var pa = (A = / ([\d.+]+)$/.exec(R)) && "/" == R.charAt(R.length - A[0].length - 1); R = { architecture: 32, family: A && !pa ? R.replace(A[0], "") : R, version: A ? A[1] : null, toString: function() { var ha = this.version; return this.family + (ha && !pa ? " " + ha : "") + (64 == this.architecture ? " 64-bit" : "") } } }(A = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(la)) && !/\bi686\b/i.test(la) ? (R && (R.architecture = 64, R.family = R.family.replace(RegExp(" *" + A), "")), K && (/\bWOW64\b/i.test(B) || J && /\w(?:86|32)$/.test(y.cpuClass || y.platform) && !/\bWin64; x64\b/i.test(B)) && I.unshift("32-bit")) : R && /^OS X/.test(R.family) && "Chrome" == K && 39 <= parseFloat(D) && (R.architecture = 64); B || (B = null); F = {}; F.description = B; F.layout = Z && Z[0]; F.manufacturer = ja; F.name = K; F.prerelease = fa; F.product = V; F.ua = B; F.version = K && D; F.os = R || { architecture: null, family: null, version: null, toString: function() { return "null" } }; F.parse = k; F.toString = function() { return this.description || "" }; F.version && I.unshift(D); F.name && I.unshift(K); R && K && (R != String(R).split(" ")[0] || R != K.split(" ")[0] && !V) && I.push(V ? "(" + R + ")" : "on " + R); I.length && (F.description = I.join(" ")); return F } var n = { "function": !0, object: !0 }, l = n[typeof window] && window || this, t = n[typeof exports] && exports; n = n[typeof module] && module && !module.nodeType && module; var w = t && n && "object" == typeof global && global; !w || w.global !== w && w.window !== w && w.self !== w || (l = w); var z = Math.pow(2, 53) - 1, v = /\bOpera/; w = Object.prototype; var G = w.hasOwnProperty, C = w.toString, N = k(); "function" == typeof define && "object" == typeof define.amd && define.amd ? (l.platform = N, define(function() { return N })) : t && n ? e(N, function(B, r) { t[r] = B }) : l.platform = N }).call(this); function buildIOSMeta() { for (var a = [{ name: "viewport", content: "width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" }, { name: "apple-mobile-web-app-capable", content: "yes" }, { name: "apple-mobile-web-app-status-bar-style", content: "black" }], c = 0; c < a.length; c++) { var b = document.createElement("meta"); b.name = a[c].name; b.content = a[c].content; var e = window.document.head.querySelector('meta[name="' + b.name + '"]'); e && e.parentNode.removeChild(e); window.document.head.appendChild(b) } } function hideIOSFullscreenPanel() { jQuery(".xxx-ios-fullscreen-message").css("display", "none"); jQuery(".xxx-ios-fullscreen-scroll").css("display", "none"); jQuery(".xxx-game-iframe-full").removeClass("xxx-game-iframe-iphone-se") } function buildIOSFullscreenPanel() { jQuery("body").append('<div class="xxx-ios-fullscreen-message"><div class="xxx-ios-fullscreen-swipe"></div></div><div class="xxx-ios-fullscreen-scroll"></div>') } function showIOSFullscreenPanel() { jQuery(".xxx-ios-fullscreen-message").css("display", "block"); jQuery(".xxx-ios-fullscreen-scroll").css("display", "block") } function __iosResize() { window.scrollTo(0, 0); console.log(window.devicePixelRatio); console.log(window.innerWidth); console.log(window.innerHeight); if ("iPhone" === platform.product) switch (window.devicePixelRatio) { case 2: switch (window.innerWidth) { case 568: 320 !== window.innerHeight && jQuery(".xxx-game-iframe-full").addClass("xxx-game-iframe-iphone-se"); break; case 667: 375 === window.innerHeight ? hideIOSFullscreenPanel() : showIOSFullscreenPanel(); break; case 808: 414 === window.innerHeight ? hideIOSFullscreenPanel() : showIOSFullscreenPanel(); break; default: hideIOSFullscreenPanel() } break; case 3: switch (window.innerWidth) { case 736: 414 === window.innerHeight ? hideIOSFullscreenPanel() : showIOSFullscreenPanel(); break; case 724: 375 === window.innerHeight ? hideIOSFullscreenPanel() : showIOSFullscreenPanel(); break; case 808: 414 === window.innerHeight ? hideIOSFullscreenPanel() : showIOSFullscreenPanel(); break; default: hideIOSFullscreenPanel() } break; default: hideIOSFullscreenPanel() } } function iosResize() { __iosResize(); setTimeout(function() { __iosResize() }, 500) } function iosInIframe() { try { return window.self !== window.top } catch (a) { return !0 } } function isIOSLessThen13() { var a = platform.os, c = a.family.toLowerCase(); a = parseFloat(a.version); return "ios" === c && 13 > a ? !0 : !1 } $(document).ready(function() { platform && "iPhone" === platform.product && "safari" === platform.name.toLowerCase() && isIOSLessThen13() && !iosInIframe() && (buildIOSFullscreenPanel(), buildIOSMeta()) }); jQuery(window).resize(function() { platform && "iPhone" === platform.product && "safari" === platform.name.toLowerCase() && isIOSLessThen13() && !iosInIframe() && iosResize() }); var s_iScaleFactor = 1, s_bIsIphone = !1, s_iOffsetX, s_iOffsetY, s_bFocus = !0; (function(a) { (jQuery.browser = jQuery.browser || {}).mobile = /android|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(ad|hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|tablet|treo|up\.(browser|link)|vodafone|wap|webos|windows (ce|phone)|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4)) })(navigator.userAgent || navigator.vendor || window.opera); $(window).resize(function() { sizeHandler() }); function trace(a) { console.log(a) } function isIOS() { for (var a = "iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";"); a.length;) if (navigator.platform === a.pop()) return s_bIsIphone = !0; return s_bIsIphone = !1 } function isIpad() { var a = -1 !== navigator.userAgent.toLowerCase().indexOf("ipad"); return !a && navigator.userAgent.match(/Mac/) && navigator.maxTouchPoints && 2 < navigator.maxTouchPoints ? !0 : a } function isMobile() { return isIpad() ? !0 : jQuery.browser.mobile } function getSize(a) { var c = a.toLowerCase(), b = window.document, e = b.documentElement; if (void 0 === window["inner" + a]) a = e["client" + a]; else if (window["inner" + a] != e["client" + a]) { var d = b.createElement("body"); d.id = "vpw-test-b"; d.style.cssText = "overflow:scroll"; var f = b.createElement("div"); f.id = "vpw-test-d"; f.style.cssText = "position:absolute;top:-1000px"; f.innerHTML = "<style>@media(" + c + ":" + e["client" + a] + "px){body#vpw-test-b div#vpw-test-d{" + c + ":7px!important}}</style>"; d.appendChild(f); e.insertBefore(d, b.head); a = 7 == f["offset" + a] ? e["client" + a] : window["inner" + a]; e.removeChild(d) } else a = window["inner" + a]; return a } window.addEventListener("orientationchange", onOrientationChange); function onOrientationChange() { window.matchMedia("(orientation: portrait)").matches && sizeHandler(); window.matchMedia("(orientation: landscape)").matches && sizeHandler() } function getIOSWindowHeight() { return document.documentElement.clientWidth / window.innerWidth * window.innerHeight } function getHeightOfIOSToolbars() { var a = (0 === window.orientation ? screen.height : screen.width) - getIOSWindowHeight(); return 1 < a ? a : 0 } function sizeHandler() { window.scrollTo(0, 1); if ($("#canvas_game")) { var a = null !== platform.name && "safari" === platform.name.toLowerCase() ? getIOSWindowHeight() : getSize("Height"); var c = getSize("Width"); s_bFocus && _checkOrientation(c, a); var b = Math.min(a / CANVAS_HEIGHT, c / CANVAS_WIDTH), e = Math.round(CANVAS_WIDTH * b); b = Math.round(CANVAS_HEIGHT * b); if (b < a) { var d = a - b; b += d; e += CANVAS_WIDTH / CANVAS_HEIGHT * d } else e < c && (d = c - e, e += d, b += CANVAS_HEIGHT / CANVAS_WIDTH * d); d = a / 2 - b / 2; var f = c / 2 - e / 2, g = CANVAS_WIDTH / e; if (f * g < -EDGEBOARD_X || d * g < -EDGEBOARD_Y) b = Math.min(a / (CANVAS_HEIGHT - 2 * EDGEBOARD_Y), c / (CANVAS_WIDTH - 2 * EDGEBOARD_X)), e = Math.round(CANVAS_WIDTH * b), b = Math.round(CANVAS_HEIGHT * b), d = (a - b) / 2, f = (c - e) / 2, g = CANVAS_WIDTH / e; s_iOffsetX = -1 * f * g; s_iOffsetY = -1 * d * g; 0 <= d && (s_iOffsetY = 0); 0 <= f && (s_iOffsetX = 0); null !== s_oGame && s_oGame.refreshButtonPos(); null !== s_oMenu && s_oMenu.refreshButtonPos(); null !== s_oDifficultyMenu && s_oDifficultyMenu.refreshButtonPos(); $("#canvas_game").css("width", e + "px"); $("#canvas_game").css("height", b + "px"); $("#canvas_3d").css("width", e + "px"); $("#canvas_3d").css("height", b + "px"); $("#canvas_upper_3d").css("width", e + "px"); $("#canvas_upper_3d").css("height", b + "px"); 0 > d || (d = (a - b) / 2); $("#canvas_game").css("top", d + "px"); $("#canvas_3d").css("top", d + "px"); $("#canvas_upper_3d").css("top", d + "px"); $("#canvas_game").css("left", f + "px"); $("#canvas_3d").css("left", f + "px"); $("#canvas_upper_3d").css("left", f + "px"); fullscreenHandler() } } function _checkOrientation(a, c) { s_bMobile && ENABLE_CHECK_ORIENTATION && (a > c ? "landscape" === $(".orientation-msg-container").attr("data-orientation") ? ($(".orientation-msg-container").css("display", "none"), s_oMain.startUpdate()) : ($(".orientation-msg-container").css("display", "block"), s_oMain.stopUpdate()) : "portrait" === $(".orientation-msg-container").attr("data-orientation") ? ($(".orientation-msg-container").css("display", "none"), s_oMain.startUpdate()) : ($(".orientation-msg-container").css("display", "block"), s_oMain.stopUpdate())) } function createBitmap(a, c, b) { var e = new createjs.Bitmap(a), d = new createjs.Shape; c && b ? d.graphics.beginFill("#fff").drawRect(0, 0, c, b) : d.graphics.beginFill("#ff0").drawRect(0, 0, a.width, a.height); e.hitArea = d; return e } function createSprite(a, c, b, e, d, f) { a = null !== c ? new createjs.Sprite(a, c) : new createjs.Sprite(a); c = new createjs.Shape; c.graphics.beginFill("#000000").drawRect(-b, -e, d, f); a.hitArea = c; return a } function randomFloatBetween(a, c, b) { return parseFloat(Math.min(a + Math.random() * (c - a), c).toFixed(void 0 === b ? 2 : b)) } function shuffle(a) { for (var c = a.length, b, e; 0 !== c;) e = Math.floor(Math.random() * c), --c, b = a[c], a[c] = a[e], a[e] = b; return a } function formatTime(a) { a /= 1E3; var c = Math.floor(a / 60); a = parseFloat(a - 60 * c).toFixed(1); var b = ""; b = 10 > c ? b + ("0" + c + ":") : b + (c + ":"); return 10 > a ? b + ("0" + a) : b + a } this.tweenValue = function(a, c, b) { return a + b * (c - a) }; function NoClickDelay(a) { this.element = a; window.Touch && this.element.addEventListener("touchstart", this, !1) } function shuffle(a) { for (var c = a.length, b, e; 0 < c;) e = Math.floor(Math.random() * c), c--, b = a[c], a[c] = a[e], a[e] = b; return a } NoClickDelay.prototype = { handleEvent: function(a) { switch (a.type) { case "touchstart": this.onTouchStart(a); break; case "touchmove": this.onTouchMove(a); break; case "touchend": this.onTouchEnd(a) } }, onTouchStart: function(a) { a.preventDefault(); this.moved = !1; this.element.addEventListener("touchmove", this, !1); this.element.addEventListener("touchend", this, !1) }, onTouchMove: function(a) { this.moved = !0 }, onTouchEnd: function(a) { this.element.removeEventListener("touchmove", this, !1); this.element.removeEventListener("touchend", this, !1); if (!this.moved) { a = document.elementFromPoint(a.changedTouches[0].clientX, a.changedTouches[0].clientY); 3 == a.nodeType && (a = a.parentNode); var c = document.createEvent("MouseEvents"); c.initEvent("click", !0, !0); a.dispatchEvent(c) } } }; (function() { function a(b) { var e = { focus: "visible", focusin: "visible", pageshow: "visible", blur: "hidden", focusout: "hidden", pagehide: "hidden" }; b = b || window.event; b.type in e ? document.body.className = e[b.type] : (document.body.className = this[c] ? "hidden" : "visible", "hidden" === document.body.className ? (s_oMain.stopUpdate(), s_bFocus = !1) : (s_oMain.startUpdate(), s_bFocus = !0)) } var c = "hidden"; c in document ? document.addEventListener("visibilitychange", a) : (c = "mozHidden") in document ? document.addEventListener("mozvisibilitychange", a) : (c = "webkitHidden") in document ? document.addEventListener("webkitvisibilitychange", a) : (c = "msHidden") in document ? document.addEventListener("msvisibilitychange", a) : "onfocusin" in document ? document.onfocusin = document.onfocusout = a : window.onpageshow = window.onpagehide = window.onfocus = window.onblur = a })(); function ctlArcadeResume() { null !== s_oMain && s_oMain.startUpdate() } function ctlArcadePause() { null !== s_oMain && s_oMain.stopUpdate() } function getParamValue(a) { for (var c = window.location.search.substring(1).split("&"), b = 0; b < c.length; b++) { var e = c[b].split("="); if (e[0] == a) return e[1] } } function playSound(a, c, b) { return !1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile ? (s_aSounds[a].play(), s_aSounds[a].volume(c), s_aSounds[a].loop(b), s_aSounds[a]) : null } function stopSound(a) { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || s_aSounds[a].stop() } function setVolume(a, c) { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || s_aSounds[a].volume(c) } function setMute(a, c) { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || s_aSounds[a].mute(c) } function tweenVolume(a, c, b, e, d, f) { e = void 0 === e ? createjs.Ease.linear : e; if (!1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile) { var g = { from: s_aSounds[a].volume(), to: c }; createjs.Tween.get(g, { override: !0 }).to({ from: g.to }, b, e).on("change", function() { s_aSounds[a].volume(g.from) }).call(function(h) { h.target.removeAllEventListeners(); void 0 !== d && d.call(f) }) } } function isSoundPlaying(a) { return s_aSounds[a].playing() } function radiantsToDegrees(a) { return 180 / Math.PI * a } function degreesToRadiants(a) { return Math.PI / 180 * a } function saveItem(a, c) { s_bStorageAvailable && localStorage.setItem(a, c) } function getItem(a) { return s_bStorageAvailable ? localStorage.getItem(a) : null } function sortByKey(a, c) { return a.sort(function(b, e) { var d = b[c], f = e[c]; return d < f ? -1 : d > f ? 1 : 0 }) } function createGraphicCircle(a, c, b, e) { var d = new createjs.Shape; d.graphics.beginFill(e).drawCircle(a.x, a.y, c); null !== b && createjs.Tween.get(d).to({ alpha: 0, visible: !1 }, b); return d } function createGraphicLine(a, c, b, e, d) { var f = new createjs.Shape; f.graphics.setStrokeStyle(b, "round", "round"); f.graphics.beginStroke(d).moveTo(a.x, a.y).lineTo(c.x, c.y); null !== e && createjs.Tween.get(f).to({ alpha: 0, visible: !1 }, e); return f } function linearFunction(a, c, b, e, d) { return (a - c) * (d - e) / (b - c) + e } function fullscreenHandler() { ENABLE_FULLSCREEN && !1 !== screenfull.isEnabled && (s_bFullscreen = screenfull.isFullscreen, null !== s_oInterface && s_oInterface.resetFullscreenBut(), null !== s_oMenu && s_oMenu.resetFullscreenBut(), null !== s_oDifficultyMenu && s_oDifficultyMenu.resetFullscreenBut()) } if (screenfull.isEnabled) screenfull.on("change", function() { s_bFullscreen = screenfull.isFullscreen; null !== s_oInterface && s_oInterface.resetFullscreenBut(); null !== s_oMenu && s_oMenu.resetFullscreenBut(); null !== s_oDifficultyMenu && s_oDifficultyMenu.resetFullscreenBut() }); function CSpriteLibrary() { var a = {}, c, b, e, d, f, g; this.init = function(h, k, n) { c = {}; e = b = 0; d = h; f = k; g = n }; this.addSprite = function(h, k) { if (a.hasOwnProperty(h)) return !1; var n = new Image; a[h] = c[h] = { szPath: k, oSprite: n, bLoaded: !1 }; b++; return !0 }; this.getSprite = function(h) { return a.hasOwnProperty(h) ? a[h].oSprite : null }; this._onSpritesLoaded = function() { b = 0; f.call(g) }; this._onSpriteLoaded = function() { d.call(g); ++e === b && this._onSpritesLoaded() }; this.loadSprites = function() { for (var h in c) c[h].oSprite.oSpriteLibrary = this, c[h].oSprite.szKey = h, c[h].oSprite.onload = function() { this.oSpriteLibrary.setLoaded(this.szKey); this.oSpriteLibrary._onSpriteLoaded(this.szKey) }, c[h].oSprite.onerror = function(k) { var n = k.currentTarget; setTimeout(function() { c[n.szKey].oSprite.src = c[n.szKey].szPath }, 500) }, c[h].oSprite.src = c[h].szPath }; this.setLoaded = function(h) { a[h].bLoaded = !0 }; this.isLoaded = function(h) { return a[h].bLoaded }; this.getNumSprites = function() { return b } } var CANVAS_WIDTH = 1920, CANVAS_HEIGHT = 1080, EDGEBOARD_X = 126, EDGEBOARD_Y = 100, FPS = 60, FPS_TIME = 1E3 / FPS, DISABLE_SOUND_MOBILE = !1, FONT_GAME = "Montserrat", PRIMARY_FONT_COLOR = "#fff", FONT_STROKE_COLOR = "rgba(0,0,0,0)", STATE_LOADING = 0, STATE_MENU = 1, STATE_GAME = 2, ON_MOUSE_DOWN = 0, ON_MOUSE_UP = 1, ON_MOUSE_OVER = 2, ON_MOUSE_OUT = 3, ON_BALL_INTO_HOLE = 4, ON_BALL_WITH_BALL = 5, ON_BALL_WITH_BANK = 6, ON_LOST = 7, ON_WON = 8, ON_RESTART = 9, ON_EXIT_GAME = 10, ON_SELECT_LANG = 11, SOUNDTRACK_VOLUME_DEFAULT = 1, SOUNDTRACK_VOLUME_IN_GAME = .1, GAME_MODE_EIGHT = 0, GAME_MODE_NINE = 1, GAME_MODE_TIME = 2, GAME_MODE_CPU = 0, GAME_MODE_TWO = 1, STATE_TABLE_PLACE_CUE_BALL_BREAKSHOT = 0, STATE_TABLE_PLACE_CUE_BALL = 1, STATE_TABLE_MOVE_STICK = 2, STATE_TABLE_SHOOT = 3, STATE_TABLE_SHOOTING = 4, COMMAND_STICK_MAX_SPEED = 5, COMMAND_STICK_SPEED_INCREMENT = .05, COMMAND_STICK_START_SPEED = .05, HAND_ANIM_NUM_FRAMES = 20, ON_CUE_PLACEABLE = 0, ON_CUE_NOT_PLACEABLE = 1, PREVISION_TRAJECTORY_COLORS = [ ["#fff", "#f00"], ["#00f", "#f00"] ], EASY = 0, MEDIUM = 1, HARD = 2, GAME_DIFFICULTY_PARAMS = []; GAME_DIFFICULTY_PARAMS[EASY] = [{ max: .99, min: .9 }, { max: .9, min: .85 }, { max: .87, min: .8 }, { max: .8, min: .75 }, { max: .7, min: .6 }]; GAME_DIFFICULTY_PARAMS[MEDIUM] = [{ max: .99, min: .95 }, { max: .97, min: .93 }, { max: .9, min: .87 }, { max: .85, min: .8 }, { max: .83, min: .8 }]; GAME_DIFFICULTY_PARAMS[HARD] = [{ max: .99, min: .99 }, { max: .99, min: .97 }, { max: .97, min: .95 }, { max: .95, min: .93 }, { max: .93, min: .9 }]; var TABLE_CENTER, TABLE_CENTER_COORDINATE, FIELD_POINTS = [{ x: 88, y: 46 }, { x: 130, y: 81 }, { x: 607, y: 81 }, { x: 620, y: 32 }, { x: 659, y: 32 }, { x: 673, y: 81 }, { x: 1150, y: 81 }, { x: 1193, y: 44 }, { x: 1226, y: 77 }, { x: 1189, y: 121 }, { x: 1189, y: 591 }, { x: 1226, y: 636 }, { x: 1193, y: 667 }, { x: 1150, y: 631 }, { x: 673, y: 631 }, { x: 658, y: 679 }, { x: 622, y: 679 }, { x: 607, y: 631 }, { x: 130, y: 631 }, { x: 86, y: 665 }, { x: 55, y: 635 }, { x: 91, y: 592 }, { x: 91, y: 114 }, { x: 53, y: 74 }], HOLE_POINT_TO_DETECT = [ [1, 22][2, 5], [6, 9], [10, 13], [14, 17], [18, 21] ], HOLE_CENTER_POS = [{ x: 95, y: 85 }, { x: 640, y: 72 }, { x: 1185, y: 88 }, { x: 1185, y: 628 }, { x: 640, y: 639 }, { x: 95, y: 628 } ], HOLE_CPU_POINTS = [{ x: 105, y: 97 }, { x: 640, y: 80 }, { x: 1173, y: 97 }, { x: 1173, y: 613 }, { x: 640, y: 632 }, { x: 105, y: 613 }], MAX_FORCE_PER_DISTANCE = 850, TABLE_UPPER_BUMPER = [{ x: 366, y: 63, sprite: "bumper_top_left", regX: 2, regY: 0 }, { x: 915, y: 63, sprite: "bumper_top_right", regX: 2, regY: 0 }, { x: 1206, y: 356, sprite: "bumper_right", regX: 1, regY: 2 }, { x: 915, y: 649, sprite: "bumper_bottom_right", regX: 2, regY: 1 }, { x: 366, y: 649, sprite: "bumper_bottom_left", regX: 2, regY: 1 }, { x: 74, y: 356, sprite: "bumper_left", regX: 0, regY: 2 }], POS_RAIL_EXIT = { x: 250, y: 742 }, OFFSET_X_RAILS = []; OFFSET_X_RAILS[GAME_MODE_EIGHT] = 890; OFFSET_X_RAILS[GAME_MODE_NINE] = 890; OFFSET_X_RAILS[GAME_MODE_TIME] = 890; var TIME_RAILS = 5E3, CUE_BALL_HIT_AREA_DIMENSION = 100, ON_PRESS_DOWN_BALL = "mousedown", ON_PRESS_MOVE_BALL = "pressmove", ON_PRESS_UP_BALL = "pressup", POOL_HOLE_RADIUS = 30, DIST_BALL_HOLE = 66, BALL_DIAMETER = 28, BALL_DIAMETER_QUADRO = Math.pow(BALL_DIAMETER, 2), BALL_RADIUS = BALL_DIAMETER / 2, BALL_RADIUS_QUADRO = Math.pow(BALL_RADIUS, 2), BALL_NUMBER, CUE_BALL_POS = { x: 357, y: 356 }, CUE_BALL_RESPOT_1 = { x: 109, y: 102 }, CUE_BALL_RESPOT_3 = { x: 1168, y: 616 }, RACK_POS, STARTING_RACK_POS = []; STARTING_RACK_POS[GAME_MODE_EIGHT] = [{ x: 916, y: 356 }, { x: 941, y: 370 }, { x: 941, y: 342 }, { x: 966, y: 384 }, { x: 966, y: 356 }, { x: 966, y: 328 }, { x: 991, y: 398 }, { x: 991, y: 370 }, { x: 991, y: 342 }, { x: 991, y: 314 }, { x: 1016, y: 412 }, { x: 1016, y: 384 }, { x: 1016, y: 356 }, { x: 1016, y: 328 }, { x: 1016, y: 300 }]; STARTING_RACK_POS[GAME_MODE_NINE] = [{ x: 916, y: 356 }, { x: 949, y: 376 }, { x: 949, y: 335 }, { x: 982, y: 396 }, { x: 982, y: 356 }, { x: 982, y: 316 }, { x: 1015, y: 376 }, { x: 1015, y: 335 }, { x: 1048, y: 356 }]; STARTING_RACK_POS[GAME_MODE_TIME] = [{ x: 916, y: 356 }, { x: 949, y: 376 }, { x: 949, y: 335 }, { x: 982, y: 396 }, { x: 982, y: 356 }, { x: 982, y: 316 }, { x: 1015, y: 416 }, { x: 1015, y: 376 }, { x: 1015, y: 335 }, { x: 1015, y: 295 }, { x: 1048, y: 436 }, { x: 1048, y: 396 }, { x: 1048, y: 356 }, { x: 1048, y: 316 }, { x: 1048, y: 276 }]; var RECT_COLLISION = new createjs.Rectangle(124, 117, 1037, 483), MAX_SPIN_VALUE = 50, K_IMPACT_BALL = .97, K_FRICTION = .985, K_MIN_FORCE = .016, MAX_POWER_SHOT = 200, MIN_POWER_SHOT = 10, MAX_POWER_FORCE_BALL = 40, MAX_BACK_SPIN_CUE_FORCE = 3, MAIN_TABLE_EDGE = [1, 5, 9, 13, 17, 21], BALL_3D_DIAMETER = BALL_DIAMETER, TEXTURE_NAME = [{ path: "sprites/textures/ball_0.jpg", name: "cue_ball" }, { path: "sprites/textures/ball_1.jpg", name: "ball_1" }, { path: "sprites/textures/ball_2.jpg", name: "ball_2" }, { path: "sprites/textures/ball_3.jpg", name: "ball_3" }, { path: "sprites/textures/ball_4.jpg", name: "ball_4" }, { path: "sprites/textures/ball_5.jpg", name: "ball_5" }, { path: "sprites/textures/ball_6.jpg", name: "ball_6" }, { path: "sprites/textures/ball_7.jpg", name: "ball_7" }, { path: "sprites/textures/ball_8.jpg", name: "ball_8" }, { path: "sprites/textures/ball_9.jpg", name: "ball_9" }, { path: "sprites/textures/ball_10.jpg", name: "ball_10" }, { path: "sprites/textures/ball_11.jpg", name: "ball_11" }, { path: "sprites/textures/ball_12.jpg", name: "ball_12" }, { path: "sprites/textures/ball_13.jpg", name: "ball_13" }, { path: "sprites/textures/ball_14.jpg", name: "ball_14" }, { path: "sprites/textures/ball_15.jpg", name: "ball_15" }], BALL_Z_POSITION = 50, DAMPING_BALL_EFFECT = .9, DEBUG_SHOW_2D_SPRITE = !1, DEBUG_SHOW_TABLE_CENTER_SHAPE = !1, DEBUG_SHOW_HOLE_CENTER_POS_SHAPE = !1, DEBUG_SHOW_EDGE_TABLE = !1, DEBUG_SHOW_RECT_COLLISION = !1, DEBUG_SHOW_CPU_BALL_TRAJECTORY = !1, DEBUG_SHOW_PREDICT_TRAJECTORY_COLLISION = !1, SHOW_TRAJECTORY_UNSUCCESSFUL_SHOTS = !1, TIME_ANIMATION_SHOT_ELASTIC = 1500, TIME_ANIMATION_SHOT_BACK = 300, ADD_POINT_RATIO_EVERY_SHOT_EDGE_COLLISION = 1, ENABLE_FULLSCREEN, ENABLE_CHECK_ORIENTATION, POINTS_FOR_BALL_POT, POINTS_FOR_FAULT, NUM_LANGUAGES = 7, LANG_EN = 0, LANG_ES = 1, LANG_FR = 2, LANG_DE = 3, LANG_PT = 4, LANG_IT = 5, LANG_RU = 6, LANG_CODES = {}; LANG_CODES.en = LANG_EN; LANG_CODES.es = LANG_ES; LANG_CODES.fr = LANG_FR; LANG_CODES.de = LANG_DE; LANG_CODES.pt = LANG_PT; LANG_CODES.it = LANG_IT; LANG_CODES.ru = LANG_RU; function CAreYouSurePanel(a, c, b) { b = void 0 === b ? s_oStage : b; var e, d, f, g, h, k; this._init = function(l, t, w) { e = w; k = new createjs.Shape; k.graphics.beginFill("rgba(0, 0, 0, 0.4").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); k.on("mousedown", function() {}); e.addChild(k); h = new createjs.Container; e.addChild(h); l = s_oSpriteLibrary.getSprite("msg_box"); t = createBitmap(l); t.regX = l.width / 2; t.regY = l.height / 2; h.addChild(t); h.x = CANVAS_WIDTH / 2; h.y = CANVAS_HEIGHT / 2; t = l.width - 200; l = l.height - 200; d = new CTLText(h, 40 - t / 2, -100 - l / 2, t, l, 90, "center", PRIMARY_FONT_COLOR, FONT_GAME, 1.1, 0, 0, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ac purus sit amet eros vulputate semper iaculis ut est.", !0, !0, !0, !1); f = new CGfxButton(150, 80, s_oSpriteLibrary.getSprite("but_yes"), h); f.addEventListener(ON_MOUSE_UP, this._onButYes, this); g = new CGfxButton(-150, 80, s_oSpriteLibrary.getSprite("but_no"), h); g.addEventListener(ON_MOUSE_UP, this._onButNo, this); g.pulseAnimation() }; this._onButYes = function() { n.unload(); a && a() }; this._onButNo = function() { n.unload(); c && c() }; this.changeMessage = function(l, t) { d.refreshText(l); d.setY(t) }; this.setOneButton = function() { g.setVisible(!1); f.setPosition(0, 140); f.pulseAnimation() }; this.unload = function() { g.unload(); f.unload(); k.removeAllEventListeners(); e.removeChild(h); e.removeChild(k); h.removeAllEventListeners() }; var n = this; this._init(a, c, b) } var ON_PRESS_DOWN_BUT_ARROW_LEFT = 0, ON_PRESS_UP_BUT_ARROW_LEFT = 1, ON_PRESS_DOWN_BUT_ARROW_RIGHT = 2, ON_PRESS_UP_BUT_ARROW_RIGHT = 3; function CInputController(a) { function c(v) { v || (v = window.event); v.preventDefault(); if (k && !n[v.keyCode]) { var G = null; switch (v.keyCode) { case 37: G = ON_PRESS_DOWN_BUT_ARROW_RIGHT; break; case 39: G = ON_PRESS_DOWN_BUT_ARROW_LEFT } n[v.keyCode] = !0; z.triggerEvent(G) } } function b(v) { v || (v = window.event); v.preventDefault(); var G = null; switch (v.keyCode) { case 37: G = ON_PRESS_UP_BUT_ARROW_RIGHT; break; case 39: G = ON_PRESS_UP_BUT_ARROW_LEFT } n[v.keyCode] = !1; z.triggerEvent(G) } var e, d, f, g, h, k, n, l, t, w; this._init = function(v) { k = !0; n = []; l = []; t = []; w = []; e = v; f = new createjs.Container; e.addChild(f); s_bMobile ? (v = s_oSpriteLibrary.getSprite("but_arrow_left"), g = new CGfxButton(1280, 0, v, f), g.addEventListenerWithParams(ON_MOUSE_DOWN, this.triggerEvent, this, ON_PRESS_DOWN_BUT_ARROW_LEFT), g.addEventListenerWithParams(ON_MOUSE_UP, this.triggerEvent, this, ON_PRESS_UP_BUT_ARROW_LEFT), v = s_oSpriteLibrary.getSprite("but_arrow_right"), h = new CGfxButton(1480, 0, v, f), h.addEventListenerWithParams(ON_MOUSE_DOWN, this.triggerEvent, this, ON_PRESS_DOWN_BUT_ARROW_RIGHT), h.addEventListenerWithParams(ON_MOUSE_UP, this.triggerEvent, this, ON_PRESS_UP_BUT_ARROW_RIGHT)) : (document.onkeydown = c, document.onkeyup = b); d = f.y = CANVAS_HEIGHT - 115 }; this.setInput = function(v) { k = v }; this._onClick = function(v, G) { k && this.triggerEvent(v, G) }; this.refreshOffsetPos = function() { f.y = d - .5 * s_iOffsetY }; this.unload = function() { s_bMobile || (document.onkeydown = null, document.onkeyup = null); g.unload(); h.unload() }; this.triggerEvent = function(v) { l[v] && l[v].call(t[v], w[v]) }; this.addEventListener = function(v, G, C, N) { l[v] = G; t[v] = C; w[v] = N }; var z = this; this._init(a) } function CPreloader() { var a, c, b, e, d, f, g; this._init = function() { s_oSpriteLibrary.init(this._onImagesLoaded, this._onAllImagesLoaded, this); s_oSpriteLibrary.addSprite("progress_bar", "./sprites/progress_bar.png"); s_oSpriteLibrary.addSprite("mask_progress_bar", "./sprites/mask_progress_bar.png"); s_oSpriteLibrary.addSprite("200x200", "./sprites/200x200.jpg"); s_oSpriteLibrary.loadSprites(); g = new createjs.Container; s_oStage.addChild(g) }; this.unload = function() { g.removeAllChildren() }; this._onImagesLoaded = function() {}; this._onAllImagesLoaded = function() { this.attachSprites(); s_oMain.preloaderReady() }; this.attachSprites = function() { var h = new createjs.Shape; h.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); h.cache(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); g.addChild(h); h = s_oSpriteLibrary.getSprite("200x200"); d = createBitmap(h); d.regX = .5 * h.width; d.regY = .5 * h.height; d.x = CANVAS_WIDTH / 2; d.y = CANVAS_HEIGHT / 2 - 80; g.addChild(d); f = new createjs.Shape; f.graphics.beginFill("rgba(0,0,0,0.01)").drawRoundRect(d.x - 100, d.y - 100, 200, 200, 10); g.addChild(f); d.mask = f; h = s_oSpriteLibrary.getSprite("progress_bar"); b = createBitmap(h); b.x = CANVAS_WIDTH / 2 - h.width / 2; b.y = CANVAS_HEIGHT / 2 + 70; g.addChild(b); a = h.width; e = createBitmap(s_oSpriteLibrary.getSprite("mask_progress_bar")); e.x = b.x + a; e.y = b.y; e.regX = a; g.addChild(e); b.mask = e; c = new createjs.Text(" ", "30px " + FONT_GAME, "#fff"); c.x = CANVAS_WIDTH / 2; c.y = CANVAS_HEIGHT / 2 + 120; c.textBaseline = "alphabetic"; c.textAlign = "center"; g.addChild(c); h = c.getBounds(); c.cache(h.x, h.y, h.width, h.height) }; this.refreshLoader = function(h) { c.text = h + "%"; c.uncache(); var k = c.getBounds(); c.cache(k.x, k.y, k.width, k.height); 100 === h && (s_oMain._allResourcesLoaded(), c.visible = !1, b.visible = !1); e.scaleX = 1 - h / 100 }; this._init() } function CMain(a) { var c, b, e = 0, d = 0, f = STATE_LOADING, g, h; this.initContainer = function() { var k = document.getElementById("canvas_game"); s_oStage = new createjs.Stage(k); s_oStage.preventSelection = !1; createjs.Touch.enable(s_oStage, !0); s_oStageUpper3D = new createjs.Stage(document.getElementById("canvas_upper_3d")); s_bMobile = isMobile(); !1 === s_bMobile && s_oStage.enableMouseOver(20); s_iPrevTime = (new Date).getTime(); createjs.Ticker.framerate = FPS; createjs.Ticker.on("tick", this._update); navigator.userAgent.match(/Windows Phone/i) && (DISABLE_SOUND_MOBILE = !0); s_oSpriteLibrary = new CSpriteLibrary; s_oLocalStorage = new CLocalStorage; g = new CPreloader; }; this.preloaderReady = function() { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || this._initSounds(); this._loadImages(); c = b = !0 }; this.soundLoaded = function() { e++; g.refreshLoader(Math.floor(e / d * 100)) }; this._initSounds = function() { Howler.mute(!s_bAudioActive); s_aSoundsInfo = []; s_aSoundsInfo.push({ path: "./sounds/", filename: "click", loop: !1, volume: 1, ingamename: "click" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "level_win", loop: !1, volume: 1, ingamename: "level_win" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "game_over", loop: !1, volume: 1, ingamename: "game_over" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "ball_collision", loop: !1, volume: 1, ingamename: "ball_collision" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "ball_in_hole", loop: !1, volume: 1, ingamename: "ball_in_hole" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "edge_collision", loop: !1, volume: 1, ingamename: "edge_collision" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "stick_shot", loop: !1, volume: 1, ingamename: "stick_shot" }); s_aSoundsInfo.push({ path: "./sounds/", filename: "soundtrack", loop: !0, volume: 1, ingamename: "soundtrack" }); d += s_aSoundsInfo.length; s_aSounds = []; for (var k = 0; k < s_aSoundsInfo.length; k++) this.tryToLoadSound(s_aSoundsInfo[k], !1) }; this.tryToLoadSound = function(k, n) { setTimeout(function() { s_aSounds[k.ingamename] = new Howl({ src: [k.path + k.filename + ".mp3"], autoplay: !1, preload: !0, loop: k.loop, volume: k.volume, onload: s_oMain.soundLoaded, onloaderror: function(l, t) { for (var w = 0; w < s_aSoundsInfo.length; w++) if (l === s_aSounds[s_aSoundsInfo[w].ingamename]._sounds[0]._id) { s_oMain.tryToLoadSound(s_aSoundsInfo[w], !0); break } }, onplayerror: function(l) { for (var t = 0; t < s_aSoundsInfo.length; t++) if (l === s_aSounds[s_aSoundsInfo[t].ingamename]._sounds[0]._id) { s_aSounds[s_aSoundsInfo[t].ingamename].once("unlock", function() { s_aSounds[s_aSoundsInfo[t].ingamename].play(); "soundtrack" === s_aSoundsInfo[t].ingamename && null !== s_oGame && setVolume("soundtrack", SOUNDTRACK_VOLUME_IN_GAME) }); break } } }) }, n ? 200 : 0) }; this._loadImages = function() { s_oSpriteLibrary.init(this._onImagesLoaded, this._onAllImagesLoaded, this); s_oSpriteLibrary.addSprite("but_play", "./sprites/but_play.png"); s_oSpriteLibrary.addSprite("logo_menu", "./sprites/logo_menu.png"); s_oSpriteLibrary.addSprite("bg_game", "./sprites/bg_game.jpg"); s_oSpriteLibrary.addSprite("but_exit", "./sprites/but_exit.png"); s_oSpriteLibrary.addSprite("bg_menu", "./sprites/bg_menu.jpg"); s_oSpriteLibrary.addSprite("audio_icon", "./sprites/audio_icon.png"); s_oSpriteLibrary.addSprite("logo_ctl", "./sprites/logo_ctl.png"); s_oSpriteLibrary.addSprite("but_credits", "./sprites/but_credits.png"); s_oSpriteLibrary.addSprite("but_fullscreen", "./sprites/but_fullscreen.png"); s_oSpriteLibrary.addSprite("but_settings", "./sprites/but_settings.png"); s_oSpriteLibrary.addSprite("pool_table", "./sprites/pool_table.png"); s_oSpriteLibrary.addSprite("balls", "./sprites/2d_balls.png"); s_oSpriteLibrary.addSprite("stick", "./sprites/stick.png"); s_oSpriteLibrary.addSprite("player_gui", "./sprites/player_gui.png"); s_oSpriteLibrary.addSprite("highlight_player", "./sprites/highlight_player.png"); s_oSpriteLibrary.addSprite("msg_box", "./sprites/msg_box.png"); s_oSpriteLibrary.addSprite("ball_spin_gui", "./sprites/ball_spin_gui.png"); s_oSpriteLibrary.addSprite("ball_spin_token", "./sprites/ball_spin_token.png"); s_oSpriteLibrary.addSprite("but_home", "./sprites/but_home.png"); s_oSpriteLibrary.addSprite("but_restart", "./sprites/but_restart.png"); s_oSpriteLibrary.addSprite("but_lang", "./sprites/but_lang.png"); s_oSpriteLibrary.addSprite("but_next", "./sprites/but_next.png"); s_oSpriteLibrary.addSprite("but_continue", "./sprites/but_continue.png"); s_oSpriteLibrary.addSprite("but_yes", "./sprites/but_yes.png"); s_oSpriteLibrary.addSprite("but_no", "./sprites/but_no.png"); s_oSpriteLibrary.addSprite("vs_man_panel", "./sprites/vs_man_panel.png"); s_oSpriteLibrary.addSprite("vs_pc_panel", "./sprites/vs_pc_panel.png"); s_oSpriteLibrary.addSprite("but_text", "./sprites/but_text.png"); s_oSpriteLibrary.addSprite("ball_shadow", "./sprites/ball_shadow.png"); s_oSpriteLibrary.addSprite("but_arrow_left", "./sprites/but_arrow_left.png"); s_oSpriteLibrary.addSprite("but_arrow_right", "./sprites/but_arrow_right.png"); s_oSpriteLibrary.addSprite("hand_cue_ball", "./sprites/hand_cue_ball.png"); s_oSpriteLibrary.addSprite("shot_bar", "./sprites/shot_bar.png"); s_oSpriteLibrary.addSprite("over_shot_bar", "./sprites/over_shot_bar.png"); for (var k = 0; k < TABLE_UPPER_BUMPER.length; k++) { var n = TABLE_UPPER_BUMPER[k].sprite; s_oSpriteLibrary.addSprite(n, "./sprites/" + n + ".png") } for (k = 0; 4 > k; k++) s_oSpriteLibrary.addSprite("bg_interactive_help_" + k, "./sprites/bg_interactive_help_" + k + ".png"); for (k = 0; k < HAND_ANIM_NUM_FRAMES; k++) s_oSpriteLibrary.addSprite("hand_anim_" + k, "./sprites/hand_anim/hand_anim_" + k + ".png"); d += s_oSpriteLibrary.getNumSprites(); s_oTextureLibrary = []; k = new THREE.LoadingManager; k.onLoad = this._onTexturesLoaded(); d += TEXTURE_NAME.length; var l = new THREE.TextureLoader(k); for (k = 0; k < TEXTURE_NAME.length; k++) n = TEXTURE_NAME[k].name, s_oTextureLibrary[n] = l.load(TEXTURE_NAME[k].path, this._onImagesLoaded); s_oSpriteLibrary.loadSprites() }; this._onTexturesLoaded = function() {}; this._onImagesLoaded = function() { e++; g.refreshLoader(Math.floor(e / d * 100)) }; this._onAllImagesLoaded = function() {}; this._allResourcesLoaded = function() { g.unload(); try { saveItem(LOCALSTORAGE_STRING + "ls_available", "ok") } catch (k) { s_bStorageAvailable = !1 } s_oSoundTrack = playSound("soundtrack", 1, !0); s_oMain.gotoMenu() }; this.gotoMenu = function() { new CMenu; f = STATE_MENU }; this.gotoDifficultyMenu = function() { new CDifficutlyMenu; f = STATE_MENU }; this.gotoGame = function() { h = new CGame; f = STATE_GAME }; this.levelSelected = function(k) { s_iLevelSelected = k; k >= s_iLastLevel && (s_iLastLevel = k) }; this.stopUpdateNoBlockAndTick = function() { b = !1 }; this.startUpdateNoBlockAndTick = function() { b = !0 }; this.stopUpdateNoBlock = function() { c = !1; createjs.Ticker.paused = !0 }; this.startUpdateNoBlock = function() { s_iPrevTime = (new Date).getTime(); c = !0; createjs.Ticker.paused = !1 }; this.stopUpdate = function() { c = !1; createjs.Ticker.paused = !0; $("#block_game").css("display", "block"); !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || Howler.mute(!0) }; this.startUpdate = function() { s_iPrevTime = (new Date).getTime(); c = !0; createjs.Ticker.paused = !1; $("#block_game").css("display", "none"); (!1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile) && s_bAudioActive && Howler.mute(!1) }; this._update = function(k) { if (!1 !== c) { var n = (new Date).getTime(); s_iTimeElaps = n - s_iPrevTime; s_iCntTime += s_iTimeElaps; s_iCntFps++; s_iPrevTime = n; 1E3 <= s_iCntTime && (s_iCurFps = s_iCntFps, s_iCntTime -= 1E3, s_iCntFps = 0); f === STATE_GAME && b && h.update(); void 0 !== s_oStage && s_oStage.update(k); void 0 !== s_oStageUpper3D && s_oStageUpper3D.update(k) } }; s_oMain = this; s_bAudioActive = a.audio_enable_on_startup; ENABLE_FULLSCREEN = a.fullscreen; ENABLE_CHECK_ORIENTATION = a.check_orientation; POINTS_FOR_BALL_POT = a.points_for_ball_pot; POINTS_FOR_FAULT = a.points_for_fault; a = navigator.language.split("-")[0]; s_iCurLang = LANG_CODES[a]; console.log("LANG_CODES[" + navigator.language + "] " + s_iCurLang); refreshLanguage(); this.initContainer() } var s_bMobile, s_bAudioActive = !1, s_iCntTime = 0, s_iTimeElaps = 0, s_iPrevTime = 0, s_iCntFps = 0, s_iCurFps = 0, s_oSoundTrack = null, s_oDrawLayer, s_oStage, s_oStageUpper3D, s_oMain = null, s_oSpriteLibrary, s_oTextureLibrary, s_oLocalStorage, s_bFullscreen = !1, s_bStorageAvailable = !0, s_bInteractiveHelp = !0, s_aSoundsInfo, s_iGameMode = GAME_MODE_EIGHT, s_iPlayerMode = GAME_MODE_CPU, s_iCurLang = LANG_EN, s_iGameDifficulty = EASY; function CTextButton(a, c, b, e, d, f, g, h, k) { d = void 0 === d ? FONT_GAME : d; var n, l, t, w, z, v, G, C, N, B; this._init = function(r, u, F, I, y, D, x, L) { n = !1; l = 1; t = []; w = []; B = createBitmap(F); C = new createjs.Container; C.x = r; C.y = u; C.regX = F.width / 2; C.regY = F.height / 2; s_bMobile || (C.cursor = "pointer"); C.addChild(B, N); k.addChild(C); N = new CTLText(C, 0, 0, F.width - 20, F.height - 20, x, L, D, y, 1, 0, 0, I, !0, !1, !1, !1); this._initListener() }; this.unload = function() { C.off("mousedown", z); C.off("pressup", v); k.removeChild(C) }; this.setVisible = function(r) { C.visible = r }; this.setAlign = function(r) { N.textAlign = r }; this.setTextOffsetX = function(r) { N.setOffsetX(r) }; this.setTextOffsetY = function(r) { N.setOffsetY(r) }; this.setScale = function(r) { l = C.scaleX = C.scaleY = r }; this.enable = function() { n = !1 }; this.disable = function() { n = !0 }; this._initListener = function() { z = C.on("mousedown", this.buttonDown); v = C.on("pressup", this.buttonRelease) }; this.addEventListener = function(r, u, F) { t[r] = u; w[r] = F }; this.addEventListenerWithParams = function(r, u, F, I) { t[r] = u; w[r] = F; G = I }; this.buttonRelease = function() { n || (playSound("click", 1, !1), C.scaleX = l, C.scaleY = l, t[ON_MOUSE_UP] && t[ON_MOUSE_UP].call(w[ON_MOUSE_UP], G)) }; this.buttonDown = function() { n || (C.scaleX = .9 * l, C.scaleY = .9 * l, t[ON_MOUSE_DOWN] && t[ON_MOUSE_DOWN].call(w[ON_MOUSE_DOWN], G)) }; this.setPosition = function(r, u) { C.x = r; C.y = u }; this.tweenPosition = function(r, u, F, I, y, D, x) { createjs.Tween.get(C).wait(I).to({ x: r, y: u }, F, y).call(function() { void 0 !== D && D.call(x) }) }; this.changeText = function(r) { N.refreshText(r) }; this.setX = function(r) { C.x = r }; this.setY = function(r) { C.y = r }; this.getButtonImage = function() { return C }; this.getX = function() { return C.x }; this.getY = function() { return C.y }; this.getSprite = function() { return C }; this.getScale = function() { return C.scaleX }; this._init(a, c, b, e, d, void 0 === f ? "#fff" : f, g, h) } function CGfxButton(a, c, b, e) { var d, f, g, h, k, n, l, t, w; this._init = function(v, G, C) { d = []; f = []; h = []; g = createBitmap(C); g.x = v; g.y = G; g.regX = C.width / 2; g.regY = C.height / 2; n = k = 1; w = !1; s_bMobile || (g.cursor = "pointer"); z.addChild(g); this._initListener() }; this.unload = function() { g.off("mousedown", l); g.off("pressup", t); this.removeAllTweens(); z.removeChild(g) }; this.setVisible = function(v) { g.visible = v }; this.setCursorType = function(v) { g.cursor = v }; this._initListener = function() { l = g.on("mousedown", this.buttonDown); t = g.on("pressup", this.buttonRelease) }; this.addEventListener = function(v, G, C) { d[v] = G; f[v] = C }; this.addEventListenerWithParams = function(v, G, C, N) { d[v] = G; f[v] = C; h[v] = N }; this.buttonRelease = function() { w || (g.scaleX = 0 < k ? k : -k, g.scaleY = n, playSound("click", 1, !1), d[ON_MOUSE_UP] && d[ON_MOUSE_UP].call(f[ON_MOUSE_UP], h[ON_MOUSE_UP])) }; this.buttonDown = function() { w || (g.scaleX = 0 < k ? .9 * k : .9 * -k, g.scaleY = .9 * n, d[ON_MOUSE_DOWN] && d[ON_MOUSE_DOWN].call(f[ON_MOUSE_DOWN], h[ON_MOUSE_DOWN])) }; this.rotation = function(v) { g.rotation = v }; this.getButton = function() { return g }; this.setPosition = function(v, G) { g.x = v; g.y = G }; this.setX = function(v) { g.x = v }; this.setY = function(v) { g.y = v }; this.getButtonImage = function() { return g }; this.getX = function() { return g.x }; this.getY = function() { return g.y }; this.block = function(v) { w = v; g.scaleX = k; g.scaleY = n }; this.setScaleX = function(v) { k = g.scaleX = v }; this.setScale = function(v) { n = k = v; g.scaleX = g.scaleY = v }; this.setRotation = function(v) { g.rotation = v }; this.getX = function() { return g.x }; this.getY = function() { return g.y }; this.setRegPoints = function(v) { g.regX = v.regX; g.regY = v.regY }; this.pulseAnimation = function() { createjs.Tween.get(g, { loop: -1, override: !0 }).to({ scaleX: .9 * k, scaleY: .9 * n }, 850, createjs.Ease.quadOut).to({ scaleX: k, scaleY: n }, 650, createjs.Ease.quadIn) }; this.trebleAnimation = function() { createjs.Tween.get(g, { loop: -1 }).to({ rotation: 5 }, 75, createjs.Ease.quadOut).to({ rotation: -5 }, 140, createjs.Ease.quadIn).to({ rotation: 0 }, 75, createjs.Ease.quadIn).wait(750) }; this.getGraphic = function() { return g }; this.removeAllTweens = function() { createjs.Tween.removeTweens(g) }; var z = void 0 !== e ? e : s_oStage; this._init(a, c, b); return this } function CToggle(a, c, b, e, d) { var f, g, h, k; this._init = function(n, l, t, w) { g = []; h = []; var z = new createjs.SpriteSheet({ images: [t], frames: { width: t.width / 2, height: t.height, regX: t.width / 2 / 2, regY: t.height / 2 }, animations: { state_true: [0], state_false: [1] } }); f = w; k = createSprite(z, "state_" + f, t.width / 2 / 2, t.height / 2, t.width / 2, t.height); k.x = n; k.y = l; k.stop(); k.cursor = "pointer"; d.addChild(k); this._initListener() }; this.unload = function() { k.off("mousedown", this.buttonDown); k.off("pressup", this.buttonRelease); d.removeChild(k) }; this._initListener = function() { k.on("mousedown", this.buttonDown); k.on("pressup", this.buttonRelease) }; this.addEventListener = function(n, l, t) { g[n] = l; h[n] = t }; this.setActive = function(n) { f = n; k.gotoAndStop("state_" + f) }; this.buttonRelease = function() { k.scaleX = 1; k.scaleY = 1; playSound("click", 1, !1); f = !f; k.gotoAndStop("state_" + f); g[ON_MOUSE_UP] && g[ON_MOUSE_UP].call(h[ON_MOUSE_UP], f) }; this.buttonDown = function() { k.scaleX = .9; k.scaleY = .9; g[ON_MOUSE_DOWN] && g[ON_MOUSE_DOWN].call(h[ON_MOUSE_DOWN]) }; this.setPosition = function(n, l) { k.x = n; k.y = l }; this.getButtonImage = function() { return k }; this._init(a, c, b, e) } function CMenu() { var a, c, b, e, d, f, g, h, k, n, l, t, w, z, v, G, C, N, B, r, u, F = null, I = null; this._init = function() { w = createBitmap(s_oSpriteLibrary.getSprite("bg_menu")); s_oStage.addChild(w); d = CANVAS_WIDTH / 2 - 250; f = CANVAS_HEIGHT - 170; v = new CGfxButton(d, f, s_oSpriteLibrary.getSprite("vs_pc_panel"), s_oStage); v.addEventListener(ON_MOUSE_UP, this._onButPlaySingle, this); b = CANVAS_WIDTH / 2 + 250; e = CANVAS_HEIGHT - 170; G = new CGfxButton(b, e, s_oSpriteLibrary.getSprite("vs_man_panel"), s_oStage); G.addEventListener(ON_MOUSE_UP, this._onButPlayTwo, this); var y = s_oSpriteLibrary.getSprite("but_lang"); if (!1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile) { var D = s_oSpriteLibrary.getSprite("audio_icon"); l = CANVAS_WIDTH - D.height / 2 - 10; t = D.height / 2 + 10; C = new CToggle(l, t, D, s_bAudioActive, s_oStage); C.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this); a = l - y.width / NUM_LANGUAGES - 10; c = t } else a = CANVAS_WIDTH - D.width / 4 - 10, c = D.height / 2 + 10; u = new CButLang(a, c, NUM_LANGUAGES, s_iCurLang, y, s_oStage); u.addEventListener(ON_SELECT_LANG, this._onChangeLang, this); D = s_oSpriteLibrary.getSprite("but_credits"); k = D.width / 2 + 10; n = D.height / 2 + 10; N = new CGfxButton(k, n, D, s_oStage); N.addEventListener(ON_MOUSE_UP, this._onButCreditsRelease, this); y = window.document; D = y.documentElement; F = D.requestFullscreen || D.mozRequestFullScreen || D.webkitRequestFullScreen || D.msRequestFullscreen; I = y.exitFullscreen || y.mozCancelFullScreen || y.webkitExitFullscreen || y.msExitFullscreen; !1 === ENABLE_FULLSCREEN && (F = !1); F && screenfull.isEnabled && (D = s_oSpriteLibrary.getSprite("but_fullscreen"), g = k + D.width / 2 + 10, h = n, r = new CToggle(g, h, D, s_bFullscreen, s_oStage), r.addEventListener(ON_MOUSE_UP, this._onFullscreenRelease, this)); y = s_oSpriteLibrary.getSprite("logo_menu"); z = createBitmap(y); z.regX = y.width / 2; z.regY = y.height / 2; z.x = -z.regX; z.y = CANVAS_HEIGHT / 2 - 160; s_oStage.addChild(z); createjs.Tween.get(z, { override: !0 }).to({ x: CANVAS_WIDTH / 2 }, 1E3, createjs.Ease.cubicOut); s_oLocalStorage.isUsed() || (y = new CAreYouSurePanel, y.changeMessage(TEXT_ERR_LS, -170), y.setOneButton()); B = new createjs.Shape; B.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); s_oStage.addChild(B); createjs.Tween.get(B).to({ alpha: 0 }, 1E3, createjs.Ease.cubicOut); $("#canvas_upper_3d").css("pointer-events", "none"); sizeHandler() }; this._onExit = function(y) { B.on("click", function() {}); createjs.Tween.get(z, { override: !0 }).to({ x: CANVAS_WIDTH + z.regX }, 1E3, createjs.Ease.cubicIn); B.visible = !0; createjs.Tween.get(B).to({ alpha: 1 }, 1E3, createjs.Ease.cubicOut).call(y) }; this.unload = function() { v.unload(); N.unload(); G.unload(); if (!1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile) C.unload(), C = null; F && screenfull.isEnabled && r.unload(); u.unload(); B.removeAllEventListeners(); s_oStage.removeAllChildren(); s_oMenu = null }; this.refreshButtonPos = function() { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || C.setPosition(l - s_iOffsetX, s_iOffsetY + t); F && screenfull.isEnabled && r.setPosition(g + s_iOffsetX, h + s_iOffsetY); N.setPosition(k + s_iOffsetX, n + s_iOffsetY); v.setPosition(d, f - s_iOffsetY); G.setPosition(b, e - s_iOffsetY); z.scaleX = z.scaleY = linearFunction(s_iOffsetY, 0, EDGEBOARD_Y, 1, .9); u.setPosition(a - s_iOffsetX, c + s_iOffsetY) }; this._onButPlaySingle = function() { s_iPlayerMode = GAME_MODE_CPU; s_iGameMode = GAME_MODE_EIGHT; this._onExit(function() { s_oMenu.unload(); s_oMain.gotoDifficultyMenu() }) }; this._onButPlayTwo = function() { s_iPlayerMode = GAME_MODE_TWO; s_iGameMode = GAME_MODE_EIGHT; this._onExit(function() { s_oMenu.unload(); s_oMain.gotoGame(); $(s_oMain).trigger("start_session") }) }; this._onChangeLang = function(y) { s_iCurLang = y; refreshLanguage() }; this._onButCreditsRelease = function() { new CCreditsPanel }; this._onAudioToggle = function() { Howler.mute(s_bAudioActive); s_bAudioActive = !s_bAudioActive }; this.resetFullscreenBut = function() { F && screenfull.isEnabled && r.setActive(s_bFullscreen) }; this._onFullscreenRelease = function() { s_bFullscreen ? I.call(window.document) : F.call(window.document.documentElement); sizeHandler() }; s_oMenu = this; this._init() } var s_oMenu = null; function CDifficutlyMenu() { var a, c, b, e, d, f, g, h, k, n, l, t, w, z, v, G, C, N = null, B = null; this._init = function() { k = createBitmap(s_oSpriteLibrary.getSprite("bg_menu")); s_oStage.addChild(k); var r = s_oSpriteLibrary.getSprite("but_lang"), u = s_oSpriteLibrary.getSprite("but_exit"); a = CANVAS_WIDTH - u.width / 2 - 10; c = r.height / 2 + 10; l = new CGfxButton(a, c, u, s_oStage); l.addEventListener(ON_MOUSE_DOWN, this._onMouseDownButExit, this); var F = s_oSpriteLibrary.getSprite("audio_icon"); !1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile ? (g = a - F.width / 2 - 10, h = c, n = new CToggle(g, h, F, s_bAudioActive, s_oStage), n.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this), b = g - r.width / NUM_LANGUAGES - 10, e = h) : (b = a - u.width / 2 - 10, e = c); z = new CButLang(b, e, NUM_LANGUAGES, s_iCurLang, r, s_oStage); z.addEventListener(ON_SELECT_LANG, this._onChangeLang, this); r = window.document; u = r.documentElement; N = u.requestFullscreen || u.mozRequestFullScreen || u.webkitRequestFullScreen || u.msRequestFullscreen; B = r.exitFullscreen || r.mozCancelFullScreen || r.webkitExitFullscreen || r.msExitFullscreen; !1 === ENABLE_FULLSCREEN && (N = !1); N && screenfull.isEnabled && (F = s_oSpriteLibrary.getSprite("but_fullscreen"), d = F.width / 4 + 10, f = F.height / 2 + 10, w = new CToggle(d, f, F, s_bFullscreen, s_oStage), w.addEventListener(ON_MOUSE_UP, this._onFullscreenRelease, this)); v = new CTextButton(CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2 - 200, s_oSpriteLibrary.getSprite("but_text"), TEXT_EASY, FONT_GAME, "#fff", 60, "center", s_oStage); v.setTextOffsetX(10); v.setTextOffsetY(10); v.addEventListenerWithParams(ON_MOUSE_DOWN, this._onPressDownButDifficulty, this, EASY); G = new CTextButton(CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2, s_oSpriteLibrary.getSprite("but_text"), TEXT_MEDIUM, FONT_GAME, "#fff", 60, "center", s_oStage); G.addEventListenerWithParams(ON_MOUSE_DOWN, this._onPressDownButDifficulty, this, MEDIUM); G.setTextOffsetX(10); G.setTextOffsetY(10); C = new CTextButton(CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2 + 200, s_oSpriteLibrary.getSprite("but_text"), TEXT_HARD, FONT_GAME, "#fff", 60, "center", s_oStage); C.setTextOffsetX(10); C.setTextOffsetY(10); C.addEventListenerWithParams(ON_MOUSE_DOWN, this._onPressDownButDifficulty, this, HARD); t = new createjs.Shape; t.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); s_oStage.addChild(t); createjs.Tween.get(t).to({ alpha: 0 }, 1E3, createjs.Ease.cubicOut); sizeHandler(); v.changeText(TEXT_EASY); G.changeText(TEXT_MEDIUM); C.changeText(TEXT_HARD) }; this._onPressDownButDifficulty = function(r) { s_iGameDifficulty = r; this._onExit(function() { s_oDifficultyMenu.unload(); s_oMain.gotoGame(); $(s_oMain).trigger("start_session") }) }; this._onMouseDownButExit = function() { this._onExit(function() { s_oDifficultyMenu.unload(); s_oMain.gotoMenu() }) }; this._onExit = function(r) { t.on("click", function() {}); t.visible = !0; createjs.Tween.get(t).to({ alpha: 1 }, 1E3, createjs.Ease.cubicOut).call(r) }; this.unload = function() { v.unload(); G.unload(); C.unload(); if (!1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile) n.unload(), n = null; N && screenfull.isEnabled && w.unload(); z.unload(); t.removeAllEventListeners(); s_oStage.removeAllChildren(); s_oDifficultyMenu = null }; this.refreshButtonPos = function() { !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || n.setPosition(g - s_iOffsetX, s_iOffsetY + h); N && screenfull.isEnabled && w.setPosition(d + s_iOffsetX, f + s_iOffsetY); z.setPosition(b - s_iOffsetX, e + s_iOffsetY); l.setPosition(a - s_iOffsetX, c + s_iOffsetY) }; this._onChangeLang = function(r) { s_iCurLang = r; refreshLanguage(); v.changeText(TEXT_EASY); G.changeText(TEXT_MEDIUM); C.changeText(TEXT_HARD) }; this._onAudioToggle = function() { Howler.mute(s_bAudioActive); s_bAudioActive = !s_bAudioActive }; this.resetFullscreenBut = function() { N && screenfull.isEnabled && w.setActive(s_bFullscreen) }; this._onFullscreenRelease = function() { s_bFullscreen ? B.call(window.document) : N.call(window.document.documentElement); sizeHandler() }; s_oDifficultyMenu = this; this._init() } var s_oDifficultyMenu = null; function CGame() { var a = !1, c, b, e, d, f, g, h, k, n, l, t, w, z, v, G, C, N, B, r, u, F, I, y, D; this._init = function() { b = 1; e = 0; I = c = !1; y = 1; D = COMMAND_STICK_START_SPEED; G = 0; switch (s_iGameMode) { case GAME_MODE_NINE: BALL_NUMBER = 9; break; case GAME_MODE_EIGHT: BALL_NUMBER = 15; break; case GAME_MODE_TIME: BALL_NUMBER = 15 } RACK_POS = STARTING_RACK_POS[s_iGameMode]; w = new createjs.Container; s_oStage.addChild(w); var x = createBitmap(s_oSpriteLibrary.getSprite("bg_game")); w.addChild(x); z = new createjs.Container; w.addChild(z); v = new createjs.Container; s_oStage.addChild(v); l = new CInterface(v); f = new CScene; t = new CTable(z, GAME_DIFFICULTY_PARAMS[s_iGameDifficulty]); t.addEventListener(ON_LOST, this.gameOver, this); t.addEventListener(ON_WON, this.showWinPanel, this); n = null; h = new CPlayerGUI(CANVAS_WIDTH / 2 - 400, 40, TEXT_PLAYER1, s_oStage); k = new CPlayerGUI(CANVAS_WIDTH / 2 + 400, 40, TEXT_PLAYER2, s_oStage); s_iPlayerMode === GAME_MODE_CPU && (n = new CScoreGUI(CANVAS_WIDTH / 2, 40, s_oStage)); 1 === b ? (h.highlight(), k.unlight()) : (k.highlight(), h.unlight()); s_iGameMode === GAME_MODE_NINE && this.setNextBallToHit(1); N = new createjs.Container; s_oStage.addChild(N); B = new CInputController(N); B.addEventListener(ON_PRESS_DOWN_BUT_ARROW_LEFT, this._onPressDownStickCommand, this, -1); B.addEventListener(ON_PRESS_UP_BUT_ARROW_LEFT, this._onPressUpStickCommand, this); B.addEventListener(ON_PRESS_DOWN_BUT_ARROW_RIGHT, this._onPressDownStickCommand, this, 1); B.addEventListener(ON_PRESS_UP_BUT_ARROW_RIGHT, this._onPressUpStickCommand, this); u = new createjs.Container; s_oStageUpper3D.addChild(u); F = new createjs.Container; s_oStage.addChild(F); s_bMobile && (r = new CShotPowerBar(u, 123, 260, F)); var L = new createjs.Shape; L.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); s_oStageUpper3D.addChild(L); tweenVolume("soundtrack", SOUNDTRACK_VOLUME_IN_GAME, 1E3); g = new CGameOverPanel(s_oStageUpper3D); g.addEventListener(ON_EXIT_GAME, this.onExit, this); g.addEventListener(ON_RESTART, this.restartGame, this); C = null; s_bInteractiveHelp ? (C = new CInteractiveHelp(s_oStageUpper3D), C.addEventListener(ON_END_TUTORIAL, this._onEndTutorial, this), $("#canvas_upper_3d").css("pointer-events", "initial"), s_bInteractiveHelp = !1) : this._onEndTutorial(); createjs.Tween.get(L).to({ alpha: 0 }, 1E3, createjs.Ease.cubicIn).call(function() { s_oStageUpper3D.removeChild(L); s_oGame._startInteractiveHelp() }); this.refreshButtonPos(); sizeHandler(); createjs.Tween.get(f).wait(s_iTimeElaps).call(f.update, null, f) }; this._startInteractiveHelp = function() { C && (s_bMobile ? (C.startTutorial({ tutorial: TUTORIAL_MOVE_STICK_MOBILE, info: { movement: !1, on_show_tutorial: void 0 } }), C.startTutorial({ tutorial: TUTORIAL_SHOT_MOBILE, info: { movement: !1, on_show_tutorial: void 0, param: r } }), C.startTutorial({ tutorial: TUTORIAL_MOVE_STICK_BUTTONS, info: { movement: !1, on_show_tutorial: void 0 } })) : C.startTutorial({ tutorial: TUTORIAL_SHOT_DESKTOP, info: { movement: !1, on_show_tutorial: void 0, param: r } }), C.startTutorial({ tutorial: TUTORIAL_CUE_EFFECT, info: { movement: !1, on_show_tutorial: void 0 } }), C.startTutorial({ tutorial: TUTORIAL_RESPOT_CUE, info: { movement: !1, on_show_tutorial: void 0 } })) }; this._onMouseDownPowerBar = function() { s_oTable.startToShot() }; this._onPressMovePowerBar = function(x) { s_oTable.holdShotStickMovement(x) }; this._onPressUpPowerBar = function() { s_oTable.startStickAnimation() && r.setInput(!1) }; this.hideShotBar = function() { s_bMobile && r.hide() }; this.showShotBar = function() { s_bMobile && r.show() }; this._onEndTutorial = function() { $("#canvas_upper_3d").css("pointer-events", "none"); a = !0; s_bMobile && (r.initEventListener(), r.addEventListener(ON_MOUSE_DOWN_POWER_BAR, this._onMouseDownPowerBar, this), r.addEventListener(ON_PRESS_MOVE_POWER_BAR, this._onPressMovePowerBar, this), r.addEventListener(ON_PRESS_UP_POWER_BAR, this._onPressUpPowerBar, this), r.show()); C && (C.unload(), C = null) }; this._onPressDownStickCommand = function(x) { y = x; I = !0; D = COMMAND_STICK_START_SPEED }; this._onPressUpStickCommand = function() { I = !1 }; this.unload = function(x, L) { x = void 0 === x ? null : x; a = !1; var P = new createjs.Shape; P.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); P.alpha = 0; s_oStageUpper3D.addChild(P); createjs.Tween.get(P).to({ alpha: 1 }, 700, createjs.Ease.cubicIn).call(function() { t.unload(); l.unload(); f.unload(); g.unload(); s_oStageUpper3D.removeAllChildren(); s_oStage.removeAllChildren(); null !== x && x.call(L) }) }; this.reset = function() { b = 1; c = !1 }; this.refreshButtonPos = function() { l.refreshButtonPos(); h.refreshButtonPos(); k.refreshButtonPos(); B.refreshOffsetPos(); F.x = u.x = .5 * s_iOffsetX; C && C.refreshButtonsPos(); n && n.refreshButtonPos() }; this.setNextBallToHit = function(x) { 1 === b ? (k.setBallVisible(!1), h.setBall(x)) : (h.setBallVisible(!1), k.setBall(x)) }; this.changeTurn = function(x) { 1 === b ? (b = 2, s_oTable.isCpuTurn() || s_oGame.showShotBar(), k.highlight(), h.unlight()) : (b = 1, h.highlight(), k.unlight(), s_oGame.showShotBar()); s_oInterface.resetSpin(); x ? new CEffectText(TEXT_FAULT, s_oStageUpper3D) : new CEffectText(TEXT_CHANGE_TURN, s_oStageUpper3D) }; this.assignSuits = function(x) { d = []; 8 > x ? 1 === b ? (d[0] = "solid", d[1] = "stripes", this.setBallInInterface("solid")) : (d[0] = "stripes", d[1] = "solid", this.setBallInInterface("stripes")) : 1 === b ? (d[0] = "stripes", d[1] = "solid", this.setBallInInterface("stripes")) : (d[0] = "solid", d[1] = "stripes", this.setBallInInterface("solid")); c = !0 }; this.setBallInInterface = function(x) { "solid" == x ? (h.setBall(2), k.setBall(15)) : (h.setBall(15), k.setBall(2)) }; this.isLegalShotFor8Ball = function(x, L) { return c ? "solid" == d[b - 1] && 8 > x ? !0 : "stripes" == d[b - 1] && 8 < x ? !0 : 8 == x && 0 == L ? !0 : !1 : 8 != x ? !0 : !1 }; this.increaseWinStreak = function() { e++ }; this.resetWinStreak = function() { e = 0 }; this.gameOver = function(x) { g.show(x); $("#canvas_upper_3d").css("pointer-events", "initial"); a = !1 }; this.showWinPanel = function(x) { g.show(x, s_iGameMode === GAME_MODE_CPU ? G : void 0); $("#canvas_upper_3d").css("pointer-events", "initial"); a = !1 }; this.onExit = function() { f.update(); tweenVolume("soundtrack", SOUNDTRACK_VOLUME_DEFAULT, 1E3); this.unload(s_oMain.gotoMenu, s_oMain); $(s_oMain).trigger("show_interlevel_ad"); $(s_oMain).trigger("end_session") }; this.restartGame = function() { f.update(); this.unload(s_oMain.gotoGame, s_oMain); $(s_oMain).trigger("show_interlevel_ad"); $(s_oMain).trigger("end_session") }; this.updateScore = function(x) { n && (x = G + x, G = 0 > x ? 0 : x, n.refreshScore(G), n.highlight()) }; this.getCurTurn = function() { return b }; this.getNextTurn = function() { return 1 === b ? 2 : 1 }; this.getSuiteForCurPlayer = function() { return d[b - 1] }; this.isSuiteAssigned = function() { return c }; this.getPlayer1Name = function() { return h.getPlayerName() }; this.getPlayer2Name = function() { return k.getPlayerName() }; this._updateInput = function() { I && (t.rotateStick(y * D), D += COMMAND_STICK_SPEED_INCREMENT, D >= COMMAND_STICK_MAX_SPEED && (D = COMMAND_STICK_MAX_SPEED)) }; this.update = function() { !1 !== a && (this._updateInput(), t.update(), f.update()) }; s_oGame = this; this._init() } var s_oGame = null; function CInterface(a) { var c, b, e, d, f, g, h, k, n, l, t, w = null, z = null, v, G; this._init = function(C) { h = C; k = new createjs.Container; h.addChild(k); C = s_oSpriteLibrary.getSprite("but_exit"); c = CANVAS_WIDTH - C.width / 2 - 10; b = C.height / 2 + 10; n = new CGfxButton(c, b, C, k); n.addEventListener(ON_MOUSE_UP, this._onExit, this); !1 === DISABLE_SOUND_MOBILE || !1 === s_bMobile ? (f = c - C.width, g = b, C = s_oSpriteLibrary.getSprite("audio_icon"), l = new CToggle(f, g, C, s_bAudioActive, k), l.addEventListener(ON_MOUSE_UP, this._onAudioToggle, this), e = f - C.width / 2, d = g) : (e = c - C.width, d = b); C = window.document; var N = C.documentElement; w = N.requestFullscreen || N.mozRequestFullScreen || N.webkitRequestFullScreen || N.msRequestFullscreen; z = C.exitFullscreen || C.mozCancelFullScreen || C.webkitExitFullscreen || C.msExitFullscreen; !1 === ENABLE_FULLSCREEN && (w = !1); w && screenfull.isEnabled && (C = s_oSpriteLibrary.getSprite("but_fullscreen"), t = new CToggle(e, d, C, s_bFullscreen, k), t.addEventListener(ON_MOUSE_UP, this._onFullscreenRelease, this)); C = s_oSpriteLibrary.getSprite("but_settings"); v = new CGUIExpandible(c, b, C, k); v.addButton(n); !1 !== DISABLE_SOUND_MOBILE && !1 !== s_bMobile || v.addButton(l); w && screenfull.isEnabled && v.addButton(t); G = new CBallSpinGUI(CANVAS_WIDTH / 2 - 480, CANVAS_HEIGHT - 115, k); this.refreshButtonPos() }; this.unload = function() { n.unload(); n = null; v.unload(); G.unload(); !1 === DISABLE_SOUND_MOBILE && (l.unload(), l = null); w && screenfull.isEnabled && t.unload(); k.removeAllChildren(); s_oInterface = null }; this.refreshButtonPos = function() { v.refreshPos(); G.refreshOffsetPos(0, .5 * -s_iOffsetY) }; this.resetSpin = function() { G.resetSpin() }; this.getSideSpin = function() { return G.getSideSpin() }; this.getBackSpin = function() { return G.getBackSpin() }; this.setSideSpin = function(C) { G.setSideSpin(C) }; this._onExit = function() { s_oGame.onExit() }; this._onAudioToggle = function() { Howler.mute(s_bAudioActive); s_bAudioActive = !s_bAudioActive }; this.resetFullscreenBut = function() { w && screenfull.isEnabled && t.setActive(s_bFullscreen) }; this._onFullscreenRelease = function() { s_bFullscreen ? z.call(window.document) : w.call(window.document.documentElement); sizeHandler() }; s_oInterface = this; this._init(a); return this } var s_oInterface = null, CAMERA_SCENARIO; function CScene() { var a, c; this._init = function() { a = new THREE.Scene; CAMERA_SCENARIO = new THREE.OrthographicCamera(CANVAS_WIDTH / -2, CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2, CANVAS_HEIGHT / -2, 1, 1E3); CAMERA_SCENARIO.position.z = 100; CAMERA_SCENARIO.zoom = 1; a.add(CAMERA_SCENARIO); CAMERA_SCENARIO.updateProjectionMatrix(); var b = new THREE.SpotLight(16777215); b.position.set(0, 0, 500); b.penumbra = .1; b.power = .75 * Math.PI; a.add(b); b = new THREE.AmbientLight(16777215, .3); a.add(b); c = new THREE.WebGLRenderer({ antialias: !0, canvas: $("#canvas_3d")[0], alpha: !0, precision: "lowp", powerPreference: "low-power" }); c.shadowMap.enabled = !1; c.setSize(CANVAS_WIDTH, CANVAS_HEIGHT); c.gammaFactor = 2.2 }; this.create3DBall = function(b, e, d) { e = new THREE.SphereGeometry(e, 16, 16); b = new THREE.MeshPhongMaterial({ specular: 2236962, shininess: 80, map: b }); b = new THREE.Mesh(e, b); b.castShadow = !0; b.receiveShadow = !0; a.add(b); b.position.copy(d); return b }; this.consoleInfoRenderer = function() { console.log(c.info) }; this.update = function() { c.render(a, CAMERA_SCENARIO) }; this.unload = function() { c.clear(); a = c = null }; this._init(); s_oScenario = this } var s_oScenario; function CCreditsPanel() { var a, c, b, e, d, f, g, h, k, n; this._init = function() { n = new createjs.Container; s_oStage.addChild(n); var l = new createjs.Shape; l.graphics.beginFill("rgba(0,0,0,0.7)").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); n.addChild(l); l = s_oSpriteLibrary.getSprite("msg_box"); e = createBitmap(l); e.regX = l.width / 2; e.regY = l.height / 2; e.x = CANVAS_WIDTH / 2; e.y = CANVAS_HEIGHT / 2; n.addChild(e); h = new createjs.Shape; h.graphics.beginFill("#0f0f0f").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); h.alpha = .01; b = h.on("click", this._onLogoButRelease); n.addChild(h); var t = s_oSpriteLibrary.getSprite("but_exit"); a = e.x + l.width / 2 - t.width / 2 - 20; c = e.y - l.height / 2 + t.height / 2 + 34; f = new CGfxButton(a, c, t, n); f.addEventListener(ON_MOUSE_UP, this.unload, this); g = new createjs.Text(TEXT_CREDITS_DEVELOPED, "28px " + FONT_GAME, "#fff"); g.textAlign = "center"; g.textBaseline = "alphabetic"; g.x = CANVAS_WIDTH / 2; g.y = 475; n.addChild(g); l = g.getBounds(); g.cache(l.x, l.y, l.width, l.height); t = s_oSpriteLibrary.getSprite("logo_ctl"); d = createBitmap(t); d.regX = t.width / 2; d.regY = t.height / 2; d.x = CANVAS_WIDTH / 2; d.y = CANVAS_HEIGHT / 2; n.addChild(d); k = new createjs.Text("www.codethislab.com", "28px " + FONT_GAME, "#fff"); k.textAlign = "center"; k.textBaseline = "alphabetic"; k.x = CANVAS_WIDTH / 2; k.y = 620; n.addChild(k); l = k.getBounds(); k.cache(l.x, l.y, l.width, l.height) }; this.unload = function() { h.off("click", b); f.unload(); f = null; s_oStage.removeChild(n) }; this._onLogoButRelease = function() { window.open("http://www.codethislab.com/index.php?&l=en", "_blank") }; this._init() } function CTable(a, c) { var b, e, d, f, g, h, k, n, l, t, w, z, v, G, C, N, B, r, u, F, I, y, D, x, L, P, S, ea, T, X, aa, ka, ma, A, la, fa, J, Z, K, V, ja, R, pa, ha, da, U, ia, na, oa; this._init = function(m) { v = []; G = []; oa = []; na = m; this.reset(); m = s_oSpriteLibrary.getSprite("pool_table"); TABLE_CENTER = { x: CANVAS_WIDTH / 2 - m.width / 4, y: CANVAS_HEIGHT / 2 - m.height / 4 }; R = new createjs.Container; s_oStageUpper3D.addChild(R); K = new createjs.Container; R.x = K.x = CANVAS_WIDTH / 2 - m.width / 2; R.y = K.y = CANVAS_HEIGHT / 2 - m.height / 2; a.addChild(K); var p = createBitmap(m); K.addChild(p); TABLE_CENTER_COORDINATE = new CVector2(CANVAS_WIDTH / 2 - m.width / 4, CANVAS_HEIGHT / 2 - m.height / 4); DEBUG_SHOW_TABLE_CENTER_SHAPE && this._createGraphicCenterTableShape(); this._initTableEdges(); DEBUG_SHOW_RECT_COLLISION && (p = new createjs.Shape, p.graphics.beginStroke("red").drawRect(RECT_COLLISION.x, RECT_COLLISION.y, RECT_COLLISION.width, RECT_COLLISION.height), R.addChild(p)); la = new createjs.Shape; la.graphics.beginFill("red").drawRect(-150, -150, m.width + 300, m.height - 60 + 300); la.alpha = .01; la.cache(-150, -150, m.width + 300, m.height - 60 + 300); S = la.on("mousedown", this._onPressHitArea); K.addChild(la); this.initBalls(); J.enableEvents(); J.addEventListener(ON_PRESS_DOWN_BALL, this._onPressDownCueBall, this); V = new createjs.Container; R.addChild(V); ja = new createjs.Container; ja.visible = !1; K.addChild(ja); this._createTableDownUpperBumper(); fa = new CStick(R); this.initStick(); U = ON_CUE_PLACEABLE; m = new createjs.Graphics; aa = new createjs.Shape(m); K.addChild(aa); m = new createjs.Graphics; ka = new createjs.Shape(m); K.addChild(ka); m = new createjs.Graphics; ma = new createjs.Shape(m); K.addChild(ma); m = (new createjs.Graphics).beginStroke("#fff").drawCircle(0, 0, BALL_DIAMETER / 2); A = new createjs.Shape(m); A.visible = !1; K.addChild(A); if (DEBUG_SHOW_HOLE_CENTER_POS_SHAPE) for (m = 0; m < HOLE_CENTER_POS.length; m++) p = createGraphicCircle(HOLE_CENTER_POS[m], BALL_RADIUS, null, "#fff"), K.addChild(p); X = new CPhysicsController(K); X.addEventListener(ON_BALL_INTO_HOLE, this._onBallInHole, this); X.addEventListener(ON_BALL_WITH_BALL, this._onCollisionBallWithBall, this); X.addEventListener(ON_BALL_WITH_BANK, this._onCollisionBallWithEdge, this); da = h = STATE_TABLE_PLACE_CUE_BALL_BREAKSHOT; this._placeCueBall(); this.updateStick(); D.set(1, 0); this.renderStickDirection(); pa = new CHandBallDrag(R); pa.setPos(J.getX(), J.getY()); pa.show(); DEBUG_SHOW_EDGE_TABLE && this.renderEdges() }; this._createTableDownUpperBumper = function() { for (var m = 0; m < TABLE_UPPER_BUMPER.length; m++) { var p = s_oSpriteLibrary.getSprite(TABLE_UPPER_BUMPER[m].sprite), q = createBitmap(p); q.x = TABLE_UPPER_BUMPER[m].x; q.y = TABLE_UPPER_BUMPER[m].y; var E = p.width / TABLE_UPPER_BUMPER[m].regX, H = p.height / TABLE_UPPER_BUMPER[m].regY; q.regX = Infinity === E ? 0 : E; q.regY = Infinity === H ? 0 : H; V.addChild(q); p = createBitmap(p); p.x = q.x; p.y = q.y; p.regX = q.regX; p.regY = q.regY; ja.addChild(p) } }; this._createGraphicCenterTableShape = function() { var m = createGraphicCircle({ x: TABLE_CENTER_COORDINATE.getX(), y: TABLE_CENTER_COORDINATE.getY() }, 10, null, "rgba(255,255,255,1)"); K.addChild(m) }; this.addEventListener = function(m, p, q) { v[m] = p; G[m] = q }; this._onCollisionBallWithBall = function(m, p, q) { 0 !== q && (m = linearFunction(q, .1, 40, .05, 1), this._playTableSound("ball_collision", m, 100)) }; this._playTableSound = function(m, p, q) { for (var E = !0, H = 0, M = (new Date).getTime(), Q = 0; Q < oa.length; Q++) oa[Q].time > H && oa[Q].name === m && (H = oa[Q].time); M - H < q && (E = !1); E && (p = playSound(m, p, !1), p.once("play", function(O) { oa.push({ time: M, id: O, name: m }) }), p.once("end", function(O) { for (var ba = 0; ba < oa.lenght; ba++) if (oa[ba].id === O) { oa.splice(ba, 1); break } })); return E }; this._onBallInHole = function(m) { s_iGameMode == GAME_MODE_TIME ? 0 != m.getNumber() ? (l = 9 == m.getNumber() ? l + 3 * POINTS_FOR_BALL_POT : l + POINTS_FOR_BALL_POT, s_oInterface.updateScore(l), 14 != F.length && (C++, F.push(m.getNumber())), I.push(m.getNumber())) : l > POINTS_FOR_BALL_POT && (l -= POINTS_FOR_BALL_POT, s_oInterface.updateScore(l)) : 0 !== m.getNumber() ? (C++, F.push(m.getNumber()), I.push(m.getNumber())) : g = !0; var p = m.getCurForceLen(); p = linearFunction(p, .1, 40, .2, 1); playSound("ball_in_hole", p, !1); 0 !== m.getNumber() && (p = m.getCurForceLen(), p = linearFunction(p, 0, 13, 700, 100), m.fadeAnimInHole(p)); p = J.getEdgeCollisionCount(); m = m.getEdgeCollisionCount() + p; l += POINTS_FOR_BALL_POT * (0 >= m ? 1 : m) * t; t++ }; this._onCollisionBallWithEdge = function(m, p) { p = void 0 === p ? null : p; var q = m.getCurForceLen(); if (0 !== q && (q = linearFunction(q, .1, 40, .1, 1), this._playTableSound("edge_collision", q, 100), p)) { q = p.getID(); for (var E = 0; E < MAIN_TABLE_EDGE.length; E++) MAIN_TABLE_EDGE[E] === q && m.increaseEdgeCollisionCount() } }; this.reset = function() { g = e = b = !1; f = !0; l = ia = C = N = 0; n = t = 1; F = []; I = []; z = []; d = !0; w = [7, 7]; k = 0 }; this.unload = function() { la.off("mousedown", S); la.removeAllEventListeners(); s_oTable = null }; this._initTableEdges = function() { y = []; for (var m = 0; m < FIELD_POINTS.length - 1; m++) { var p = new CEdge(FIELD_POINTS[m].x, FIELD_POINTS[m].y, FIELD_POINTS[m + 1].x, FIELD_POINTS[m + 1].y, m); y.push(p) } p = new CEdge(FIELD_POINTS[FIELD_POINTS.length - 1].x, FIELD_POINTS[FIELD_POINTS.length - 1].y, FIELD_POINTS[0].x, FIELD_POINTS[0].y, FIELD_POINTS.length - 1); y.push(p) }; this.renderEdges = function() { for (var m = 0; m < y.length; m++) y[m].render(V) }; this.initBalls = function() { Z = new createjs.Container; K.addChild(Z); u = []; J = new CBall(0, Z, s_oTextureLibrary.cue_ball); J.setPos(CUE_BALL_POS.x, CUE_BALL_POS.y); u[0] = J; for (var m = 1; m < BALL_NUMBER + 1; m++) { var p = new CBall(m, Z, s_oTextureLibrary["ball_" + m]); u[m] = p; u[m].setFlagOnTable(!0) } this.setInitBallsPosition(); F = [] }; this.setFirstBallCollision = function(m) { z.push(m) }; this.setInitBallsPosition = function() { switch (s_iGameMode) { case GAME_MODE_NINE: for (var m = [1, 2, 3, 5, 6, 7, 8], p = 2; p < BALL_NUMBER; p++) { var q = Math.floor(Math.random() * m.length); u[p].setPos(RACK_POS[m[q]].x, RACK_POS[m[q]].y); m.splice(q, 1) } u[0].setPos(CUE_BALL_POS.x, CUE_BALL_POS.y); u[1].setPos(RACK_POS[0].x, RACK_POS[0].y); u[9].setPos(RACK_POS[4].x, RACK_POS[4].y); break; case GAME_MODE_EIGHT: m = [0, 1, 2, 3, 5, 6, 7, 8, 9, 11, 12, 13]; var E = Math.floor(7 * Math.random()) + 9, H = Math.floor(7 * Math.random()) + 1; for (p = 1; p < BALL_NUMBER + 1; p++) 8 != p && p != E && p != H && (q = Math.floor(Math.random() * m.length), u[p].setPos(RACK_POS[m[q]].x, RACK_POS[m[q]].y), m.splice(q, 1)); u[E].setPos(RACK_POS[10].x, RACK_POS[10].y); u[H].setPos(RACK_POS[14].x, RACK_POS[14].y); u[8].setPos(RACK_POS[4].x, RACK_POS[4].y); break; case GAME_MODE_TIME: m = [0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; for (p = 1; p < BALL_NUMBER; p++) 9 !== p && (q = Math.floor(Math.random() * m.length), u[p].setPos(RACK_POS[m[q]].x, RACK_POS[m[q]].y), m.splice(q, 1)); u[0].setPos(CUE_BALL_POS.x, CUE_BALL_POS.y); u[9].setPos(RACK_POS[4].x, RACK_POS[4].y) } u.forEach(function(M) { this._update3DObjectTransformation(M) }, this) }; this.initStick = function() { P = new CVector2; P.set(-1, 0); D = new CVector2(1, 0); x = new CVector2; L = new CVector2 }; this.hitBall = function() { k *= .2; D.scalarProduct(k); J.addForce(D) }; this.startToShot = function() { pa.hide(); h = STATE_TABLE_MOVE_STICK; b = !0 }; this._onPressHitArea = function(m) { !J.isBallOnTable() || s_iPlayerMode === GAME_MODE_CPU && 2 === s_oGame.getCurTurn() || !X.areBallsStopped() || e || (s_bMobile || s_oTable.startToShot(), J.setDragging(!1), m = K.globalToLocal(s_oStage.mouseX, s_oStage.mouseY), x.set(m.x, m.y), ha = radiantsToDegrees(Math.atan2(J.getPos().getY() - m.y, J.getPos().getX() - m.x)), 0 > ha ? ha += 360 : 360 < ha && (ha -= 360), s_bMobile && (ea = la.on("pressmove", s_oTable._onPressMoveHitArea)), T = la.on("pressup", s_oTable._onReleaseHitArea)) }; this._onPressMoveHitArea = function(m) { m = K.globalToLocal(m.stageX, m.stageY); m = radiantsToDegrees(Math.atan2(J.getPos().getY() - m.y, J.getPos().getX() - m.x)); 0 > m ? m += 360 : 360 < m && (m -= 360); s_oTable.rotateStick(-(m - ha)); ha = m }; this.startStickAnimation = function() { return s_oTable._moveStick() }; this._moveStick = function(m, p) { b = !1; var q = k >= MIN_POWER_SHOT; q ? (d = !1, e = !0, J.setSideEffect(s_oInterface.getSideSpin())) : (h = da, h !== STATE_TABLE_PLACE_CUE_BALL && h !== STATE_TABLE_PLACE_CUE_BALL_BREAKSHOT || pa.show()); return q }; this._onReleaseHitArea = function() { la.off("pressmove", ea); la.off("pressup", T); if (!s_bMobile) switch (h) { case STATE_TABLE_MOVE_STICK: s_oTable._moveStick({ x: s_oStage.mouseX, y: s_oStage.mouseY }, x) } }; this._onPressDownCueBall = function(m) { s_iPlayerMode === GAME_MODE_CPU && 2 === s_oGame.getCurTurn() || h !== STATE_TABLE_PLACE_CUE_BALL_BREAKSHOT && h !== STATE_TABLE_PLACE_CUE_BALL || (J.addEventListener(ON_PRESS_MOVE_BALL, this._onPressMoveCueBall, this), J.addEventListener(ON_PRESS_UP_BALL, this._onPressUpCueBall, this), J.setFlagOnTable(!1), fa.setVisible(!0), pa.setPos(J.getX(), J.getY())) }; this._onPressMoveCueBall = function(m) { this._moveCueBall({ x: m.stageX, y: m.stageY }); this.updateStick(); this.renderStickDirection(); this._checkCueBallCollisionWithTableElements() ? (s_oGame.hideShotBar(), U = ON_CUE_NOT_PLACEABLE) : (s_oGame.showShotBar(), U = ON_CUE_PLACEABLE); pa.setPos(J.getX(), J.getY()) }; this._onPressUpCueBall = function() { J.removeEventListener(ON_PRESS_MOVE_BALL); J.removeEventListener(ON_PRESS_UP_BALL); this._placeCueBall(); this.updateStick(); this.renderStickDirection(); pa.setPos(J.getX(), J.getY()) }; this._checkCueBallCollisionWithTableElements = function() { if (J.getX() > CUE_BALL_RESPOT_1.x && J.getX() < CUE_BALL_RESPOT_3.x && J.getY() > CUE_BALL_RESPOT_1.y && J.getY() < CUE_BALL_RESPOT_3.y) { var m = new CVector2; m.set(J.getX(), J.getY()); for (var p = 1; p < BALL_NUMBER + 1; p++) if (distance2(m, u[p].getPos()) <= BALL_DIAMETER_QUADRO) return !0 } return !1 }; this._placeCueBall = function() { this._checkCueBallCollisionWithTableElements() || (V.visible = !0, ja.visible = !1, J.setDragging(!1), J.setFlagOnTable(!0)) }; this._moveCueBall = function(m) { m = K.globalToLocal(m.x, m.y); m.y - BALL_RADIUS > FIELD_POINTS[1].y && m.y + BALL_RADIUS < FIELD_POINTS[13].y && J.setY(m.y); h === STATE_TABLE_PLACE_CUE_BALL && m.x + BALL_RADIUS < FIELD_POINTS[9].x && m.x - BALL_RADIUS > FIELD_POINTS[21].x && J.setX(m.x) }; this._checkCpuBallCollision = function(m, p, q, E, H) { var M = new CVector2, Q = new CVector2, O = new CVector2; O.setV(m); O.subtract(p); m = O.length(); O.normalize(); M.setV(O); Q.setV(O); M.rot90CCW(); Q.rot90CW(); M.scalarProduct(BALL_RADIUS); Q.scalarProduct(BALL_RADIUS); M.add(p); Q.add(p); p = new CVector2; var ba = new CVector2; p.setV(O); ba.setV(O); p.scalarProduct(m); ba.scalarProduct(m); p.add(M); ba.add(Q); O = new CEdge; O.set(Q.getX(), Q.getY(), ba.getX(), ba.getY()); Q = new CEdge; Q.set(M.getX(), M.getY(), p.getX(), p.getY()); M = !1; p = { iDistance: 0, vClosestPoint: new CVector2 }; for (m = 0; m < BALL_NUMBER + 1; m++) m != q && m != E && (collideEdgeWithCircle(O, u[m].getPos(), BALL_RADIUS, p) && (M = !0, H.push({ ball: u[m], point: p.vClosestPoint })), collideEdgeWithCircle(Q, u[m].getPos(), BALL_RADIUS, p) && (M = !0, H.push({ ball: u[m], point: p.vClosestPoint }))); return M }; this.renderStickDirection = function() { aa.graphics.clear(); ka.graphics.clear(); ma.graphics.clear(); A.x = CANVAS_WIDTH + 100; A.y = CANVAS_HEIGHT + 100; if (!1 === b) if (e) { var m = new CVector2, p = new CVector2; p.set(fa.getX(), fa.getY()); N += s_iTimeElaps; if (100 < k) var q = easeElasticIn(N, 0, 1, TIME_ANIMATION_SHOT_ELASTIC, -1); else q = easeBackIn(N, 0, 1, TIME_ANIMATION_SHOT_BACK), k < MIN_POWER_SHOT && (k = MIN_POWER_SHOT); m = tweenVectors(p, J.getPos(), m, q); N >= B && (s_oGame.hideShotBar(), p = linearFunction(k, MIN_POWER_SHOT, MAX_POWER_SHOT, .3, 1), playSound("stick_shot", p, !1), N = 0, e = !1, k *= .2, D.scalarProduct(k), J.addForce(D), D.normalize(), q = .5 * s_oInterface.getSideSpin() * Math.sign(D.getX()), p = .5 * s_oInterface.getBackSpin() * Math.sign(D.getY()), q += p * D.getX(), p -= q * Math.sign(D.getX()), J.setEffectForceX(-q), J.setEffectForceY(-p), J.getEffectForceVector().add(D), fa.setVisible(!1), h = STATE_TABLE_SHOOTING); fa.setPos(m.getX(), m.getY()) } else { p = []; q = new CVector2; var E = 1280 * D.getX() + J.getX(); m = 1280 * D.getY() + J.getY(); q.set(E, m); m = new CVector2; m.setV(q); m.subtract(J.getPos()); m.normalize(); this._checkCpuBallCollision(q, J.getPos(), 0, 0, p); for (E = 0; E < p.length; E++) p[E].ball.isBallOnTable() || (p.splice(E, 1), E--); if (0 < p.length) { var H = distance(J.getPos(), p[0].ball.getPos()); E = 0; for (var M = 1; M < p.length; M++) if (p[M].ball.isBallOnTable()) { var Q = distance(J.getPos(), p[M].ball.getPos()); Q < H && (H = Q, E = M) }(new CEdge). set(J.getX(), J.getY(), q.getX(), q.getY()); H = new CVector2; H.setV(m); H.scalarProduct(1.5); q = new CVector2; for (q.setV(J.getPos()); distance(q, p[E].ball.getPos()) > BALL_DIAMETER + 1;) q.add(H); H = new CVector2; H.setV(p[E].ball.getPos()); H.subtract(q); H.normalize(); new CVector2; H.invert(); H = reflectVectorV2(H, m); H.normalize(); H.scalarProduct(48); m = new CVector2; m.setV(q); m.add(H); H = new CVector2; H.setV(p[E].ball.getPos()); H.subtract(q); H.normalize(); H.scalarProduct(72); p = new CVector2; p.setV(q); p.add(H); A.visible = !0; A.x = q.getX(); A.y = q.getY(); aa.graphics.setStrokeStyle(4).beginStroke(PREVISION_TRAJECTORY_COLORS[0][U]).moveTo(J.getX(), J.getY()).lineTo(q.getX(), q.getY()); ka.graphics.setStrokeStyle(4).beginStroke(PREVISION_TRAJECTORY_COLORS[0][U]).moveTo(q.getX(), q.getY()).lineTo(m.getX(), m.getY()); ma.graphics.setStrokeStyle(4).beginStroke(PREVISION_TRAJECTORY_COLORS[1][U]).moveTo(q.getX(), q.getY()).lineTo(p.getX(), p.getY()) } else { (new CEdge).set(J.getX(), J.getY(), q.getX(), q.getY()); new CEdge; Q = J.getPos(); p = y; E = new CVector2; H = new CVector2; M = new CVector2; M.setV(q); M.subtract(Q); q = M.length(); M.normalize(); E.setV(M); H.setV(M); E.rot90CCW(); H.rot90CW(); E.scalarProduct(BALL_RADIUS); H.scalarProduct(BALL_RADIUS); E.add(Q); H.add(Q); Q = new CVector2; var O = new CVector2; Q.setV(M); O.setV(M); Q.scalarProduct(q); O.scalarProduct(q); Q.add(E); O.add(H); q = new CEdge; q.set(H.getX(), H.getY(), O.getX(), O.getY()); H = new CEdge; H.set(E.getX(), E.getY(), Q.getX(), Q.getY()); E = new CEdge; M = !1; for (Q = 0; Q < p.length; Q++) { if (collideEdgeWithEdge(q, p[Q])) { E = p[Q]; M = !0; break } if (collideEdgeWithEdge(H, p[Q])) { E = p[Q]; M = !0; break } } p = M ? E : null; if (null !== p) { q = new CVector2; H = new CVector2; H.setV(m); H.scalarProduct(2); for (q.setV(J.getPos()); !collideEdgeWithCircle(p, q, BALL_RADIUS);) q.add(H); A.visible = !0; A.x = q.getX(); A.y = q.getY(); aa.graphics.beginStroke(PREVISION_TRAJECTORY_COLORS[0][U]).moveTo(J.getX(), J.getY()).lineTo(q.getX(), q.getY()) } else A.visible = !1, aa.graphics.beginStroke(PREVISION_TRAJECTORY_COLORS[0][U]).moveTo(J.getX(), J.getY()).lineTo(J.getX() + D.getX() * r, J.getY() + D.getY() * r) } fa.setPos(J.getX(), J.getY()); p = toDegree(angleBetweenVectors(P, D)); D.getX(); J.getX(); m = 1280 * D.getY() + J.getY(); m > J.getY() && (p = 180 - p + 180); fa.setRotation(p + 180) } else fa.setPos(J.getX() + L.getX() * k, J.getY() + L.getY() * k) }; this.updateStick = function() { var m = new CVector2, p = K.globalToLocal(s_oStage.mouseX, s_oStage.mouseY); m.set(p.x, p.y); if (!1 === b) if (!0 === e) N += s_iTimeElaps, N > B && (N = B); else { if (p = !s_bMobile && J.isBallOnTable()) D.setV(m), D.subtract(J.getPos()); r = D.length(); p && D.normalize(); L.setV(D); L.invert() } else s_bMobile || (m.subtract(x), m = m.length(), this.holdShotStickMovement(m)) }; this.holdShotStickMovement = function(m) { k = m; k > MAX_POWER_SHOT && (k = MAX_POWER_SHOT); B = 100 < k ? TIME_ANIMATION_SHOT_ELASTIC : TIME_ANIMATION_SHOT_BACK }; this.renderBalls = function() { for (var m = 0; m < u.length; m++) s_iPlayerMode === GAME_MODE_CPU && 2 === s_oGame.getCurTurn() ? u[m].render(!0) : u[m].render(!1) }; this.respotCueBall = function() { J.setDragging(!0); h = STATE_TABLE_PLACE_CUE_BALL; V.visible = !1; ja.visible = !0; if (s_iPlayerMode !== GAME_MODE_CPU || 2 !== s_oGame.getCurTurn()) da = h, J.setPos(CUE_BALL_POS.x, CUE_BALL_POS.y), fa.setVisible(!0), pa.setPos(J.getX(), J.getY(0)), pa.show() }; this.rotateStick = function(m) { h === STATE_TABLE_SHOOT || h === STATE_TABLE_SHOOTING || s_iPlayerMode === GAME_MODE_CPU && 2 === s_oGame.getCurTurn() || e || (rotateVector2D(toRadian(m), D), this.updateStick(), this.renderStickDirection()) }; this.checkTurn = function() { var m = !1, p = !1; switch (s_iGameMode) { case GAME_MODE_NINE: var q = z[0]; if (0 < z.length && q.getNumber() === n) { if (g) { if (g = !1, s_oGame.changeTurn(), this.respotCueBall(), !1 === u[9].isBallOnTable()) { q = !1; for (var E = 0; !q;) { u[9].setPos(RACK_POS[4].x + E, RACK_POS[4].y); q = !0; for (var H = 0; 8 > H; H++) { var M = distance2(u[9].getPos(), u[H].getPos()); if (M <= BALL_DIAMETER_QUADRO) { q = !1; break } E += BALL_RADIUS } } u[9].setFlagOnTable(!0); u[9].setVisible(!0) } } else { if (0 < I.length) for (q = 0; q < I.length; q++) { if (9 == I[q]) { u[9].setVisible(!0); s_iPlayerMode == GAME_MODE_CPU ? 2 == s_oGame.getCurTurn() ? (v[ON_END_GAME] && v[ON_LOST].call(G[ON_LOST]), s_oGame.resetWinStreak()) : (v[ON_WON] && v[ON_WON].call(G[ON_WON], "YOU"), s_oGame.increaseWinStreak()) : 1 == s_oGame.getCurTurn() ? v[ON_WON] && v[ON_WON].call(G[ON_WON], s_oGame.getPlayer1Name()) : v[ON_WON] && v[ON_WON].call(G[ON_WON], s_oGame.getPlayer2Name()); return } } else s_oGame.changeTurn(); fa.setVisible(!0) } f = !1 } else { if (f) J.setPos(CUE_BALL_POS.x, CUE_BALL_POS.y), s_oGame.changeTurn(), this.targetting(!0); else { if (0 == u[9].isBallOnTable()) { q = !1; for (E = 0; !q;) for (u[9].setPos(RACK_POS[4].x + E, RACK_POS[4].y), q = !0, H = 0; 8 > H; H++) { M = distance2(u[9].getPos(), u[H].getPos()); if (M <= BALL_DIAMETER_QUADRO) { q = !1; break } E += BALL_RADIUS } u[9].setFlagOnTable(!0); u[9].setVisible(!0) } s_oGame.changeTurn(); this.respotCueBall(); f = !1 } g = !1 } z.splice(0); I.splice(0); break; case GAME_MODE_EIGHT: if (!1 === u[8].isBallOnTable()) { 0 === w[s_oGame.getCurTurn() - 1] ? s_iPlayerMode == GAME_MODE_CPU ? 2 == s_oGame.getCurTurn() ? (v[ON_LOST] && v[ON_LOST].call(G[ON_LOST], TEXT_GAME_OVER, l), s_oGame.resetWinStreak()) : (v[ON_WON] && v[ON_WON].call(G[ON_WON], TEXT_YOU_WON, l), s_oGame.increaseWinStreak()) : 1 === s_oGame.getCurTurn() ? v[ON_WON] && v[ON_WON].call(G[ON_WON], sprintf(TEXT_PLAYER_NAME_WON, s_oGame.getPlayer1Name()), l) : v[ON_WON] && v[ON_WON].call(G[ON_WON], sprintf(TEXT_PLAYER_NAME_WON, s_oGame.getPlayer2Name()), l) : s_iPlayerMode == GAME_MODE_CPU ? 2 == s_oGame.getCurTurn() ? (v[ON_WON] && v[ON_WON].call(G[ON_WON], TEXT_YOU_WON, l), s_oGame.increaseWinStreak()) : (v[ON_LOST] && v[ON_LOST].call(G[ON_LOST], TEXT_GAME_OVER, l), s_oGame.resetWinStreak()) : 1 == s_oGame.getCurTurn() ? v[ON_WON] && v[ON_WON].call(G[ON_WON], sprintf(TEXT_PLAYER_NAME_WON, s_oGame.getPlayer2Name()), l) : v[ON_WON] && v[ON_WON].call(G[ON_WON], sprintf(TEXT_PLAYER_NAME_WON, s_oGame.getPlayer1Name()), l); return } if (g) for (g = !1, s_oGame.changeTurn(!0), m = p = !0, this._assignSuit(), this.respotCueBall(), q = 0; q < I.length; q++) s_oGame.isLegalShotFor8Ball(I[q]) ? w[s_oGame.getCurTurn() - 1]-- : w[s_oGame.getNextTurn() - 1]--; else if (0 !== z.length && s_oGame.isLegalShotFor8Ball(z[0].getNumber(), w[s_oGame.getCurTurn() - 1])) if (0 < I.length) if (this._assignSuit()) 0 == w[s_oGame.getCurTurn() - 1] && s_oGame.setNextBallToHit(8), fa.setVisible(!(s_iPlayerMode === GAME_MODE_CPU && 2 === s_oGame.getCurTurn())); else if (s_oGame.isLegalShotFor8Ball(I[0])) { E = !0; w[s_oGame.getCurTurn() - 1]--; if (1 < I.length) { for (q = 1; q < I.length; q++) s_oGame.isLegalShotFor8Ball(I[q]) ? w[s_oGame.getCurTurn() - 1]-- : (E = !1, w[s_oGame.getNextTurn() - 1]--); 0 == w[s_oGame.getCurTurn() - 1] && s_oGame.setNextBallToHit(8); m = E; E || (s_oGame.changeTurn(!0), p = !0) } 0 == w[s_oGame.getCurTurn() - 1] && s_oGame.setNextBallToHit(8); fa.setVisible(!(s_iPlayerMode === GAME_MODE_CPU && 2 === s_oGame.getCurTurn())) } else { s_oGame.changeTurn(!0); m = p = !0; this.respotCueBall(); for (q = 0; q < I.length; q++) s_oGame.isLegalShotFor8Ball(I[q]) ? w[s_oGame.getCurTurn() - 1]-- : w[s_oGame.getNextTurn() - 1]--; 0 === w[s_oGame.getCurTurn() - 1] && s_oGame.setNextBallToHit(8) } else s_oGame.changeTurn(!1), p = !0, fa.setVisible(!(s_iPlayerMode === GAME_MODE_CPU && 2 === s_oGame.getCurTurn())); else { for (q = 0; q < I.length; q++) s_oGame.isLegalShotFor8Ball(I[q]) ? w[s_oGame.getCurTurn() - 1]-- : w[s_oGame.getNextTurn() - 1]--; 0 == w[s_oGame.getCurTurn() - 1] && s_oGame.setNextBallToHit(8); s_oGame.changeTurn(!0); m = p = !0; this.respotCueBall() } z.splice(0); I.splice(0) } J.isDragging() || (s_iPlayerMode === GAME_MODE_CPU ? 1 === s_oGame.getCurTurn() ? (da = h = STATE_TABLE_MOVE_STICK, s_oGame.showShotBar()) : h = STATE_TABLE_SHOOT : (da = h = STATE_TABLE_MOVE_STICK, s_oGame.showShotBar())); if (s_iPlayerMode !== GAME_MODE_CPU || 2 !== s_oGame.getCurTurn()) this.updateStick(), this.renderStickDirection(); p && (ia = 0, t = 1); p = p ? 2 : 1; s_iPlayerMode === GAME_MODE_CPU && s_oGame.getCurTurn() === p && (m && (l = POINTS_FOR_FAULT), s_oGame.updateScore(l)); l = 0; return !1 }; this.isCpuTurn = function() { return s_iPlayerMode === GAME_MODE_CPU && 2 === s_oGame.getCurTurn() }; this.targetting = function(m) { fa.setVisible(m) }; this._assignSuit = function() { var m = 7 === w[0] && 7 === w[1]; if (m) { for (var p = 0, q = 0, E = 0; E < I.length; E++) 8 < I[E] ? p++ : q++; if (p > q) { s_oGame.assignSuits(9); for (E = 0; E < p; E++) I[s_oGame.getCurTurn() - 1]--; for (E = 0; E < q; E++) I[s_oGame.getNextTurn() - 1]-- } else { s_oGame.assignSuits(1); for (E = 0; E < q; E++) w[s_oGame.getCurTurn() - 1]--; for (E = 0; E < p; E++) w[s_oGame.getNextTurn() - 1]-- } } return m }; this.prepareNextTurn = function() { N = 0; ia++; ia > na.length - 1 && (ia = na.length - 1); var m = this.checkTurn(); s_iPlayerMode != GAME_MODE_CPU || 2 !== s_oGame.getCurTurn() || m || setTimeout(function() { s_oTable.calculateCpuShot() }, 2E3); I.splice(0) }; this.calculateCpuShot = function() { switch (s_iGameMode) { case GAME_MODE_NINE: var m = X.getEdges(), p = this.setHoleToAim(J, u[n], n, m); if (null !== p) { var q = !0; J.isDragging() && (q = this.respotCpuCueBall(p.coll)); q && !this.findCollisionForCueBall(p.coll) && (q = !1) } else q = !1; if (!q) for (var E = n + 1; E < BALL_NUMBER + 1; E++) if (p = this.setHoleToAim(u[n], u[E], E, m), null != p) { var H = new CVector2; H.setV(this.findCollisionPoint(p.coll.getX(), p.coll.getY(), u[n])); if (q = J.isDragging() ? this.respotCpuCueBall(H) : !0) if (this.findCollisionForCueBall(H)) { q = !0; break } else q = !1 } else q = !1; if (!q) { p = []; E = []; var M = this.setAllHolesToAim(J, u[n], n, m); for (var Q = new CVector2, O = 0; O < M.length; O++) { p[O] = M[O].dist; var ba = new CVector2; ba.setV(M[O].coll); q = !0; J.isDragging() && (q = this.respotCpuCueBall(ba)); q && (Q.set(0, -1), E[O] = this._getEdgeShot(ba, Q, m), void 0 === E[O] ? (p[O] += 9E3, q = !1) : (p[O] += E[O].dist, q = !0)) } if (q) { q = p[0]; m = 0; for (H = 1; H < p.length; H++) p[H] < q && (q = p[H], m = H); this.cpuShot(E[m].dir) } else q = new CVector2, q.setV(u[n].getPos()), q.subtract(J.getPos()), q.normalize(), J.isDragging() && J.setPos(CUE_BALL_POS.x, CUE_BALL_POS.y), this.cpuShot(q) } break; case GAME_MODE_EIGHT: if (q = !1, m = X.getEdges(), 0 === w[s_oGame.getCurTurn() - 1]) { if (p = this.setHoleToAim(u[0], u[8], 8, m), null !== p ? (q = !0, u[0].isDragging() && (q = this.respotCpuCueBall(p.coll, 8)), q && !this.findCollisionForCueBall(p.coll, u[8], new CVector2(p.hole.x, p.hole.y)) && (q = !1)) : q = !1, !q) { p = []; M = this.setAllHolesToAim(u[0], u[8], 8, m); Q = new CVector2; for (O = 0; O < M.length; O++) p[O] = M[O].dist, ba = new CVector2, ba.setV(M[O].coll), (q = J.isDragging() ? this.respotCpuCueBall(ba, 8) : !0) && (q = this.prepareEdgeShot(O, ba, Q, m, p)); q || (q = new CVector2, q.setV(u[8].getPos()), q.subtract(u[0].getPos()), q.normalize(), u[0].isDragging() && u[0].setPos(CUE_BALL_POS.x, CUE_BALL_POS.y), this.cpuShot(q)) } } else { var ca = 1; H = BALL_NUMBER + 1; var W = []; s_oGame.isSuiteAssigned() && ("solid" == s_oGame.getSuiteForCurPlayer() ? (ca = 1, H = 9) : (ca = 9, H = 16)); for (var Y = ca; Y < H; Y++) 8 !== Y && u[Y].isBallOnTable() && W.push(u[Y]); for (O = 0; O < W.length; O++) if (p = this.setHoleToAim(u[0], W[O], W[O].getNumber(), y), null !== p) if (q = !0, DEBUG_SHOW_CPU_BALL_TRAJECTORY && (console.log("palla : " + W[O].getNumber()), console.log(p), console.log("*********"), Y = { x: p.coll.getX(), y: p.coll.getY() }, K.addChild(createGraphicCircle(Y, 6, 1E4, "#fff")), K.addChild(createGraphicLine(Y, p.hole, 3, 1E4, "#fff"))), J.isDragging() && (q = this.respotCpuCueBall(p.coll, W[O].getNumber())), q && !this.findCollisionForCueBall(p.coll, W[O], new CVector2(p.hole.x, p.hole.y))) q = !1; else break; else q = !1; if (!q) for (Y = 0; Y < W.length; Y++) for (p = [], M = this.setAllHolesToAim(J, W[Y], Y, m), Q = new CVector2, O = 0; O < M.length; O++) p[O] = M[O].dist, ba = new CVector2, ba.setV(M[O].coll), (q = J.isDragging() ? this.respotCpuCueBall(ba, W[Y].getNumber()) : !0) && (q = this.prepareEdgeShot(O, ba, Q, m, p)); if (!q) { for (Y = ca; Y < H; Y++) if ((8 !== Y || 0 === w[s_oGame.getCurTurn() - 1]) && u[Y].isBallOnTable()) { q = !1; m = new CEdge; m.set(J.getX(), J.getY(), u[Y].getX(), u[Y].getY()); E = u[Y]; for (p = 1; p < BALL_NUMBER + 1; p++) if (p !== Y && collideEdgeWithCircle(m, u[p].getPos(), BALL_DIAMETER)) { q = !0; break } if (!q) break } q = new CVector2; q.setV(E.getPos()); q.subtract(J.getPos()); q.normalize(); J.isDragging() && J.setPos(CUE_BALL_POS.x, CUE_BALL_POS.y); this.cpuShot(q) } } } }; this.respotCpuCueBall = function(m, p) { switch (s_iGameMode) { case GAME_MODE_NINE: var q = n; break; case GAME_MODE_EIGHT: q = p } var E = new CVector2; E.setV(u[q].getPos()); E.subtract(m); E.normalize(); E.invert(); E.scalarProduct(2 * BALL_DIAMETER); E.add(m); for (q += 1; q < u.length; q++) if (distance2(E, u[q].getPos()) <= BALL_DIAMETER_QUADRO) return !1; if (E.getX() > CUE_BALL_RESPOT_1.x && E.getX() < CUE_BALL_RESPOT_3.x && E.getY() > CUE_BALL_RESPOT_1.y && E.getY() < CUE_BALL_RESPOT_3.y) return J.setPos(E.getX(), E.getY()), J.setDragging(!1), !0; console.trace("no respotCpuCueBall " + E.getX() + "," + E.getY()); return !1 }; this.findCollisionPoint = function(m, p, q) { var E = new CVector2; E.set(m, p); E.subtract(q.getPos()); E.normalize(); E.invert(); m = new CVector2; p = randomFloatBetween(na[ia].min, na[ia].max); E.scalarProduct(BALL_DIAMETER * p); E.add(q.getPos()); m.setV(E); return m }; this.cpuShot = function(m, p) { p = void 0 === p ? MAX_FORCE_PER_DISTANCE : p; p = p > MAX_FORCE_PER_DISTANCE ? MAX_FORCE_PER_DISTANCE : p; k = linearFunction(p, 0, MAX_FORCE_PER_DISTANCE, 3, MAX_POWER_SHOT); D.setV(m); B = 100 < k ? TIME_ANIMATION_SHOT_ELASTIC : TIME_ANIMATION_SHOT_BACK; fa.setPos(u[0].getX(), u[0].getY()); b = !0; var q = new CVector2; q.setV(D); q.invert(); q.normalize(); q.scalarProduct(Math.floor(k / 10)); var E = new CVector2; E.set(fa.getX(), fa.getY()); q.add(E); E = toDegree(angleBetweenVectors(P, D)); 0 < m.getY() && (E = 180 - E + 180); fa.setRotation(E + 180); fa.setVisible(!0); fa.setPos(q.getX(), q.getY()); b = !1; e = !0; h = STATE_TABLE_SHOOT }; this.findCollisionForCueBall = function(m, p, q) { if (this._checkCpuBallCollision(m, J.getPos(), 0, 0, [])) return !1; p = distance(p, q) + distance(p, J.getPos()); q = new CVector2; q.setV(m); q.subtract(J.getPos()); q.scalarProduct(.3); q.normalize(); this.cpuShot(q, p); return !0 }; this.setAllHolesToAim = function(m, p, q, E) { for (var H = [], M = 0; M < HOLE_CPU_POINTS.length; M++) { var Q = new CEdge; Q.set(p.getX(), p.getY(), HOLE_CPU_POINTS[M].x, HOLE_CPU_POINTS[M].y); for (var O = distance(Q.getPointA(), Q.getPointB()), ba = !1, ca = 0; ca < BALL_NUMBER + 1; ca++) if (ca != q && collideEdgeWithCircle(Q, u[ca].getPos(), BALL_DIAMETER)) { ba = !0; break } for (ca = 0; ca < E.length; ca++) if (collideEdgeWithEdge(Q, E[ca])) { ba = !0; break } ba || H.push({ coll: this.findCollisionPoint(HOLE_CPU_POINTS[M].x, HOLE_CPU_POINTS[M].y, p), dist: O }) } if (0 !== H.length) for (E = H.length, M = 0; 0 < E;) Q = H[M].coll, O = !0, 0 === m.getNumber() && m.isDragging() && (O = this.respotCpuCueBall(Q, p.getNumber())), !O || this._checkCpuBallCollision(Q, m.getPos(), m.getNumber(), q, []) ? H.splice(M, 1) : M++, E--; else return []; return H }; this.setHoleToAim = function(m, p, q, E) { for (var H = [], M = 1.1 * BALL_RADIUS, Q = 0; 6 > Q; Q++) { var O = new CEdge; O.set(p.getX(), p.getY(), HOLE_CPU_POINTS[Q].x, HOLE_CPU_POINTS[Q].y); for (var ba = distance2(O.getPointA(), O.getPointB()), ca = !1, W = 0; W < BALL_NUMBER + 1; W++) if (W != q && collideEdgeWithCircle(O, u[W].getPos(), BALL_DIAMETER)) { ca = !0; break } for (W = 0; W < E.length; W++) if (collideEdgeWithEdge(O, E[W])) { ca = !0; break } W = lineInterpolate(O, M, 3); E = X.getEdgesByHoleID(Q); for (O = 0; O < W.length && !ca; O++) for (var Y = 0; Y < E.length; Y++) if (ca = collideEdgeWithCircle(E[Y], W[O], M)) { DEBUG_SHOW_PREDICT_TRAJECTORY_COLLISION && (K.addChild(createGraphicLine({ x: p.getX(), y: p.getY() }, HOLE_CPU_POINTS[Q], 3, 6E3, "#f0f")), K.addChild(createGraphicCircle({ x: W[O].getX(), y: W[O].getY() }, M, 6E3, "#0ff"))); break } if (!ca) { ca = this.findCollisionPoint(HOLE_CPU_POINTS[Q].x, HOLE_CPU_POINTS[Q].y, p); O = X.getEdgesByHoleID(Q); Y = !1; for (W = 0; W < O.length; W++) if (collideEdgeWithCircle(E[W], ca, BALL_RADIUS)) { Y = !0; break } Y ? DEBUG_SHOW_PREDICT_TRAJECTORY_COLLISION && K.addChild(createGraphicCircle({ x: ca.getX(), y: ca.getY() }, M, 6E3, "#0f0")) : H.push({ hole: HOLE_CPU_POINTS[Q], coll: ca, dist: ba }) } } if (0 !== H.length) { sortByKey(H, "dist"); q = H.length; for (E = 0; 0 < q;) M = H[E].coll, Q = !0, 0 === m.getNumber() && m.isDragging() && (Q = this.respotCpuCueBall(M, p.getNumber())), !Q || this._checkCpuBallCollision(M, m.getPos(), m.getNumber(), m.getNumber(), []) ? H.splice(E, 1) : E++, q--; return 0 == H.length ? null : H[0] } return null }; this._getEdgeShot = function(m, p, q) { var E = new CVector2; E.setV(m); var H = 1, M = new CEdge; p.scalarProduct(600); for (var Q = []; 360 > H;) { rotateVector2D(toRadian(1), p); var O = new CVector2; O.set(E.getX() + p.getX(), E.getY() + p.getY()); M.set(m.getX(), m.getY(), O.getX(), O.getY()); O = new CVector2; for (var ba = 0; ba < q.length; ba++) if (collideEdgeWithEdge(M, q[ba], O)) { var ca = q[ba]; var W = new CVector2; W.setV(reflectVectorV2(p, ca.getNormal())); ca = new CEdge; var Y = new CVector2; Y.setV(W); Y.add(O); ca.set(O.getX(), O.getY(), Y.getX(), Y.getY()); Y = distance(O, m); if (Y > BALL_DIAMETER && collideEdgeWithCircle(ca, J.getPos(), BALL_RADIUS)) { var qa = !1; this._checkCpuBallCollision(O, J.getPos(), 0, 0, []) ? qa = !0 : this._checkCpuBallCollision(m, O, 0, 0, []) && (qa = !0); qa || (W.invert(), W.normalize(), qa = new CVector2, qa.setV(W), W = distance(ca.getPointA(), ca.getPointB()), Q.push({ dir: qa, edge: ca, dist: W + Y })) } } H += 1 } if (0 !== Q.length) { E = closestPointOnLine(Q[0].edge.getPointA(), Q[0].edge.getPointB(), J.getPos()); m = distance(E, J.getPos()); p = 0; for (q = 1; q < Q.length; q++) E = closestPointOnLine(Q[q].edge.getPointA(), Q[q].edge.getPointB(), J.getPos()), W = distance(E, J.getPos()), m > W && (m = W, p = q); return Q[p] } }; this.prepareEdgeShot = function(m, p, q, E, H) { var M = []; q.set(0, -1); M[m] = this._getEdgeShot(p, q, E); if (void 0 == M[m]) { H[m] += 9E3; var Q = !1 } else H[m] += M[m].dist, Q = !0; if (Q) this._edgeShot(H, M); else if (q.set(1, 0), M[m] = this._getEdgeShot(p, q, E), void 0 === M[m] ? (H[m] += 9E3, Q = !1) : (H[m] += M[m].dist, Q = !0), Q) this._edgeShot(H, M); else if (q.set(0, 1), M[m] = this._getEdgeShot(p, q, E), void 0 == M[m] ? (H[m] += 9E3, Q = !1) : (H[m] += M[m].dist, Q = !0), Q) this._edgeShot(H, M); else { q.set(-1, 0); M[m] = this._getEdgeShot(p, q, E); if (void 0 == M[m]) return H[m] += 9E3, !1; H[m] += M[m].dist; return !0 } }; this._edgeShot = function(m, p) { if (void 0 !== p) { for (var q = m[0], E = 0, H = 1; H < m.length; H++) m[H] < q && (q = m[H], E = H); q = p[E]; q = void 0 === q ? void 0 : q.dir; this.cpuShot(q) } }; this.setLowestBall = function() { for (var m = 1; m < u.length; m++) if (u[m].isBallOnTable()) { n = m; break } }; this.isBreakShot = function() { return d }; this.getCntBallsIntoHoles = function() { return C }; this.updatePhysics = function() { var m = X.areBallsStopped(); X.update(u); var p = X.areBallsStopped(); if (!m && p) for (s_oInterface.resetSpin(), this.prepareNextTurn(), m = k = 0; m < u.length; m++) u[m].resetEdgeCollisionCount() }; this.getTableX = function() { return K.x }; this.getTableY = function() { return K.y }; this._update3DObjectTransformation = function(m) { var p = m.getX(), q = m.getY(), E = m.getObject3D(); E.position.x = .5 * -CANVAS_WIDTH + p + this.getTableX(); E.position.y = .5 * CANVAS_HEIGHT - q - this.getTableY(); p = m.getCurForce(); m = m.getEffectForceVector(); p = new CVector2(p.getX(), p.getY()); p.add(m); q = .04 * p.length(); p.normalize(); m.scalarProduct(DAMPING_BALL_EFFECT); E.rotateOnWorldAxis(new THREE.Vector3(p.getY(), p.getX(), 0), q) }; this.update = function() { this.updatePhysics(); this.renderBalls(); var m = this.isCpuTurn(); switch (h) { case STATE_TABLE_PLACE_CUE_BALL: case STATE_TABLE_PLACE_CUE_BALL_BREAKSHOT: case STATE_TABLE_MOVE_STICK: if (m) return; this.updateStick(); this.renderStickDirection(); break; case STATE_TABLE_SHOOT: s_iPlayerMode === GAME_MODE_CPU && 2 === s_oGame.getCurTurn() && e && this.renderStickDirection() } u.forEach(function(p) { this._update3DObjectTransformation(p); p._updateShadow() }, this) }; s_oTable = this; this._init(c) } var s_oTable = null; function CGUIExpandible(a, c, b, e) { var d, f, g, h, k, n, l, t; this._init = function(z, v, G, C) { h = []; n = new createjs.Container; n.x = z; n.y = v; C.addChild(n); l = new createjs.Container; n.addChild(l); t = new createjs.Container; n.addChild(t); g = !1; k = new CGfxButton(0, 0, G, t); k.addEventListener(ON_MOUSE_UP, this._onMenu, this); f = d = 135 }; this.unload = function() { k.unload(); e.removeChild(n) }; this.refreshPos = function() { n.x = a - s_iOffsetX; n.y = c + s_iOffsetY }; this.addButton = function(z) { z = z.getButtonImage(); z.x = 0; z.y = 0; z.visible = 0; l.addChildAt(z, 0); h.push(z) }; this._onMenu = function() { (g = !g) ? w._expand(): w._collapse() }; this._expand = function() { for (var z = 0; z < h.length; z++) h[z].visible = !0, createjs.Tween.get(h[z], { override: !0 }).wait(300 * z / 2).to({ y: d + z * f }, 300, createjs.Ease.cubicOut) }; this._collapse = function() { for (var z = 0; z < h.length; z++) { var v = h[h.length - 1 - z]; createjs.Tween.get(v, { override: !0 }).wait(300 * z / 2).to({ y: 0 }, 300, createjs.Ease.cubicOut).call(function(G) { G.visible = !1 }, [v]) } }; var w = this; this._init(a, c, b, e) } function CEdge(a, c, b, e, d) { var f = null, g = null, h = null, k = null, n = null, l = null; this._init = function(t, w, z, v, G) { l = G; this.set(t, w, z, v) }; this.destroy = function() { n = k = h = g = f = null }; this.render = function(t) { var w = new createjs.Shape; w.graphics.setStrokeStyle(4, "round", "round"); w.graphics.beginStroke("red").moveTo(f.getX(), f.getY()).lineTo(g.getX(), g.getY()); t.addChild(w); w = .5 * (f.getX() + g.getX()); var z = .5 * (f.getY() + g.getY()); new CTLText(t, w - 50, z - 50, 100, 100, 30, "center", "#00f", FONT_GAME, 1, 0, 0, String(l), !0, !0, !1, !1) }; this.toString = function(t) { console.log(t + " " + f.x + " " + f.y + " " + g.x + " " + g.y) }; this.add = function(t) { f.addV(t); g.addV(t) }; this.set = function(t, w, z, v) { f = new CVector2; g = new CVector2; f.set(t, w); g.set(z, v); this.calculateNormal(); this.calculateCenter() }; this.scale = function(t) { f.scalarProduct(t); g.scalarProduct(t); this.calculateNormal(); this.calculateCenter() }; this.calculateEdgeVector = function() { var t = new CVector2; t.setV(g); t.subtract(f); t.normalize(); return t }; this.calculateNormal = function() { n = null; n = new CVector2; n.setV(g); n.subtract(f); n.rot90CCW(); n.normalize() }; this.calculateCenter = function() { h = null; h = centerBetweenPointsV2(f, g); k = new CVector2; k.setV(n); k.scalarProduct(5); k.addV(h) }; this.getPointA = function() { return f }; this.m_pCenter = function() { return h }; this.getPointB = function() { return g }; this.getNormal = function() { return n }; this.getID = function() { return l }; this.renderNormal = function(t) { t.moveTo(h.getX(), h.y); t.lineTo(k.getX(), k.y) }; this._init(a, c, b, e, d); return this } function CVector2(a, c) { var b, e; this._init = function(d, f) { b = d; e = f }; this.add = function(d) { b += d.getX(); e += d.getY() }; this.addV = function(d) { b += d.getX(); e += d.getY() }; this.scalarDivision = function(d) { b /= d; e /= d }; this.subtract = function(d) { b -= d.getX(); e -= d.getY() }; this.scalarProduct = function(d) { b *= d; e *= d }; this.invert = function() { b *= -1; e *= -1 }; this.dotProduct = function(d) { return b * d.getX() + e * d.getY() }; this.set = function(d, f) { b = d; e = f }; this.setV = function(d) { b = d.getX(); e = d.getY() }; this.length = function() { return Math.sqrt(b * b + e * e) }; this.length2 = function() { return b * b + e * e }; this.normalize = function() { var d = this.length(); 0 < d && (b /= d, e /= d) }; this.angleBetweenVectors = function(d) { d = Math.acos(this.dotProduct(d) / (this.length() * d.length())); return !0 === isNaN(d) ? 0 : d }; this.getNormalize = function(d) { this.length(); d.set(b, e); d.normalize() }; this.rot90CCW = function() { var d = b; b = -e; e = d }; this.rot90CW = function() { var d = b; b = e; e = -d }; this.getRotCCW = function(d) { d.set(b, e); d.rot90CCW() }; this.getRotCW = function(d) { d.set(b, e); d.rot90CW() }; this.ceil = function() { b = Math.ceil(b); e = Math.ceil(e) }; this.round = function() { b = Math.round(b); e = Math.round(e) }; this.toString = function() { return "Vector2: " + b + ", " + e }; this.print = function() { trace("Vector2: " + b + ", " + e) }; this.getX = function() { return b }; this.getY = function() { return e }; this.rotate = function(d) { var f = b, g = e; b = f * Math.cos(d) + g * Math.sin(d); e = f * -Math.sin(d) + g * Math.cos(d) }; this._init(a, c) } var SIN_PI = Math.sin(Math.PI), DOUBLE_PI = 2 * Math.PI, HALF_PI = Math.PI / 2, SIN_HALF_PI = Math.sin(HALF_PI), SIN_DOUBLE_PI = Math.sin(DOUBLE_PI); function angleBetweenVectors(a, c) { var b = Math.acos(dotProductV2(a, c) / (a.length() * c.length())); return !0 === isNaN(b) ? 0 : b } function centerBetweenPointsV2(a, c) { var b = new CVector2; b.set((a.getX() + c.getX()) / 2, (a.getY() + c.getY()) / 2); return b } function distance2(a, c) { return (c.getX() - a.getX()) * (c.getX() - a.getX()) + (c.getY() - a.getY()) * (c.getY() - a.getY()) } function distance(a, c) { return Math.sqrt((c.getX() - a.getX()) * (c.getX() - a.getX()) + (c.getY() - a.getY()) * (c.getY() - a.getY())) } function easeQuintIn(a, c, b, e) { return b * (a /= e) * a * a * a * a + c } function easeCubicInOut(a, c, b, e) { if (!(a > e)) return 1 > (a /= e / 2) ? b / 2 * a * a * a + c : b / 2 * ((a -= 2) * a * a + 2) + c } function easeBackIn(a, c, b, e, d) { void 0 == d && (d = 1.70158); return b * (a /= e) * a * ((d + 1) * a - d) + c } function easeElasticIn(a, c, b, e, d, f) { if (0 == a) return c; if (1 == (a /= e)) return c + b; f || (f = .3 * e); !d || d < Math.abs(b) ? (d = b, b = f / 4) : b = f / (2 * Math.PI) * Math.asin(b / d); return -(d * Math.pow(2, 10 * --a) * Math.sin(2 * (a * e - b) * Math.PI / f)) + c } function toRadian(a) { return Math.PI / 180 * a } function toDegree(a) { return 180 / Math.PI * a } function dotProductV2(a, c) { return a.getX() * c.getX() + a.getY() * c.getY() } function perpProductV2(a, c) { return a.getX() * c.getY() - a.getY() * c.getX() } function reflectVectorV2(a, c) { var b = new CVector2, e = dotProductV2(a, c); b.set(a.getX() - 2 * e * c.getX(), a.getY() - 2 * e * c.getY()); return b } function classifySphere(a, c, b, e) { a = c.getX() * a.getX() + c.getY() * a.getY() + planeDistance(c, b); return Math.abs(a) < e ? 0 <= a ? "INTERSECT FRONT" : "INTERSECT BEHIND" : a >= e ? "FRONT" : "BEHIND" } function planeDistance(a, c) { return -(a.getX() * c.getX() + a.getY() * c.getY()) } function randRange(a, c) { return Math.floor(Math.random() * (c - a + 1)) + a } function randRangeReal(a, c) { return Math.random() * (c - a + 1) + a } function rotateVector2D(a, c) { var b = c.getX() * Math.cos(a) + c.getY() * Math.sin(a), e = c.getX() * -Math.sin(a) + c.getY() * Math.cos(a); c.set(b, e) } function closestPointOnLine(a, c, b) { var e = new CVector2; e.setV(b); e.subtract(a); b = new CVector2; b.setV(c); b.subtract(a); b.normalize(); e = dotProductV2(b, e); if (0 >= e) return a; if (e >= distance(a, c)) return c; b.scalarProduct(e); b.add(a); return b } function rectInRect(a, c) { return c.x <= a.x && c.y <= a.y && c.width >= a.width && c.height >= a.height ? !0 : !1 } function collideEdgeWithCircle(a, c, b, e) { a = closestPointOnLine(a.getPointA(), a.getPointB(), c); c = distance(c, a); e && (e.iDistance = c, e.vClosestPoint = a); return b < c ? !1 : !0 } function collideEdgeWithEdge(a, c, b) { var e = a.getPointA(); a = a.getPointB(); var d = c.getPointA(); c = c.getPointB(); var f = e.getX() * (c.getY() - d.getY()) + a.getX() * (d.getY() - c.getY()) + c.getX() * (a.getY() - e.getY()) + d.getX() * (e.getY() - a.getY()); if (0 === f) return !1; var g = e.getX() * (c.getY() - d.getY()) + d.getX() * (e.getY() - c.getY()) + c.getX() * (d.getY() - e.getY()); c = g / f; g = -(e.getX() * (d.getY() - a.getY()) + a.getX() * (e.getY() - d.getY()) + d.getX() * (a.getY() - e.getY())); d = g / f; b && b.set(e.getX() + c * (a.getX() - e.getX()), e.getY() + c * (a.getY() - e.getY())); return 0 <= c && 1 >= c && 0 <= d && 1 >= d ? !0 : !1 } function lineInterpolate(a, c, b) { var e = a.getPointA(), d = a.getPointB(), f = Math.abs(e.getX() - d.getX()), g = Math.abs(e.getY() - d.getY()); a = d.getX() - e.getX(); d = d.getY() - e.getY(); c = Math.sqrt(Math.pow(f, 2) + Math.pow(g, 2)) / c; a /= c; d /= c; f = []; b = void 0 !== b ? b > c ? c : b : c; var h = c - b; for (h; h < c; h++) b = e.getX() + a * h, g = e.getY() + d * h, f.push(new CVector2(b, g)); return f } function intersect2D_Segments(a, c, b, e) { var d = new CVector2, f = new CVector2, g = new CVector2; d.set(a.m_pB.getX() - a.m_pA.getX(), a.m_pB.getY() - a.m_pA.getY()); f.set(c.m_pB.getX() - c.m_pA.getX(), c.m_pB.getY() - c.m_pA.getY()); g.set(a.m_pA.getX() - c.m_pA.getX(), a.m_pA.getY() - c.m_pA.getY()); var h = perpProductV2(d, f); if (1E-8 > Math.abs(h)) { if (0 != perpProductV2(d, g) || 0 != perpProductV2(f, g)) return 0; d = dotProductV2(d, d); h = dotProductV2(f, f); if (0 == d && 0 == h) return a.m_pA.getX() != c.m_pA.getX() || a.m_pA.getY() != c.m_pA.getY() ? 0 : 1; if (0 == d) return 0 == inSegment(a.m_pA, c) ? 0 : 1; if (0 == h) return 0 == inSegment(c.m_pA, a) ? 0 : 1; d = new CVector2; d.set(a.m_pB.getX() - c.m_pA.getX(), a.m_pB.getY() - c.m_pA.getY()); 0 != f.getX() ? (a = g.getX() / f.getX(), g = d.getX() / f.getX()) : (a = g.getY() / f.getY(), g = d.getY() / f.getY()); a > g && (d = a, a = g, g = d); if (1 < a || 0 > g) return 0; a = 0 > a ? 0 : a; g = 1 < g ? 1 : g; if (a == g) return b.set(c.m_pA.getX() + a * f.getX(), c.m_pA.getY() + a * f.getY()), 1; b.set(c.m_pA.getX() + a * f.getX(), c.m_pA.getY() + a * f.getY()); e.set(c.m_pA.getX() + g * f.getX(), c.m_pA.getY() + g * f.getY()); return 2 } c = perpProductV2(f, g) / h; if (0 > c || 1 < c) return 0; e = perpProductV2(d, g) / h; if (0 > e || 1 < e) return 0; b.set(a.m_pA.getX() + c * d.getX(), a.m_pA.getY() + c * d.getY()); return 1 } function inSegment(a, c) { if (c.m_pA.getX() != c.m_pB.getX()) { if (c.m_pA.getX() <= a.getX() && a.getX() <= c.m_pB.getX() || c.m_pA.getX() >= a.getX() && a.getX() >= c.m_pB.getX()) return 1 } else if (c.m_pA.getY() <= a.getY() && a.getY() <= c.m_pB.getY() || c.m_pA.getY() >= a.getY() && a.getY() >= c.m_pB.getY()) return 1; return 0 } function detectCollisionPointCircle(a, c, b) { var e = a.getX() - c.getX(); a = a.getY() - c.getY(); return sqrt(e * e + a * a) <= b } function tweenVectors(a, c, b, e) { b.set(a.getX() + e * (c.getX() - a.getX()), a.getY() + e * (c.getY() - a.getY())); return b } CTLText.prototype = { constructor: CTLText, __autofit: function() { if (this._bFitText) { for (var a = this._iFontSize; (this._oText.getBounds().height > this._iHeight - 2 * this._iPaddingV || this._oText.getBounds().width > this._iWidth - 2 * this._iPaddingH) && !(a--, this._oText.font = a + "px " + this._szFont, this._oText.lineHeight = Math.round(a * this._fLineHeightFactor), this.__updateY(), this.__verticalAlign(), 8 > a);); this._iFontSize = a } }, __verticalAlign: function() { if (this._bVerticalAlign) { var a = this._oText.getBounds().height; this._oText.y -= (a - this._iHeight) / 2 + this._iPaddingV } }, __updateY: function() { this._oText.y = this._y + this._iPaddingV; switch (this._oText.textBaseline) { case "middle": this._oText.y += this._oText.lineHeight / 2 + (this._iFontSize * this._fLineHeightFactor - this._iFontSize) } }, __createText: function(a) { this._bDebug && (this._oDebugShape = new createjs.Shape, this._oDebugShape.graphics.beginFill("rgba(255,0,0,0.5)").drawRect(this._x, this._y, this._iWidth, this._iHeight), this._oContainer.addChild(this._oDebugShape)); this._oText = new createjs.Text(a, this._iFontSize + "px " + this._szFont, this._szColor); this._oText.textBaseline = "middle"; this._oText.lineHeight = Math.round(this._iFontSize * this._fLineHeightFactor); this._oText.textAlign = this._szAlign; this._oText.lineWidth = this._bMultiline ? this._iWidth - 2 * this._iPaddingH : null; switch (this._szAlign) { case "center": this._oText.x = this._x + this._iWidth / 2; break; case "left": this._oText.x = this._x + this._iPaddingH; break; case "right": this._oText.x = this._x + this._iWidth - this._iPaddingH } this._oContainer.addChild(this._oText); this.refreshText(a) }, setVerticalAlign: function(a) { this._bVerticalAlign = a }, setOutline: function(a) { null !== this._oText && (this._oText.outline = a) }, setShadow: function(a, c, b, e) { null !== this._oText && (this._oText.shadow = new createjs.Shadow(a, c, b, e)) }, setColor: function(a) { this._oText.color = a }, setAlpha: function(a) { this._oText.alpha = a }, setY: function(a) { this._y = this._oText.y = a; this.updateDebug() }, setX: function(a) { this._x = this._oText.x = a; this.updateDebug() }, updateDebug: function() { this._bDebug && (this._oDebugShape.graphics.command.x = this._x, this._oDebugShape.graphics.command.y = this._y) }, setOffsetX: function(a) { this._oText.x += a; this._x = this._oText.x; this.updateDebug() }, setOffsetY: function(a) { this._oText.y += a; this._y = this._oText.y; this.updateDebug() }, removeTweens: function() { createjs.Tween.removeTweens(this._oText) }, getText: function() { return this._oText }, getY: function() { return this._y }, getBounds: function() { return this._oText.getBounds() }, getFontSize: function() { return this._iFontSize }, refreshText: function(a) { "" === a && (a = " "); null === this._oText && this.__createText(a); this._oText.text = a; this._oText.font = this._iFontSize + "px " + this._szFont; this._oText.lineHeight = Math.round(this._iFontSize * this._fLineHeightFactor); this.__autofit(); this.__updateY(); this.__verticalAlign() } }; function CTLText(a, c, b, e, d, f, g, h, k, n, l, t, w, z, v, G, C) { this._oContainer = a; this._x = c; this._y = b; this._iWidth = e; this._iHeight = d; this._bMultiline = G; this._iFontSize = f; this._szAlign = g; this._szColor = h; this._szFont = k; this._iPaddingH = l; this._iPaddingV = t; this._bVerticalAlign = v; this._bFitText = z; this._bDebug = C; this._oDebugShape = null; this._fLineHeightFactor = n; this._oText = null; w && this.__createText(w) } function CBall(a, c, b) { var e, d, f, g, h, k, n, l, t, w, z, v, G, C, N, B, r, u, F, I; this._init = function(y) { n = e = !1; w = 0; G = null; z = 0; N = new createjs.Container; c.addChild(N); var D = s_oSpriteLibrary.getSprite("ball_shadow"); l = createBitmap(D); l.regX = D.width / 2; l.regY = D.height / 2; N.addChild(l); DEBUG_SHOW_2D_SPRITE && (D = { images: [s_oSpriteLibrary.getSprite("balls")], frames: { width: BALL_DIAMETER, height: BALL_DIAMETER, regX: BALL_DIAMETER / 2, regY: BALL_DIAMETER / 2 }, animations: { ball_0: 0, ball_1: 1, ball_2: 2, ball_3: 3, ball_4: 4, ball_5: 5, ball_6: 6, ball_7: 7, ball_8: 8, ball_9: 9, ball_10: 10, ball_11: 11, ball_12: 12, ball_13: 13, ball_14: 14, ball_15: 15 } }, D = new createjs.SpriteSheet(D), C = createSprite(D, "ball_" + a, BALL_DIAMETER / 2, BALL_DIAMETER / 2, BALL_DIAMETER, BALL_DIAMETER), N.addChild(C)); B = s_oScenario.create3DBall(y, BALL_3D_DIAMETER / 2, new THREE.Vector3(0, 0, BALL_Z_POSITION)); f = new CVector2(0, 0); g = new CVector2(0, 0); h = new CVector2(0, 0); d = new CVector2(0, 0); k = new CVector2(0, 0) }; this.enableEvents = function() { r = []; u = []; F = []; I = []; t = new createjs.Shape; t.graphics.beginFill("#aaa").drawRect(.5 * -CUE_BALL_HIT_AREA_DIMENSION, .5 * -CUE_BALL_HIT_AREA_DIMENSION, CUE_BALL_HIT_AREA_DIMENSION, CUE_BALL_HIT_AREA_DIMENSION); t.alpha = .009; N.addChild(t) }; this.getObject3D = function() { return B }; this.render = function(y) { N.x = d.getX(); N.y = d.getY() }; this.setVisible = function(y) { N.visible = y }; this.setDragging = function(y) { n = y; B.position.z = y ? BALL_Z_POSITION + 20 : BALL_Z_POSITION }; this.setMask = function(y, D) { v = new createjs.Shape; v.graphics.beginFill("rgba(0,0,0,0.01)").drawCircle(y, D, POOL_HOLE_RADIUS); c.addChild(v); N.mask = v }; this.removeMask = function() { v && (N.mask = null) }; this.setPos = function(y, D) { N.x = y; N.y = D; d.set(y, D) }; this.setY = function(y) { N.y = y; d.set(N.x, N.y) }; this.setX = function(y) { N.x = y; d.set(N.x, N.y) }; this.setPrevPos = function(y) { h.setV(y) }; this.setPosV = function(y) { d.setV(y) }; this.setScale = function(y) { N.scale = y }; this.addPos = function(y) { d.add(y) }; this.addForce = function(y) { f.add(y) }; this.addCurForce = function(y) { g.add(y) }; this.setCurForce = function(y, D) { g.set(y, D) }; this.setCurForceV = function(y) { g.setV(y) }; this.setTmpForce = function(y, D) { f.set(y, D) }; this.normalizeCurForce = function() { g.normalize() }; this.scalarProductTmpForce = function(y) { f.scalarProduct(y) }; this.scalarProductCurForce = function(y) { g.scalarProduct(y) }; this.setFlagOnTable = function(y) { e = y }; this.inHole = function(y) { G = y }; this.getHole = function() { return G }; this.getTmpForce = function() { return f }; this.getCurForce = function() { return g }; this.getCurForceLen = function() { return g.length() }; this.getCurForceLenght2 = function() { return g.length2() }; this.getX = function() { return d.getX() }; this.getY = function() { return d.getY() }; this.getPos = function() { return d }; this.getPrevPos = function() { return h }; this.getNumber = function() { return a }; this.isBallOnTable = function() { return e }; this.isDragging = function() { return n }; this.getEffectForceVector = function() { return k }; this.setEffectForceX = function(y) { k.set(y, k.getY()) }; this.setEffectForceY = function(y) { k.set(k.getX(), y) }; this.reset3DObjectTransformation = function() { this.setOpacityMaterial3D(1); B.scale.x = B.scale.y = B.scale.z = 1; var y = new THREE.Color(1, 1, 1); B.material.color = y }; this.setOpacityMaterial3D = function(y) { var D = B.material; D.transparent = !0; .99 < y && (y = 1, D.transparent = !1); D.opacity = y }; this.fadeAnimInHole = function(y) { var D = B.material; D.transparent = !0; l.visible = !1; createjs.Tween.get(D, { override: !0 }).to({ opacity: 0 }, y, createjs.Ease.sineOut); createjs.Tween.get(B.scale).to({ x: .1, y: .1, z: .1 }, y, createjs.Ease.sineOut).call(function() { this.setCurForce(0, 0); this.setPos(POS_RAIL_EXIT.x, POS_RAIL_EXIT.y) }, null, this); createjs.Tween.get(D.color).to({ r: 0, g: 0, b: 0 }, .5 * y, createjs.Ease.sineOut) }; this.getSideEffect = function() { return z }; this.setSideEffect = function(y) { z = y }; this.resetEdgeCollisionCount = function() { w = 0 }; this.increaseEdgeCollisionCount = function() { w++ }; this.getEdgeCollisionCount = function() { return w }; this._updateShadow = function() { if (l.visible) { var y = new CVector2(TABLE_CENTER_COORDINATE.getX(), TABLE_CENTER_COORDINATE.getY()); y.subtract(d); l.x = -.03 * y.getX(); l.y = -.03 * y.getY(); y = linearFunction(y.length(), 770, 0, 0, 1); l.alpha = y } }; this.triggerEvent = function(y, D) { r && r[D] && r[D].call(u[D], y, F[D]) }; this.addEventListener = function(y, D, x, L) { r && (r[y] = D, u[y] = x, F[y] = L, I[y] = t.on(y, this.triggerEvent, this, !1, y)) }; this.removeEventListener = function(y) { r[y] = null; u[y] = null; F[y] = null; t.off(y, I[y]); I[y] = null }; this._init(b) } function CStick(a) { var c; this._init = function() { c = new createjs.Container; a.addChild(c); var b = createBitmap(s_oSpriteLibrary.getSprite("stick")); c.addChild(b); c.regX = c.getBounds().width + BALL_RADIUS; c.regY = c.getBounds().height / 2; c.rotation = 0 }; this.setVisible = function(b) { c.visible = b }; this.setPos = function(b, e) { c.x = b; c.y = e }; this.getRotation = function() { return c.rotation }; this.setRotation = function(b) { c.rotation = b }; this.getX = function() { return c.x }; this.getY = function() { return c.y }; this._init() } function CPhysicsController(a) { var c, b, e, d, f, g, h, k, n, l, t, w, z, v, G, C, N, B, r, u, F, I, y, D = this; this._init = function(x) { c = !0; f = 0; b = []; e = []; this._initCollisions() }; this._initCollisions = function() { y = new createjs.Rectangle(0, 0, POOL_HOLE_RADIUS, POOL_HOLE_RADIUS); g = []; h = []; k = []; n = []; l = []; for (var x = 0; x < FIELD_POINTS.length - 1; x++) { var L = new CEdge(FIELD_POINTS[x].x, FIELD_POINTS[x].y, FIELD_POINTS[x + 1].x, FIELD_POINTS[x + 1].y, x); l.push(L) } L = new CEdge(FIELD_POINTS[FIELD_POINTS.length - 1].x, FIELD_POINTS[FIELD_POINTS.length - 1].y, FIELD_POINTS[0].x, FIELD_POINTS[0].y, FIELD_POINTS.length - 1); l.push(L); g.push(l[21]); g.push(l[22]); g.push(l[23]); g.push(l[0]); g.push(l[1]); g.push(l[2]); g.push(l[3]); g.push(l[4]); t = []; t.push(l[0]); t.push(l[2]); t.push(l[3]); t.push(l[4]); h.push(l[3]); h.push(l[4]); h.push(l[5]); h.push(l[6]); h.push(l[7]); h.push(l[8]); h.push(l[9]); t.push(l[8]); t.push(l[7]); t.push(l[6]); n.push(l[9]); n.push(l[10]); n.push(l[11]); n.push(l[12]); n.push(l[13]); n.push(l[14]); n.push(l[15]); n.push(l[16]); t.push(l[10]); t.push(l[11]); t.push(l[12]); t.push(l[14]); t.push(l[15]); t.push(l[16]); k.push(l[15]); k.push(l[16]); k.push(l[17]); k.push(l[18]); k.push(l[19]); k.push(l[20]); k.push(l[21]); t.push(l[18]); t.push(l[19]); t.push(l[20]); t.push(l[22]); t.push(l[23]); w = []; for (x = 0; x < FIELD_POINTS.length; x++) L = new CVector2(FIELD_POINTS[x].x, FIELD_POINTS[x].y), w.push(L); z = []; v = []; G = []; C = []; N = []; x = new CVector2; x.set((l[0].getNormal().getX() + l[23].getNormal().getX()) / 2, (l[0].getNormal().getY() + l[23].getNormal().getY()) / 2); x.normalize(); z.push(x); for (x = 0; 23 > x; x++) L = new CVector2((l[x].getNormal().getX() + l[x + 1].getNormal().getX()) / 2, (l[x].getNormal().getY() + l[x + 1].getNormal().getY()) / 2), L.normalize(), z.push(L); v.push({ oPoint: w[1], oNormal: z[1] }); v.push({ oPoint: w[2], oNormal: z[2] }); v.push({ oPoint: w[5], oNormal: z[5] }); v.push({ oPoint: w[21], oNormal: z[21] }); G.push({ oPoint: w[2], oNormal: z[2] }); G.push({ oPoint: w[5], oNormal: z[5] }); G.push({ oPoint: w[6], oNormal: z[6] }); G.push({ oPoint: w[9], oNormal: z[9] }); N.push({ oPoint: w[10], oNormal: z[10] }); N.push({ oPoint: w[13], oNormal: z[13] }); N.push({ oPoint: w[14], oNormal: z[14] }); N.push({ oPoint: w[17], oNormal: z[17] }); C.push({ oPoint: w[14], oNormal: z[14] }); C.push({ oPoint: w[17], oNormal: z[17] }); C.push({ oPoint: w[18], oNormal: z[18] }); C.push({ oPoint: w[21], oNormal: z[21] }); B = []; r = []; u = []; F = []; I = []; for (x = 0; x < HOLE_CENTER_POS.length; x++) L = new CVector2, L.set(HOLE_CENTER_POS[x].x, HOLE_CENTER_POS[x].y), B.push(L); r.push(B[0]); r.push(B[1]); u.push(B[1]); u.push(B[2]); I.push(B[3]); I.push(B[4]); F.push(B[4]); F.push(B[5]) }; this.addEventListener = function(x, L, P) { b[x] = L; e[x] = P }; this.verifyCollisionBallWithRectArea = function(x) { y.x = x.getX() - BALL_RADIUS; y.y = x.getY() - BALL_RADIUS; return RECT_COLLISION.contains(x.getX(), x.getY()) }; this._chooseQuadrant = function(x) { return x.getX() < TABLE_CENTER.x ? x.getY() < TABLE_CENTER.y ? 0 : 3 : x.getY() < TABLE_CENTER.y ? 1 : 2 }; this.addBallToStack = function(x, L) { if (s_iGameMode === GAME_MODE_TIME) 0 === x.getNumber() ? (x.setTmpForce(0, 0), x.setCurForce(0, 0), x.setFlagOnTable(!1), x.setVisible(!1)) : (x.inHole(L), x.setScale(.9), x.scalarProductTmpForce(.9), x.setMask(L.getX(), L.getY())); else if (0 === x.getNumber()) x.setPos(CANVAS_WIDTH + BALL_DIAMETER, CUE_BALL_POS.y), x.setTmpForce(0, 0), x.setCurForce(0, 0); else switch (s_iGameMode) { case GAME_MODE_NINE: 9 === x.getNumber() ? (x.setPos(0, 0), x.setFlagOnTable(!1), x.setTmpForce(0, 0), x.setCurForce(0, 0), x.setVisible(!1)) : (x.inHole(L), x.setScale(.9), x.scalarProductTmpForce(.9), x.setMask(L.getX(), L.getY())); break; case GAME_MODE_EIGHT: x.inHole(L), x.setScale(.9), x.scalarProductTmpForce(.9), x.setMask(L.getX(), L.getY()) } }; this.collideBallWithHoles = function(x, L) { return distance(x.getPos(), L[0]) < BALL_RADIUS ? (b[ON_BALL_INTO_HOLE] && b[ON_BALL_INTO_HOLE].call(e[ON_BALL_INTO_HOLE], x), L[0]) : distance(x.getPos(), L[1]) < BALL_RADIUS ? (b[ON_BALL_INTO_HOLE] && b[ON_BALL_INTO_HOLE].call(e[ON_BALL_INTO_HOLE], x), L[1]) : null }; this.collideBallWithPointsNormals = function(x, L, P) { for (var S = 0; S < P.length; S++) if (distance2(P[S].oPoint, L) <= BALL_RADIUS_QUADRO) return reflectVectorV2(x.getCurForce(), P[S].oNormal), L = x.getCurForceLen(), x.setCurForceV(P[S].oNormal), x.scalarProductCurForce(L), null !== x.getHole() && b[ON_BALL_WITH_BANK] && b[ON_BALL_WITH_BANK].call(e[ON_BALL_WITH_BANK], x), !0; return !1 }; this.collideBallWithBalls = function(x) { if (null !== x.getHole()) return !1; for (var L = [], P, S = 1E4, ea, T = 0; T < d.length; T++) d[T].getNumber() !== x.getNumber() && d[T].isBallOnTable() && null === d[T].getHole() && (P = distance2(x.getPos(), d[T].getPos()), P <= BALL_DIAMETER_QUADRO && (L.push({ oBall: d[T], iDist: P, index_ball: T }), S > P && (S = P, ea = L.length - 1))); if (0 === L.length) return !1; S = new CVector2; P = new CVector2; T = new CVector2; T.setV(x.getCurForce()); T.invert(); T.normalize(); P.setV(x.getPos()); P.subtract(L[ea].oBall.getPos()); P.normalize(); S.setV(P); S.scalarProduct(1.05 * BALL_DIAMETER); S.add(L[ea].oBall.getPos()); x.setPosV(S); S = angleBetweenVectors(T, P) / HALF_PI; if (0 === x.getNumber() && .3 > S) { var X = s_oInterface.getBackSpin(), aa = new CVector2; P.getNormalize(aa); this._addSideSpinEffect(T, -1, T, x); T = this._addBackSpinEffect(x, X, P, T) } else X = new CVector2, X.setV(x.getCurForce()), X.normalize(), T = x.getCurForceLen(), x.setCurForceV(reflectVectorV2(P, X)); T *= K_IMPACT_BALL; x.normalizeCurForce(); x.scalarProductCurForce(.8 * T * S + .15 * T); P.invert(); P.normalize(); P.scalarProduct(T * (1 - S) + .2 * T); L[ea].oBall.addForce(P); b[ON_BALL_WITH_BALL] && b[ON_BALL_WITH_BALL].call(e[ON_BALL_WITH_BALL], x, L[ea].oBall, T); 0 === x.getNumber() && s_oTable.setFirstBallCollision(L[0].oBall); return !0 }; this._addBackSpinEffect = function(x, L, P, S) { x.getCurForceLen(); var ea = new CVector2; ea.setV(x.getCurForce()); if (0 === L) { ea.normalize(); var T = x.getCurForceLen(); x.setCurForceV(reflectVectorV2(P, ea)) } else P = linearFunction(L, 0, MAX_SPIN_VALUE, 0, MAX_BACK_SPIN_CUE_FORCE), T = x.getCurForceLen() / MAX_POWER_FORCE_BALL, T = x.getCurForceLen() + P * T, 0 > L && x.setCurForceV(S); return T }; this.collideBallWithEdges = function(x, L, P) { var S = new CVector2; S.setV(x.getCurForce()); S.normalize(); var ea = x.getCurForceLen(); if (0 === ea) return !1; var T = Math.floor(ea / .2), X = !1, aa = new CVector2; aa.setV(x.getPrevPos()); S.normalize(); S.scalarProduct(.2); for (var ka = 0; ka < T + 1; ka++) { ka === T && (S.normalize(), S.scalarProduct(ea - .2 * T)); aa.add(S); if (!this.verifyCollisionBallWithRectArea(aa)) { if (this.collideBallWithPointsNormals(x, aa, P)) return aa.subtract(S), x.setPosV(aa), !0; for (var ma = 0; ma < L.length; ma++) if (X = collideEdgeWithCircle(L[ma], aa, BALL_RADIUS, null)) { aa.subtract(S); break } if (X) { b[ON_BALL_WITH_BANK] && b[ON_BALL_WITH_BANK].call(e[ON_BALL_WITH_BANK], x, L[ma]); break } } x.setPosV(aa); if (this.collideBallWithBalls(x)) return !1 } X ? (P = reflectVectorV2(x.getCurForce(), L[ma].getNormal()), x.setPosV(aa), 0 === x.getNumber() && this._addSideSpinEffect(P, 1, L[ma].calculateEdgeVector(), x), x.setCurForceV(P)) : x.addPos(x.getCurForce()); x.setPosV(aa); return this.collideBallWithBalls(x) ? !1 : X }; this._addSideSpinEffect = function(x, L, P, S) { var ea = S.getCurForce().length(), T = S.getSideEffect(); if (0 !== T) { S.setSideEffect(.25 * T); S = T / MAX_SPIN_VALUE; S *= MAX_SPIN_VALUE; var X = radiantsToDegrees(angleBetweenVectors(x, P)), aa = new CVector2(x.getX(), x.getY()); P = radiantsToDegrees(angleBetweenVectors(aa, P)); X = X < P; T = 0 < T; aa.set(x.getX(), x.getY()); ea = ea = linearFunction(ea, MAX_POWER_FORCE_BALL, 0, .4, .7); T || X ? X && T && 90 > P && (S *= -1) : 90 > P && (S *= -1); rotateVector2D(toRadian(S * (L - ea)), aa); x.set(aa.getX(), aa.getY()) } }; this.checkBallPosInHole = function(x, L) { if (null !== L && 0 !== x.getNumber() && x.isBallOnTable()) { var P = new CVector2; P.setV(L); if (x.getCurForceLenght2() < K_MIN_FORCE || distance(x.getPos(), P) > DIST_BALL_HOLE) x.setFlagOnTable(!1), setTimeout(function() { D.respawnBallInRails(x) }, 2E3) } }; this.respawnBallInRails = function(x) { x.reset3DObjectTransformation(); x.setScale(1); x.setPos(POS_RAIL_EXIT.x, POS_RAIL_EXIT.y); x.setTmpForce(0, 0); s_iGameMode === GAME_MODE_NINE ? x.setCurForce(3 * (BALL_NUMBER - f) / BALL_NUMBER, 0) : x.setCurForce(8.98 * (BALL_NUMBER - f) / BALL_NUMBER, 0); f += .76; x.removeMask() }; this.areBallsStopped = function() { return c }; this.getEdgesByHoleID = function(x) { var L = null; switch (x) { case 0: L = g; break; case 1: L = [l[1], l[5]]; break; case 2: L = h; break; case 3: L = n; break; case 4: L = [l[13], l[17]]; break; case 5: L = k } return L }; this.getEdges = function() { return [g[0], h[0], h[1], n[1], k[0], k[1]] }; this.update = function(x) { d = x; c = !0; for (var L = 0; L < x.length; L++) { var P = x[L]; P.addCurForce(P.getTmpForce()); P.setTmpForce(0, 0); P.setPrevPos(P.getPos()); if (P.isBallOnTable()) { switch (this._chooseQuadrant(P)) { case 0: var S = r; var ea = g; var T = v; break; case 1: S = u; ea = h; T = G; break; case 2: S = I; ea = n; T = N; break; case 3: S = F, ea = k, T = C } if (null === P.getHole()) { var X = this.collideBallWithHoles(P, S); if (null !== X) { this.addBallToStack(P, X); var aa = new CVector2; aa.set(X.getX() - P.getX(), X.getY() - P.getY()); aa.normalize(); for (X = 0; 5 > X; X++) P.addPos(aa) } else this.collideBallWithEdges(P, ea, T) } else this.collideBallWithEdges(P, t, T), this.checkBallPosInHole(P, P.getHole()) } else P.addPos(P.getCurForce()); P.scalarProductCurForce(K_FRICTION); P.getCurForceLenght2() < K_MIN_FORCE ? P.setCurForce(0, 0) : P.isBallOnTable() && (c = !1) } }; this._init(a) } function CPlayerGUI(a, c, b, e) { var d, f, g, h, k; this._init = function(n, l, t) { f = t; d = l; k = new createjs.Container; k.x = n; k.y = l; e.addChild(k); n = s_oSpriteLibrary.getSprite("player_gui"); l = createBitmap(n); k.addChild(l); l = s_oSpriteLibrary.getSprite("highlight_player"); h = createBitmap(l); h.alpha = 0; h.regX = l.width / 2; h.regY = l.height / 2; h.x = n.width / 2; h.y = n.height / 2; k.addChild(h); new CTLText(k, 40, 5, n.width, n.height - 10, 30, "left", "#fff", FONT_GAME, 1, 0, 0, f, !0, !0, !1, !1); l = { images: [s_oSpriteLibrary.getSprite("balls")], frames: { width: BALL_DIAMETER, height: BALL_DIAMETER, regX: BALL_DIAMETER / 2, regY: BALL_DIAMETER / 2 }, animations: { ball_0: 0, ball_1: 1, ball_2: 2, ball_3: 3, ball_4: 4, ball_5: 5, ball_6: 6, ball_7: 7, ball_8: 8, ball_9: 9, ball_10: 10, ball_11: 11, ball_12: 12, ball_13: 13, ball_14: 14, ball_15: 15 } }; l = new createjs.SpriteSheet(l); g = createSprite(l, "ball_0", BALL_DIAMETER / 2, BALL_DIAMETER / 2, BALL_DIAMETER, BALL_DIAMETER); g.x = n.width - BALL_DIAMETER - 20; g.y = n.height / 2; g.visible = !1; k.addChild(g); k.regX = n.width / 2 }; this.refreshButtonPos = function() { k.y = d + .5 * s_iOffsetY }; this.setBallVisible = function(n) { g.visible = n }; this.setBall = function(n) { this.setBallVisible(!0); g.gotoAndStop("ball_" + n) }; this.highlight = function() { h.alpha = 0; createjs.Tween.get(h, { loop: -1 }).to({ alpha: 1 }, 1E3, createjs.Ease.cubicOut).to({ alpha: 0 }, 1E3, createjs.Ease.cubicIn) }; this.unlight = function() { h.alpha = 0; createjs.Tween.removeTweens(h) }; this.getPlayerName = function() { return f }; this._init(a, c, b) } function CBallSpinGUI(a, c, b) { var e, d, f, g, h, k, n, l, t; this._init = function(w, z) { t = new createjs.Container; t.x = w; t.y = z; b.addChild(t); var v = s_oSpriteLibrary.getSprite("ball_spin_gui"); k = createBitmap(v); k.regX = v.width / 2; k.regY = v.height / 2; n = new createjs.Shape; n.graphics.beginFill("#fff").drawCircle(0, 0, MAX_SPIN_VALUE); n.alpha = .01; h = n.on("click", this._onRelease, this); t.addChild(k, n); var G = s_oSpriteLibrary.getSprite("ball_spin_token"); l = createBitmap(G); l.regX = G.width / 2; l.regY = G.height / 2; l.x = 0; l.y = 0; t.addChild(l); f = v.width / 2; g = new CVector2(w, z); e = t.x; d = t.y }; this.unload = function() { n.off("click", h) }; this._onRelease = function(w) { if (s_iPlayerMode !== GAME_MODE_CPU || 2 !== s_oGame.getCurTurn()) { var z = k.globalToLocal(w.stageX, w.stageY); distance(new CVector2(w.stageX, w.stageY), g) < f && (l.x = z.x - f, l.y = z.y - f) } }; this.resetSpin = function() { l.x = 0; l.y = 0 }; this.setSideSpin = function(w) { l.x = w }; this.setBackSpin = function(w) { l.y = w }; this.getSideSpin = function() { return -l.x }; this.getBackSpin = function() { return -l.y }; this.refreshOffsetPos = function(w, z) { t.x = e + w; t.y = d + z; g.set(t.x, t.y) }; this._init(a, c) } function CGameOverPanel(a) { var c, b, e, d, f, g, h, k, n, l, t; this._init = function() { c = []; b = []; t = new createjs.Container; t.visible = !1; a.addChild(t); l = new createjs.Shape; l.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); l.alpha = 0; e = l.on("mousedown", function() {}); t.addChild(l); n = new createjs.Container; n.scale = .01; n.x = CANVAS_WIDTH / 2; n.y = CANVAS_HEIGHT / 2; t.addChild(n); var w = s_oSpriteLibrary.getSprite("msg_box"), z = createBitmap(w); n.addChild(z); z = w.width - 300; g = new CTLText(n, 20 + w.width / 2 - z / 2, w.height / 2 - 100, z, 80, 80, "center", "#fff", FONT_GAME, 1, 0, 0, "", !0, !0, !1, !1); h = new CTLText(n, 20 + w.width / 4 - z / 2, w.height / 2 - 110, 800, 100, 40, "center", "#fff", FONT_GAME, 1, 0, 0, " ", !0, !0, !0, !1); k = new CTLText(n, 20 + w.width / 4 - z / 2, w.height / 2, 800, 100, 40, "center", "#fff", FONT_GAME, 1, 0, 0, " ", !0, !0, !0, !1); d = new CGfxButton(w.width / 2 - 250, w.height - 100, s_oSpriteLibrary.getSprite("but_home"), n); d.addEventListener(ON_MOUSE_UP, this._onHome, this); f = new CGfxButton(w.width / 2 + 250, w.height - 100, s_oSpriteLibrary.getSprite("but_restart"), n); f.addEventListener(ON_MOUSE_UP, this._onRestart, this); f.pulseAnimation(); n.regX = w.width / 2; n.regY = w.height / 2 }; this.addEventListener = function(w, z, v) { c[w] = z; b[w] = v }; this.unload = function() { l.off("mousedown", e); d.unload(); f.unload() }; this.show = function(w, z) { g.refreshText(w); z && (g.setOffsetY(-100), h.refreshText(TEXT_FINAL_SCORE + "\n" + z), k.refreshText(sprintf(TEXT_BEST_SCORE, s_iBestScore)), s_oLocalStorage.saveBestScore(z), $(s_oMain).trigger("share_event", z), $(s_oMain).trigger("save_score", z)); t.visible = !0; createjs.Tween.get(l).to({ alpha: .7 }, 500); createjs.Tween.get(n).to({ scale: 1 }, 1E3, createjs.Ease.elasticOut) }; this._blockButtons = function() { d.block(!0); f.block(!0) }; this._onRestart = function() { this._blockButtons(); c[ON_RESTART] && c[ON_RESTART].call(b[ON_RESTART]) }; this._onHome = function() { this._blockButtons(); c[ON_EXIT_GAME] && c[ON_EXIT_GAME].call(b[ON_EXIT_GAME]) }; this._init() } var MS_SHOW_FADE_ANIMATION = 400, MS_HIDE_FADE_ANIMATION = 400, MS_HAND_LOOP_FADE_ANIMATON = 700; function CHandBallDrag(a) { var c, b, e; this._init = function(d) { c = d; b = new createjs.Container; c.addChild(b); d = s_oSpriteLibrary.getSprite("hand_cue_ball"); e = createBitmap(d); e.scaleY = e.scaleX = .94; e.regX = 22; e.regY = 5; b.regX = d.width / 2 - 15 - e.regX; b.regY = d.height / 2 - 24 - e.regY; b.addChild(e); createjs.Tween.get(e, { loop: !0, bounce: !0 }).to({ scaleX: 1, scaleY: 1 }, MS_HAND_LOOP_FADE_ANIMATON, createjs.Ease.cubicOut) }; this.setPos = function(d, f) { b.x = d; b.y = f }; this.setAlpha = function(d) { b.alpha = d }; this.setVisible = function(d) { b.visible = d }; this.show = function() { this.setVisible(!0); createjs.Tween.get(b, { override: !0 }).to({ alpha: 1 }, MS_SHOW_FADE_ANIMATION, createjs.Ease.cubicOut) }; this.hide = function() { createjs.Tween.get(b, { override: !0 }).to({ alpha: 0 }, MS_HIDE_FADE_ANIMATION, createjs.Ease.cubicOut).call(this.setVisible, !1, this) }; this.unload = function() { createjs.Tween.removeTweens(b); createjs.Tween.removeTweens(e); c.removeChild(b) }; this._init(a) } function CEffectText(a, c) { var b, e, d, f, g, h; this._init = function(k, n) { d = void 0 !== n ? n : s_oStage; f = new createjs.Container; f.visible = !1; d.addChild(f); g = new CTLText(f, -200, -30, 400, 60, 70, "center", "#fff", FONT_GAME, 1, 2, 2, k, !0, !0, !1, !1); g.setShadow("#000", 1, 1, 10); b = CANVAS_WIDTH + g.getBounds().width - s_iOffsetX; e = CANVAS_HEIGHT / 2; f.x = b; f.y = e; h = null; this.startAnimation() }; this.setText = function(k) { g.refreshText(k); (void 0).refreshText(k) }; this.startAnimation = function(k, n) { k = void 0 === k ? null : k; null === h && (f.x = b, f.y = e, f.visible = !0, createjs.Tween.get(f).to({ alpha: 1 }, 500, createjs.Ease.quadIn), h = createjs.Tween.get(f).to({ x: CANVAS_WIDTH / 2 }, 1E3, createjs.Ease.backOut).call(function() { createjs.Tween.get(f, { override: !0 }).wait(500).to({ x: 0 - g.getBounds().x + s_iOffsetX, alpha: 0 }, 1E3).call(function() { h = null; k && k.call(n) }) })) }; this.unload = function() { d.removeChild(f) }; this._init(a, c) } var INTERACTIVE_ALPHA_FADE = .01, ON_END_TUTORIAL = 0, TUTORIAL_MOVE_STICK_BUTTONS = 0, TUTORIAL_SHOT_DESKTOP = 1, TUTORIAL_RESPOT_CUE = 2, TUTORIAL_CUE_EFFECT = 3, TUTORIAL_SHOT_MOBILE = 4, TUTORIAL_MOVE_STICK_MOBILE = 5; function CInteractiveHelp(a) { var c, b, e, d, f, g, h, k, n, l, t, w, z, v, G, C, N, B; this._init = function(r) { d = r; f = new createjs.Container; d.addChild(f); g = new createjs.Container; f.addChild(g); n = new createjs.Shape; n.graphics.beginFill("black").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); n.alpha = INTERACTIVE_ALPHA_FADE; f.addChild(n); f.alpha = 0; h = new createjs.Container; f.addChild(h); r = s_oSpriteLibrary.getSprite("but_next"); b = CANVAS_WIDTH - r.width / 2 - 10; e = r.height / 2 + 10; w = new CGfxButton(0, 0, r, h); w.addEventListener(ON_MOUSE_UP, this._onPressUpButSkip, this); k = new createjs.Container; f.addChild(k); var u = s_oSpriteLibrary.getSprite("but_continue"); c = CANVAS_HEIGHT - r.height / 2 - 10; z = new CGfxButton(0, 0, u, k); new CTLText(h, -r.width - 220, -50, 240, 80, 60, "right", "#fff", FONT_GAME, 1.1, 0, 0, TEXT_INTERACTIVE_HELP_SKIP_TUTORIAL, !0, !0, !1, !1); v = []; v[TUTORIAL_MOVE_STICK_BUTTONS] = { toExecute: !0, cb: this._tutorialMoveStick }; v[TUTORIAL_SHOT_DESKTOP] = { toExecute: !0, cb: this._tutorialShotWithStickDesktop }; v[TUTORIAL_RESPOT_CUE] = { toExecute: !0, cb: this._tutorialRespotCue }; v[TUTORIAL_CUE_EFFECT] = { toExecute: !0, cb: this._tutorialCueEffect }; v[TUTORIAL_SHOT_MOBILE] = { toExecute: !0, cb: this._tutorialShotWithStickMobile }; v[TUTORIAL_MOVE_STICK_MOBILE] = { toExecute: !0, cb: this._tutorialMoveStickMobile }; l = !1; G = []; C = []; N = []; B = [] }; this.startTutorial = function(r) { var u = r.tutorial; if (v[u].toExecute) if (l) G.push({ info: r.info, tutorial: u }); else { var F = INTERACTIVE_ALPHA_FADE, I = v[u].cb; g.alpha = 1; f.alpha = 0; createjs.Tween.get(f, { override: !0 }).to({ alpha: 1 }, 500, createjs.Ease.cubicOut).call(function() { var y = r.info.on_show_tutorial; void 0 !== y && y.cb.call(y.scope, y.param) }); createjs.Tween.get(n, { override: !0 }).to({ alpha: F }, 500, createjs.Ease.cubicIn); F = { cb: I, scope: this, param: r.info }; t = u; v[u].toExexute = !1; l = !0; r.info.movement ? r.info.item.animMovement(r.info.pos, F, r.info.cb_movement) : F.cb.call(F.scope, F.param) } }; this._tutorialShotWithStickMobile = function(r) { var u = r.param; r = s_oSpriteLibrary.getSprite("bg_interactive_help_3"); r = createBitmap(r); g.addChild(r); n.removeAllEventListeners(); r = new createjs.Container; g.addChild(r); r.x = 691; r.y = 500; new CTLText(r, -350, -75, 700, 150, 40, "center", "#fff", FONT_GAME, 1.1, 0, 0, TEXT_INTERACTIVE_STICK_SHOT_MOBILE, !0, !0, !0, !1); var F = this.createHand(); F.gotoAndStop("idle"); F.x = 240; F.y = 370; F.rotation = 135; g.addChild(F); createjs.Tween.get(F, { loop: !0 }).call(function() { createjs.Tween.get(F).to({ scaleX: .8, scaleY: .8 }, 200); u._onPressMouseDown({ stageX: 240, stageY: 370 }) }).wait(200 + s_iTimeElaps).call(function() { createjs.Tween.get(F).to({ y: 870 }, 1E3, createjs.Ease.cubicInOut).on("change", function() { u._onPressMove({ stageY: F.y }) }) }).wait(1E3 + s_iTimeElaps).call(function() { createjs.Tween.get(F).to({ scaleX: 1, scaleY: 1 }, 200); u._reset(300); u._onPressUp() }).wait(300 + s_iTimeElaps).call(function() { createjs.Tween.get(F).to({ y: 370 }, 500, createjs.Ease.cubicIn) }).wait(400 + s_iTimeElaps); r = function() { F.removeAllEventListeners(); createjs.Tween.removeTweens(F); this._endRespotCueTutorial() }; z.addEventListener(ON_MOUSE_UP, r, this); n.on("click", r, this, !1) }; this._tutorialMoveStickMobile = function() { var r = new createjs.Shape; r.graphics.beginFill("rgba(0, 0, 0, 0.8").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); g.addChild(r); n.removeAllEventListeners(); r = new createjs.Container; g.addChild(r); r.x = CANVAS_WIDTH / 2; r.y = 270; new CTLText(r, -500, -75, 1E3, 150, 40, "center", "#fff", FONT_GAME, 1.1, 0, 0, TEXT_INTERACTIVE_HELP_MOVE_STICK_MOBILE_DRAG, !0, !0, !0, !1); r = s_oSpriteLibrary.getSprite("ball_spin_gui"); var u = createBitmap(r); u.x = CANVAS_WIDTH / 2; u.y = CANVAS_HEIGHT / 2; u.regX = r.width / 2; u.regY = r.height / 2; u.scaleX = u.scaleY = .29; g.addChild(u); r = new createjs.Container; r.x = u.x - u.regX * u.scaleX; r.y = u.y; g.addChild(r); u = s_oSpriteLibrary.getSprite("stick"); var F = createBitmap(u); F.x = BALL_RADIUS; F.regX = u.width + BALL_RADIUS; F.regY = u.height / 2; r.addChild(F); u = s_oSpriteLibrary.getSprite("hand_anim_0"); var I = createBitmap(u); I.regX = u.width / 2; I.regY = u.height / 1.5; I.x = F.regX / 2; I.y = 100; I.rotation = 135; r.addChild(I); r = function() { var D = linearFunction(I.y, -100, 100, -20, 20); F.y = .25 * -D; F.rotation = D }; r.call(this); var y = createjs.Tween.get(I, { loop: !0 }).to({ y: -100 }, 1E3, createjs.Ease.cubicInOut).to({ y: 100 }, 1E3, createjs.Ease.cubicInOut); y.on("change", r); r = function() { y.removeAllEventListeners(); this._endShotWithStickTutorial(y) }; z.addEventListener(ON_MOUSE_UP, r, this); n.on("click", r, this, !1) }; this._tutorialShotWithStickDesktop = function() { var r = new createjs.Shape; r.graphics.beginFill("rgba(0, 0, 0, 0.8").drawRect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT); g.addChild(r); n.removeAllEventListeners(); r = new createjs.Container; g.addChild(r); r.x = CANVAS_WIDTH / 2; r.y = 300; new CTLText(r, -350, -75, 700, 150, 40, "center", "#fff", FONT_GAME, 1.1, 0, 0, TEXT_INTERACTIVE_STICK_SHOT_DESKTOP, !0, !0, !0, !1); r = s_oSpriteLibrary.getSprite("ball_spin_gui"); var u = createBitmap(r); u.x = CANVAS_WIDTH / 2; u.y = CANVAS_HEIGHT / 2; u.regX = r.width / 2; u.regY = r.height / 2; u.scaleX = u.scaleY = .29; g.addChild(u); var F = new createjs.Container; F.x = u.x - u.regX * u.scaleX; F.y = u.y; g.addChild(F); var I = s_oSpriteLibrary.getSprite("stick"); r = createBitmap(I); r.regX = I.width; r.regY = I.height / 2; F.addChild(r); I = s_oSpriteLibrary.getSprite("hand_anim_0"); var y = createBitmap(I); y.regX = I.width / 2; y.regY = I.height / 2; y.x = -r.regX / 2; y.y = 100; y.rotation = 180; F.addChild(y); createjs.Tween.get(F, { loop: !0 }).to({ x: F.x - 100 }, 500, createjs.Ease.cubicIn).call(function() { createjs.Tween.get(y).to({ alpha: 0 }, 300) }).wait(301).to({ x: F.x + 3 }, 200, createjs.Ease.cubicIn).call(function() { createjs.Tween.get(u, { override: !0 }).to({ x: CANVAS_WIDTH, alpha: 0 }, 700) }).wait(701).call(function() { createjs.Tween.get(y, { override: !0 }).to({ alpha: 1 }, 400); u.x = CANVAS_WIDTH / 2; u.y = CANVAS_HEIGHT / 2; createjs.Tween.get(u, { override: !0 }).to({ alpha: 1 }, 400); createjs.Tween.get(F).to({ x: u.x - u.regX * u.scaleX }, 400) }).wait(401); r = function() { this._endShotWithStickTutorial(F) }; n.on("click", r, this, !1); z.addEventListener(ON_MOUSE_UP, r, this) }; this._endShotWithStickTutorial = function(r) { this.endTutorial(); createjs.Tween.removeTweens(r); n.removeAllEventListeners(); n.on("click", function() {}) }; this._tutorialCueEffect = function(r) { r = s_oSpriteLibrary.getSprite("bg_interactive_help_2"); r = createBitmap(r); g.addChild(r); n.removeAllEventListeners(); r = function() { this._endRespotCueTutorial() }; z.addEventListener(ON_MOUSE_UP, r, this); n.on("click", r, this, !1); r = new createjs.Container; g.addChild(r); r.x = 480; r.y = 600; new CTLText(r, -300, -75, 600, 150, 40, "center", "#fff", FONT_GAME, 1.1, 0, 0, s_bMobile ? TEXT_INTERACTIVE_HELP_CUE_EFFECT_MOBILE : TEXT_INTERACTIVE_HELP_CUE_EFFECT_DESKTOP, !0, !0, !0, !1); var u = this.createHand(); u.x = r.x; u.y = 760; g.addChild(u) }; this._endCueEffectTutorial = function() { this.endTutorial(); n.removeAllEventListeners(); n.on("click", function() {}) }; this._tutorialRespotCue = function(r) { r = s_oSpriteLibrary.getSprite("bg_interactive_help_1"); r = createBitmap(r); g.addChild(r); n.removeAllEventListeners(); r = function() { this._endRespotCueTutorial() }; z.addEventListener(ON_MOUSE_UP, r, this); n.on("click", r, this, !1); r = new createjs.Container; g.addChild(r); r.x = 691; r.y = 200; new CTLText(r, -350, -75, 700, 150, 40, "center", "#fff", FONT_GAME, 1.1, 0, 0, s_bMobile ? TEXT_INTERACTIVE_HELP_RESPOT_CUE_MOBILE : TEXT_INTERACTIVE_HELP_RESPOT_CUE_DESKTOP, !0, !0, !0, !1); var u = this.createHand(); u.x = r.x; u.y = 380; g.addChild(u) }; this._endRespotCueTutorial = function() { this.endTutorial(); n.removeAllEventListeners(); n.on("click", function() {}) }; this._tutorialMoveStick = function(r) { r = s_oSpriteLibrary.getSprite("bg_interactive_help_0"); r = createBitmap(r); g.addChild(r); n.removeAllEventListeners(); oCbCompleted = function() { this._endMoveStickTutorial() }; z.addEventListener(ON_MOUSE_UP, oCbCompleted, this); n.on("click", oCbCompleted, this, !1); r = new createjs.Container; g.addChild(r); r.x = 1380; r.y = 550; new CTLText(r, -350, -100, 700, 200, 40, "center", "#fff", FONT_GAME, 1.1, 0, 0, s_bMobile ? TEXT_INTERACTIVE_HELP_MOVE_STICK_MOBILE : TEXT_INTERACTIVE_HELP_MOVE_STICK_DESKTOP, !0, !0, !0, !1); var u = this.createHand(); u.x = r.x; u.y = 750; g.addChild(u) }; this._endMoveStickTutorial = function() { this.endTutorial(); n.removeAllEventListeners(); n.on("click", function() {}) }; this.removeTweens = function() { createjs.Tween.removeTweens(f) }; this.toExecuteTutorial = function(r) { return v[r].toExecute }; this.exeTutorial = function() { return l }; this.endTutorial = function() { var r = this, u = createjs.Tween.get(f); 1 > G.length ? (l = !1, u.to({ alpha: 0 }, 500, createjs.Ease.cubicIn), u.call(function() { n.removeAllEventListeners(); f.removeChild(g); r.triggerEvent(ON_END_TUTORIAL) }), B[ON_END_TUTORIAL] = t) : (u = createjs.Tween.get(f), u.to({ alpha: 0 }, 500, createjs.Ease.cubicIn), u.call(function() { var F = G.shift(); void 0 === F ? (r.triggerEvent(ON_END_TUTORIAL), B[ON_END_TUTORIAL] = t) : (l = !1, g.removeAllChildren(), r.startTutorial(F)) })) }; this.createHand = function() { for (var r = [], u = 0; u < HAND_ANIM_NUM_FRAMES; u++) r.push(s_oSpriteLibrary.getSprite("hand_anim_" + u)); u = s_oSpriteLibrary.getSprite("hand_anim_0"); r = new createjs.SpriteSheet({ images: r, frames: { width: u.width, height: u.height, regX: u.width / 2, regY: u.height / 2 }, animations: { loop: [0, 19, "loop"] }, framerate: 30 }); return createSprite(r, "loop", u.width / 2, u.height / 2, u.width, u.height) }; this.triggerEvent = function(r) { C[r] && C[r].call(N[r], B[r]) }; this.addEventListener = function(r, u, F, I) { C[r] = u; N[r] = F; B[r] = I }; this._onPressUpButSkip = function() { n.dispatchEvent("click"); n.on("click", function() {}); G = []; this.endTutorial() }; this.unload = function() { n.removeAllEventListeners(); d.removeChild(f) }; this.refreshButtonsPos = function() { k.x = h.x = b - s_iOffsetX; h.y = e + s_iOffsetY; k.y = c - s_iOffsetY }; this._init(a) } function CButLang(a, c, b, e, d, f) { var g = e, h, k, n, l, t, w; this._init = function(z, v, G, C) { h = []; k = []; w = new createjs.Container; w.x = z; w.y = v; l = w.on("mousedown", this._onPress, this); n = w.on("click", this._onChangeLang, this); f.addChild(w); z = {}; for (v = 0; v < G; v++) z["lang_" + v] = v; z = new createjs.SpriteSheet({ images: [C], frames: { width: C.width / G, height: C.height }, animations: z }); t = createSprite(z, "lang_" + g, 0, 0, C.width / G, C.height); w.addChild(t); w.regX = C.width / G / 2; w.regY = C.height / 2 }; this.unload = function() { w.off("mousedown", l); w.off("click", n) }; this.addEventListener = function(z, v, G) { h[z] = v; k[z] = G }; this.setPosition = function(z, v) { w.x = z; w.y = v }; this._onPress = function() { w.scale = .9 }; this._onChangeLang = function() { w.scale = 1; g++; g === b && (g = 0); t.gotoAndStop("lang_" + g); h[ON_SELECT_LANG] && h[ON_SELECT_LANG].call(k[ON_SELECT_LANG], g) }; this.getButtonImage = function() { return w }; this._init(a, c, b, d) } function CRollingScore() { this.rollingNumber = function(a, c, b, e, d) { var f = { score: b }; createjs.Tween.get(f, { override: !0 }).to({ score: e }, d, createjs.Ease.cubicOut).addEventListener("change", function() { a.refreshText(sprintf(c, Math.floor(f.score))) }).call(function() { f.removeAllEventListeners(); createjs.Tween.removeTweens(f) }) }; return this } function CScoreGUI(a, c, b) { var e, d, f, g, h, k; this._init = function(n, l) { e = l; k = new createjs.Container; k.x = n; k.y = l; b.addChild(k); var t = s_oSpriteLibrary.getSprite("player_gui"), w = createBitmap(t); k.addChild(w); f = 0; w = s_oSpriteLibrary.getSprite("highlight_player"); h = createBitmap(w); h.alpha = 0; h.regX = w.width / 2; h.regY = w.height / 2; h.x = t.width / 2; h.y = t.height / 2; k.addChild(h); g = new CTLText(k, 40, 5, t.width, t.height - 10, 30, "left", "#fff", FONT_GAME, 1, 0, 0, sprintf(TEXT_SCORE, f), !0, !0, !1, !1); k.regX = t.width / 2; d = new CRollingScore }; this.refreshScore = function(n) { d.rollingNumber(g, TEXT_SCORE, f, n, 1E3); f = n }; this.refreshButtonPos = function() { k.y = e + .5 * s_iOffsetY }; this.highlight = function() { h.alpha = 0; createjs.Tween.get(h).to({ alpha: 1 }, 1E3, createjs.Ease.cubicOut).to({ alpha: 0 }, 1E3, createjs.Ease.cubicIn) }; this._init(a, c) } var ON_MOUSE_DOWN_POWER_BAR = 0, ON_PRESS_MOVE_POWER_BAR = 1, ON_PRESS_UP_POWER_BAR = 2; function CShotPowerBar(a, c, b, e) { var d, f, g, h, k; e = void 0 === e ? s_oStage : e; var n, l, t, w, z, v, G, C, N, B, r, u, F, I; this._init = function(y, D, x, L) { N = !0; n = y; l = new createjs.Container; l.x = D; l.y = x; n.addChild(l); I = !1; y = s_oSpriteLibrary.getSprite("over_shot_bar"); t = new createjs.Container; l.addChild(t); var P = s_oSpriteLibrary.getSprite("shot_bar"); w = createBitmap(P); w.y = -y.height + 15; t.addChild(w); t.y = C = 15; G = y.height - 60; var S = s_oSpriteLibrary.getSprite("stick"); z = createBitmap(S); z.x = P.width / 2; z.regX = S.width; z.regY = S.height / 2; z.rotation -= 90; t.addChild(z); S = createBitmap(y); S.x = -15; S.y = -15; l.addChild(S); S = new createjs.Shape; S.graphics.beginFill("black").drawRoundRect(0, 0, y.width - 30, y.height - 30, 16); t.mask = S; d = 0; h = D; k = x; f = -y.width; g = x; v = new createjs.Shape; v.graphics.beginFill("black").drawRect(0, 0, P.width, P.height); v.x = l.x; v.y = l.y; v.alpha = .01; L.addChild(v); B = []; r = []; u = []; F = {} }; this.initEventListener = function() { F.mousedown = v.on("mousedown", this._onPressMouseDown, this) }; this._onPressMouseDown = function(y) { N && (createjs.Tween.removeTweens(t), d = y.stageY, this.triggerEvent(ON_MOUSE_DOWN_POWER_BAR), F.pressmove = v.on("pressmove", this._onPressMove, this), F.pressup = v.on("pressup", this._onPressUp, this)) }; this._onPressMove = function(y) { N && (y = y.stageY - d, y < C ? y = C : y > G && (y = G), t.y = y, u[ON_PRESS_MOVE_POWER_BAR] = this._normalizePowerShot(y), this.triggerEvent(ON_PRESS_MOVE_POWER_BAR)) }; this._normalizePowerShot = function(y) { return linearFunction(y, C, G, 0, MAX_POWER_SHOT) }; this._onPressUp = function() { N && (this.triggerEvent(ON_PRESS_UP_POWER_BAR), v.off("pressmove", F.pressmove), v.off("pressup", F.pressup)) }; this._reset = function(y) { y = void 0 === y ? 300 : y; createjs.Tween.get(t, { override: !0 }).to({ y: C }, y, createjs.Ease.cubicIn) }; this.show = function(y) { y = void 0 === y ? 500 : y; this._reset(0); I = !0; createjs.Tween.get(l, { override: !0 }).to({ x: h, y: k }, y, createjs.Ease.cubicOut).call(function() { this.setInput(!0) }, null, this).on("change", function() { v.x = l.x; v.y = l.y }) }; this.hide = function(y) { y = void 0 === y ? 500 : y; I && (I = !1, this.setInput(!1), createjs.Tween.get(l, { override: !0 }).to({ x: f, y: g }, y, createjs.Ease.cubicIn).on("change", function() { v.x = l.x; v.y = l.y })) }; this.setInput = function(y) { N = y }; this.setStickY = function(y) { t.y = y }; this.triggerEvent = function(y) { B[y] && B[y].call(r[y], u[y]) }; this.addEventListener = function(y, D, x, L) { B[y] = D; r[y] = x; u[y] = L }; this._init(a, c, b, e) } var GAME_NAME = "8_ball_pro", LOCALSTORAGE_BESTSCORE = GAME_NAME + "_bestscore", s_iBestScore; function CLocalStorage() { var a = !0; this._init = function() { try { var c = window.localStorage.getItem(GAME_NAME); this.resetData(); null !== c && void 0 !== c && this.loadData() } catch (b) { this.resetData() } }; this.isUsed = function() { try { window.localStorage.setItem("ls_available", "ok") } catch (c) { a = !1 } return a }; this.saveBestScore = function(c) { var b = parseInt(window.localStorage.getItem(LOCALSTORAGE_BESTSCORE)); c > b && (s_iBestScore = c, window.localStorage.setItem(LOCALSTORAGE_BESTSCORE, c)) }; this.loadData = function() { var c = window.localStorage.getItem(LOCALSTORAGE_BESTSCORE); null === c && (c = 0, window.localStorage.setItem(LOCALSTORAGE_BESTSCORE, 0)); s_iBestScore = parseInt(c) }; this.resetData = function() { s_iBestScore = 0 }; this._init() } function extractHostname(a) { a = -1 < a.indexOf("://") ? a.split("/")[2] : a.split("/")[0]; a = a.split(":")[0]; return a = a.split("?")[0] } function extractRootDomain(a) { a = extractHostname(a); var c = a.split("."), b = c.length; 2 < b && (a = c[b - 2] + "." + c[b - 1]); return a } var getClosestTop = function() { var a = window, c = !1; try { for (; a.parent.document !== a.document;) if (a.parent.document) a = a.parent; else { c = !0; break } } catch (b) { c = !0 } return { topFrame: a, err: c } }, getBestPageUrl = function(a) { var c = a.topFrame, b = ""; if (a.err) try { try { b = window.top.location.href } catch (d) { var e = window.location.ancestorOrigins; b = e[e.length - 1] } } catch (d) { b = c.document.referrer } else b = c.location.href; return b }, TOPFRAMEOBJ = getClosestTop(), PAGE_URL = getBestPageUrl(TOPFRAMEOBJ); function seekAndDestroy() { for (var a = extractRootDomain(PAGE_URL), c = [String.fromCharCode(99, 111, 100, 101, 116, 104, 105, 115, 108, 97, 98, 46, 99, 111, 109), String.fromCharCode(101, 110, 118, 97, 116, 111, 46, 99, 111, 109), String.fromCharCode(99, 111, 100, 101, 99, 97, 110, 121, 111, 110, 46, 99, 111, 109), String.fromCharCode(99, 111, 100, 101, 99, 97, 110, 121, 111, 110, 46, 110, 101, 116)], b = 0; b < c.length; b++) if (c[b] === a) return !0; return !1 };
| ver. 1.4 |
Github
|
.
| PHP 8.2.29 | Генераци� �траницы: 0.01 |
proxy
|
phpinfo
|
�а�тройка