logo change, style change, games json file; almost whole revamp is in this commit

This commit is contained in:
MonkeyGG2
2023-09-08 21:05:46 -04:00
parent 999b1858ac
commit a2f0a93a75
200 changed files with 172568 additions and 57 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

+40
View File
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-7L02W3ZMS5"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-7L02W3ZMS5');
</script>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-5648726754785335"
crossorigin="anonymous"></script>
<meta charset="utf-8" />
<title>Core Ball</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<canvas style="display: none;" id="stage"></canvas>
<div id="begin">
<section class="center-box">
<span class="title">Core Ball</span>
<div class="button">
<div id="txtAr"></div>
<div class="text"></div>
</div>
<div class="op">
<span id="btnFW"></span>
<span id="btnReset"></span>
<div id="tip"></div>
</div>
</section>
<section id="wxArrow"></section>
</div>
<script type="text/javascript" src="index.js"></script>
<script src="/global.js"></script>
</body>
</html>
+692
View File
@@ -0,0 +1,692 @@
"undefined" == typeof window.define && ((window.define = function () {}), (window.define.amd = 1)),
"undefined" == typeof window.$AJB && (window.$AJB = {}),
($AJB.lib = {}),
($AJB.general = {}),
($AJB.page = {}),
($AJB.lib.stopEvent = function () {
"use strict";
return function (a) {
a && (a.preventDefault ? (a.preventDefault(), a.stopPropagation()) : ((a.returnValue = !1), (a.cancelBubble = !0)));
};
}),
($AJB.lib.Storage = function () {
"use strict";
var a = {
setValue: function (a, b) {
window.localStorage && (window.localStorage[a] = b);
},
getValue: function (a) {
return window.localStorage ? window.localStorage[a] : void 0;
},
};
return a;
}),
($AJB.general.BeginStage = function () {
"use strict";
function a(a) {
function c() {
b(h, "click", function () {
e.fire(g, f);
}),
(j.innerHTML = "GO");
}
var h = a.getElementsByClassName("button")[0],
i = a.getElementsByClassName("text")[0],
j = document.getElementById("txtAr"),
k = {
show: function () {
a.style.display = "";
},
hide: function () {
a.style.display = "none";
},
level: function (a) {
(f = a), (i.innerHTML = "Level " + a);
},
on: function (a, b) {
e.add(a, b);
},
off: function (a, b) {
e.remove(a, b);
},
};
return c(), k;
}
var b = $AJB.lib.addEvent(),
c = $AJB.lib.CustEvent(),
d = $AJB.lib.util(),
e = c(),
f = 0,
g = "start";
return a;
}),
($AJB.general.Switcher = function () {
"use strict";
function a(a, b, c) {
var d,
e,
f = null,
g = !1,
h = {
point: [0, 0],
enabled: !1,
color: "#c8c8c8",
update: function () {
var a = h.point,
c = 30;
h.enabled &&
(0 === e
? ((d = h.color), a[0] < b / 2 ? ((a[0] = Math.min(a[0] + c, b / 2)), (h.point = a)) : ((h.point = a), (g = !0)))
: 1 === e && ((d = "#000"), a[0] > b / 2 ? ((a[0] = Math.max(a[0] - c, b / 2)), (h.point = a)) : ((h.point = a), (g = !0))));
},
render: function () {
var e = h.point;
h.enabled && ((a.fillStyle = d), a.fillRect(e[0] - b / 2, e[1] - c / 2, b, c), g && ((h.enabled = !1), f && f()));
},
switchStage: function (d, i) {
0 === d ? (h.point = [-b / 2, c / 2]) : 1 === d && ((a.fillStyle = h.color), a.fillRect(0, 0, b, c), (h.point = [b + b / 2, c / 2])), (h.enabled = !0), (g = !1), (e = d), (f = i);
},
};
return h;
}
return a;
}),
($AJB.lib.addEvent = function () {
var a = $AJB.lib.util(),
b = { click: "touchstart", mousedown: "touchstart", mouseup: "touchend" };
return function (c, d, e, f) {
c.addEventListener ? c.addEventListener(a.isMobile ? b[d] || d : d, e, f) : c.attachEvent ? c.attachEvent("on" + d, e) : (c["on" + d] = e);
};
}),
($AJB.general.Levels = function () {
"use strict";
function a(a, b) {
return function () {
var c = 0;
return function () {
return (c += (a * b) % 360);
};
};
}
function b(a, b) {
return function () {
var c = 0,
d = 1,
e = +new Date();
return function () {
var f = +new Date();
return f - e > b && ((d = -d), (e = f)), (c += (d * a) % 360);
};
};
}
function c(a, b, c, d) {
return function () {
var e = 0,
f = +new Date();
return function () {
var g = +new Date();
return g - f > c && ((a = b - a), (f = g)), (e += (a * d) % 360);
};
};
}
function d(a) {
var b = 1;
return (
h(document.body, "mousedown", function () {
b = -b;
}),
function () {
var c = 0;
return function () {
return (c += (a * b) % 360);
};
}
);
}
function e(a, b, c, d) {
return (
h(document.body, "mousedown", function () {
d = -d;
}),
function () {
var e = 0,
f = +new Date();
return function () {
var g = +new Date();
return g - f > c && ((a = b - a), (f = g)), (e += (a * d) % 360);
};
}
);
}
function f(a, b, c, d) {
i[a] = { childs: k[b], queueCount: c, round: j[d] };
}
var g,
h = $AJB.lib.addEvent(),
i = {},
j = {
A1: a(1.5, 1),
A2: a(1.5, -1),
B1: a(2.5, 1),
B2: a(2.5, -1),
C1: b(2.2, 3e3),
C2: b(3.5, 2e3),
D1: c(2, 2.3, 1200, 1),
D2: c(2, 2.3, 1200, -1),
D3: c(4, 4.5, 1700, 1),
D4: c(4, 4.5, 1700, -1),
D5: c(4, 4.5, 1700, 1),
D6: c(4, 4.5, 1700, -1),
E1: d(2),
E2: e(2, 2.3, 1e3, 1),
},
k = {
0: [],
2: [0, 180],
3: [0, 120, 240],
4: [0, 90, 180, 270],
5: [0, 72, 144, 216, 288],
6: [0, 60, 120, 180, 240, 300],
7: [0, 52, 103, 155, 206, 258, 309],
8: [0, 45, 90, 135, 180, 225, 270, 315],
9: [0, 40, 80, 120, 160, 200, 240, 280, 320],
10: [0, 36, 72, 108, 144, 180, 216, 252, 288, 324],
11: [0, 33, 66, 99, 131, 164, 197, 230, 262, 295, 328],
12: [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330],
13: [0, 28, 56, 84, 111, 139, 167, 194, 222, 250, 277, 305, 333],
14: [0, 26, 52, 78, 103, 129, 155, 180, 206, 232, 258, 283, 309, 335],
15: [0, 24, 48, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336],
16: [0, 23, 45, 68, 90, 113, 135, 158, 180, 203, 225, 248, 270, 293, 315, 338],
},
l = {
1: ["4", 8, "A1"],
2: ["6", 10, "A1"],
3: ["2", 20, "A1"],
4: ["8", 12, "A2"],
5: ["12", 8, "A1"],
6: ["10", 10, "A2"],
7: ["12", 12, "A1"],
8: ["16", 3, "A2"],
9: ["0", 26, "A2"],
10: ["16", 10, "A1"],
11: ["10", 8, "B1"],
12: ["6", 12, "B2"],
13: ["12", 4, "B1"],
14: ["8", 14, "B2"],
15: ["8", 6, "B1"],
16: ["5", 10, "B2"],
17: ["6", 12, "B1"],
18: ["8", 14, "B2"],
19: ["0", 23, "B1"],
20: ["10", 13, "B2"],
21: ["4", 12, "C1"],
22: ["6", 10, "C1"],
23: ["8", 12, "C1"],
24: ["7", 14, "C1"],
25: ["2", 18, "C1"],
26: ["4", 18, "C1"],
27: ["0", 24, "C1"],
28: ["4", 10, "C2"],
29: ["6", 13, "C2"],
30: ["4", 20, "C1"],
31: ["6", 8, "D1"],
32: ["2", 12, "D2"],
33: ["3", 14, "D2"],
34: ["3", 18, "D1"],
35: ["8", 12, "D1"],
36: ["7", 15, "D2"],
37: ["16", 8, "D2"],
38: ["0", 23, "D1"],
39: ["12", 12, "D1"],
40: ["12", 15, "D2"],
41: ["5", 10, "E1"],
42: ["6", 12, "E1"],
43: ["3", 15, "E1"],
44: ["3", 19, "E1"],
45: ["0", 24, "E1"],
46: ["2", 15, "E2"],
47: ["4", 16, "E2"],
48: ["12", 8, "E2"],
49: ["3", 20, "E2"],
50: ["16", 14, "E2"],
51: ["4", 6, "D3"],
52: ["4", 12, "D4"],
53: ["6", 13, "D3"],
54: ["0", 24, "D4"],
55: ["4", 21, "D3"],
56: ["16", 16, "A1"],
57: ["4", 24, "C1"],
58: ["4", 26, "D1"],
59: ["4", 25, "E2"],
60: ["13", 19, "E2"],
};
for (g in l) f(g, l[g][0], l[g][1], l[g][2]);
return i;
}),
($AJB.general.Collide = function () {
"use strict";
var a = $AJB.lib.util(),
b = {
check: function (b, c, d) {
var e = b.childs(),
f = e.length,
g = Math.ceil(2 * c.rad());
for (d = d || 1; f--; ) if (c !== e[f].ball && a.getPointDistance(c.pos(), e[f].ball.pos()) <= g + Math.ceil(2 * d)) return !0;
return !1;
},
};
return b;
}),
($AJB.general.Tween = function () {
"use strict";
var a = {
simple: function (b, c, d, e) {
var f = (c - b) / e,
g = +new Date();
return e > g - d ? ((a.isEnd = !1), b + (g - d) * f) : ((a.isEnd = !0), c);
},
isEnd: !0,
};
return a;
}),
($AJB.general.BallQueue = function () {
"use strict";
function a(a, f, g, h, i) {
function j() {
var b,
d,
e = k(a),
j = e.length;
for (b = 0; j > b; b++) (d = c(h, null, e[b], null, i)), d.pos(f, g + 3 * d.rad() * b), m.push(d);
}
function k(a) {
for (var b = a, c = []; b--; ) c.push(b + 1);
return c;
}
var l,
m = [],
n = [],
o = b();
return (
(i = i || 1),
(l = {
ballList: m,
add: function () {},
remove: function (a) {
var b = m[a];
return m.splice(a, 1), b;
},
clear: function () {
(n = []), (m = []);
},
popup: function () {
var a = m.shift();
(a.st = +new Date()), (a.sv = a.pos().y), n.push(a);
},
update: function () {
var a,
b,
c,
h = n.length,
i = m.length;
if (h) {
for (b = n[0].rad(), a = g - 3 * b; h--; ) n[h].pos(f, d.simple(n[h].sv, a, n[h].st, 50)), (c = n[n.length - 1].pos().y), n[h].pos().y === a && (o.fire(e, n[h]), n.splice(h, 1));
for (; i--; ) m[i].pos(f, c + 3 * b * (i + 1));
}
},
render: function () {
for (var a = m.length, b = n.length; a--; ) m[a].render();
for (; b--; ) n[b].render();
},
on: function (a, b) {
o.add(a, b);
},
off: function (a, b) {
o.remove(a, b);
},
destroy: function () {
for (var a = m.length; a--; ) m[a].destroy();
o.destroy();
},
}),
j(),
l
);
}
var b = $AJB.lib.CustEvent(),
c = $AJB.general.Ball(),
d = $AJB.general.Tween(),
e = "popup";
return a;
}),
($AJB.general.Ball = function () {
"use strict";
function a(a, c, d, e, f) {
function g() {
var c = b.getTextWidth(a, 0, 0, d, e);
b.drawText(a, i - c / 2, j + e / 3, d, e, "black");
}
var h,
i = 0,
j = 0;
return (
(f = f || 1),
(c = (c || 12) * f),
(e = (e || 15) * f),
(h = {
pos: function (a, b) {
return "undefined" != typeof a && (i = a), "undefined" != typeof b && (j = b), { x: i, y: j };
},
scale: function (a) {
return "undefined" != typeof a && (f = a), f;
},
rad: function (a) {
return "undefined" != typeof a && (c = a), c;
},
render: function (e) {
b.drawCircle(a, i, j, c, "#ffffff"), "undefined" != typeof d ? g(d) : "undefined" != typeof e && g(e);
},
destroy: function () {
h = null;
},
})
);
}
var b = $AJB.lib.util();
return a;
}),
($AJB.lib.util = function () {
"use strict";
return {
drawCircle: function (a, b, c, d, e) {
a.beginPath(), a.arc(b, c, d, 0, 2 * Math.PI, !1), (a.fillStyle = e || "red"), a.fill();
},
drawLine: function (a, b, c, d, e, f, g) {
(a.strokeStyle = f || "red"), (a.lineWidth = g || 1), a.beginPath(), a.moveTo(b, c), a.lineTo(d, e), a.stroke();
},
drawText: function (a, b, c, d, e, f) {
(a.font = e + "px Verdana"), (a.fillStyle = f || "red"), a.fillText(d, b, c);
},
getTextWidth: function (a, b, c, d, e, f) {
return (a.font = e + "px Verdana"), (a.fillStyle = f || "red"), a.measureText(d).width;
},
getPointDistance: function (a, b) {
return Math.floor(Math.sqrt(Math.floor(Math.pow(a.x - b.x, 2)) + Math.floor(Math.pow(a.y - b.y, 2))));
},
isMobile: /(mobile|iphone|ipod|ipad|ios|android|windows phone)/i.test(navigator.userAgent),
isAndroid: /android/i.test(navigator.userAgent),
isWeixin: /MicroMessenger/i.test(navigator.userAgent),
};
}),
($AJB.general.Core = function () {
"use strict";
function a(a, d, e, f, g) {
function h() {
for (var a, b, c, d, e = l.length; e--; )
(a = 3 * Math.cos(((l[e].angle + j.angle()) * Math.PI) / 180) * m * g + n), (b = 3 * Math.sin(((l[e].angle + j.angle()) * Math.PI) / 180) * m * g + o), (c = a / Math.abs(a)), (d = b / Math.abs(b)), l[e].ball.pos(a, b);
}
var i,
j,
k = 0,
l = [],
m = 50,
n = a.width / 2,
o = 4 * m * g;
return (
(g = g || 1),
(i = c(d, m, e, f, g)),
i.pos(n, o),
(j = {
pos: i.pos,
scale: i.scale,
rad: i.rad,
angle: function (a) {
return "undefined" != typeof a && (k = a), k;
},
addChild: function (a, b) {
l.push({ angle: a, ball: b });
},
clear: function () {
l = [];
},
childs: function () {
return l;
},
update: function () {
h();
},
render: function () {
var c,
e = l.length,
f = a.width,
h = a.height;
for (d.clearRect(0, 0, f, h), c = 0; e > c; c++) b.drawLine(d, n, o, l[c].ball.pos().x, l[c].ball.pos().y, "#ffffff", 1.5 * g), l[c].ball.render();
i.render();
},
destroy: function () {
j.clear(), (i = null), (j = null);
},
})
);
}
var b = $AJB.lib.util(),
c = $AJB.general.Ball();
return a;
}),
($AJB.lib.CustEvent = function () {
return function (a) {
function b(a) {
return Object.prototype.toString.call(a).slice(8, -1).toLowerCase();
}
var c = {};
return (
!a && (a = {}),
{
add: function (a, d) {
if ("function" === b(d)) {
var e = c;
(a = a.toLowerCase()), !e[a] && (e[a] = []), e[a].push(d);
}
},
remove: function (a, d) {
var e,
f = c[a];
if (((a = a.toLowerCase()), "function" === b(d) && f && f.length)) for (e = f.length - 1; e >= 0; e--) f[e] === d && f.splice(e, 1);
},
fire: function (b) {
var d, e, f, g;
if (((b = b.toLowerCase()), (d = c[b]), d && d.length)) for (e = Array.prototype.slice.call(arguments, 1), g = d.length, f = 0; g > f; f++) d[f].apply(a, e);
},
destroy: function () {
var a,
b = c.length - 1;
for (a = b; a >= 0; a--) evts.splice(a, 1);
},
}
);
};
}),
($AJB.general.Scene = function () {
"use strict";
function a(a, b, l, m) {
function n(a) {
var g = a.childs,
h = g.length;
for (y = a.round(), w && w.destroy(), w = c(b, l, B, 50, m); h--; ) w.addChild(g[h], d(l, null, "", null, m));
x && x.destroy(),
(x = e(a.queueCount, b.width / 2, w.pos().y + 4 * w.rad(), l, m)),
x.on("popup", function (a) {
w.addChild(90 - w.angle(), a), f.check(w, a, m) ? ((z = a), s()) : !x.ballList.length && r();
});
}
function o() {
y && (w.angle(y()), w.update(), x.update());
}
function p() {
var b,
c,
d,
e,
f = w.childs(),
g = f.length,
h = 25;
for (a.style.backgroundColor = u.bgColor; g--; ) (b = f[g].angle + w.angle()), (c = Math.cos((b * Math.PI) / 180) * h), (d = Math.sin((b * Math.PI) / 180) * h), (e = f[g].ball.pos()), f[g].ball.pos(e.x + c, e.y + d);
}
function q(a) {
var b,
c = [25, 15, 20, 15],
d = c.length,
e = 200,
f = e / d;
for (w.update(), b = 1; d >= b; b++) a > f * b && z.rad(c[b - 1] * m);
}
function r() {
"pass" !== A && ((a.style.backgroundColor = "#1CB01A"), (A = "pass"), (v = +new Date()));
}
function s() {
"fail" !== l && ((a.style.backgroundColor = "#B8111C"), (A = "fail"), (v = +new Date()));
}
function t() {
var a = "to be continued...",
c = h.getTextWidth(l, 0, 0, a, 30 * m);
h.drawText(l, (b.width - c) / 2, 200 * m, a, 30 * m, "yellow");
}
var u,
v,
w,
x,
y,
z,
A = "run",
B = 1;
return (u = {
enabled: !1,
run: function (b) {
var c = g[b];
(B = b), c ? ((u.enabled = !0), n(c), (a.style.backgroundColor = "#000"), (A = "run")) : t();
},
shot: function () {
x && x.ballList.length && x.popup();
},
update: function () {
var a;
u.enabled && ("run" === A ? o() : "pass" === A ? (p(), +new Date() - v > 1e3 && ((A = ""), k.fire(i))) : "fail" === A && ((a = +new Date() - v), q(a), a > 1e3 && ((A = ""), k.fire(j))));
},
render: function () {
u.enabled && (w.render(), x.render());
},
on: function (a, b) {
k.add(a, b);
},
off: function (a, b) {
k.remove(a, b);
},
});
}
var b = $AJB.lib.CustEvent(),
c = $AJB.general.Core(),
d = $AJB.general.Ball(),
e = $AJB.general.BallQueue(),
f = $AJB.general.Collide(),
g = $AJB.general.Levels(),
h = $AJB.lib.util(),
i = "passed",
j = "failed",
k = b();
return a;
}),
($AJB.general.Game = function () {
"use strict";
function a() {
var a = document.body.scrollWidth || document.documentElement.scrollWidth,
b = document.body.scrollHeight || document.documentElement.scrollHeight;
(r.width = a), (r.height = b), (i = l(x, a, b)), (s.style.backgroundColor = i.color), (s.style.width = a + "px"), (s.style.height = b + "px"), (j = b / 560);
}
function b() {}
function c() {
n(u, "mousedown", function () {});
}
function d(a) {
(D = +a), o.setValue(z, D), (document.title = A.replace(/\#\{level\}/, D)), (GlobalLevel = D), C.level(D), !p.isWeixin && p.isMobile && b();
}
function e() {
n(document.body, "mousedown", function (a) {
var b;
if (a && a.changedTouches) for (b = a.changedTouches.length; b--; ) h.shot();
else h.shot();
"1" != a.target.getAttribute("data-capture") && q(a);
}),
n(w, "mousedown", function () {
w.style.display = "none";
}),
n(v, "mousedown", function () {
E ||
((E = !0),
(t.style.display = ""),
d(1),
setTimeout(function () {
(t.style.display = "none"), (E = !1);
}, 1e3));
}),
h.on("passed", function () {
i.switchStage(0, function () {
(h.enabled = !1), d(D + 1), (r.style.display = "none"), C.show();
});
}),
h.on("failed", function () {
i.switchStage(0, function () {
(h.enabled = !1), (r.style.display = "none"), C.level(D), C.show();
});
}),
C.on("start", function () {
(r.style.display = ""),
C.hide(),
i.switchStage(1, function () {
h.run(D);
});
});
}
function f() {
window.clearTimeout(F), h.update(), h.render(), i.update(), i.render(), (F = window.setTimeout(f, 1e3 / y));
}
function g() {
a(), (h = k(document.body, r, x, j)), e(), c(), C.level(D), C.show(), f();
}
var h,
i,
j,
k = $AJB.general.Scene(),
l = $AJB.general.Switcher(),
m = $AJB.general.BeginStage(),
n = $AJB.lib.addEvent(),
o = $AJB.lib.Storage(),
p = $AJB.lib.util(),
q = $AJB.lib.stopEvent(),
r = document.getElementById("stage"),
s = document.getElementById("begin"),
t = document.getElementById("tip"),
u = document.getElementById("btnFW"),
v = document.getElementById("btnReset"),
w = document.getElementById("wxArrow"),
x = r.getContext("2d"),
y = 60,
z = "core-ball-level",
A = "",
B = "",
C = m(s),
D = +o.getValue(z) || 1,
E = !1,
F = 0,
G = { start: g, shareTitle: A, shareLevel: D };
return G;
}),
function share() {
console.log("share");
};
($AJB.page.index = function () {
"use strict";
var a = $AJB.general.Game();
a.start();
}),
$AJB.page.index();
GlobalLevel = $AJB.general.Game().shareLevel;
+3
View File
@@ -0,0 +1,3 @@
requirejs.config({
baseUrl : "http://dev.me/h5/core-ball/js"
});
+67
View File
@@ -0,0 +1,67 @@
/**
* @fileoverview Ball
* @author Random | http://weibo.com/random
* @date 2015-02-05
*/
define(function(require, exports, module) {
"use strict";
var util = require("lib/util");
function Ball(stage, rad, num, fontSize, scale){
var x = 0;
var y = 0;
var me;
scale = scale || 1;
rad = (rad || 12) * scale;
fontSize = (fontSize || 15) * scale;
function renderNumber(n){
var w = util.getTextWidth(stage, 0, 0, num, fontSize);
util.drawText(stage, x - w / 2, y + fontSize / 2, num, fontSize, "black");
}
me = {
pos : function(bx, by){
typeof bx !== "undefined" && (x = bx);
typeof by !== "undefined" && (y = by);
return {
x : x,
y : y
};
},
//n :num,
scale : function(sc){
typeof sc !== "undefined" && (scale = sc);
return scale;
},
rad : function(r){
typeof r !== "undefined" && (rad = r);
return rad;
},
render : function(n){
util.drawCircle(stage, x, y, rad, "#ffffff");
if(typeof num !== "undefined"){
renderNumber(num);
}else if(typeof n !== "undefined"){
renderNumber(n);
}
},
destroy : function(){
me = null;
}
};
return me;
}
module.exports = Ball;
});
+139
View File
@@ -0,0 +1,139 @@
/**
* @fileoverview BallQueue
* @author Random | http://weibo.com/random
* @date 2015-02-05
*/
define(function(require, exports, module) {
"use strict";
var CustEvent = require("lib/CustEvent");
var Ball = require("general/Ball");
var Tween = require("general/Tween");
var EVENT_POPUP = "popup";
function BallQueue(n, x, y, stage, scale){
var me;
var ballList = [];
var popList = [];
var custEvent = CustEvent();
scale = scale || 1;
function init(){
var numList = numToArr(n);
var l = numList.length;
var i;
var ball;
for(i=0; i<l; i++){
ball = Ball(stage, null, numList[i], null, scale);
ball.pos(x, y + ball.rad() * 3 * i );
ballList.push(ball);
}
}
function numToArr(n){
var i = n;
var ret = [];
while(i--){
ret.push(i + 1);
}
return ret;
}
me = {
ballList : ballList,
add : function(ball){
},
remove : function(idx){
var ret = ballList[idx];
ballList.splice(idx, 1);
return ret;
},
clear : function(){
popList = [];
ballList = [];
},
popup : function(){
var popBall = ballList.shift();
popBall.st = +(new Date);
popBall.sv = popBall.pos().y;
popList.push(popBall);
},
update : function(){
var ev;
var i = popList.length;
var r;
var j = ballList.length;
var py;
if(i){
r = popList[0].rad();
ev = y - 3 * r;
while(i--){
popList[i].pos(x, Tween.simple(popList[i].sv, ev, popList[i].st, 50));
py = popList[popList.length - 1].pos().y;
if(popList[i].pos().y === ev){
custEvent.fire(EVENT_POPUP, popList[i]);
popList.splice(i, 1);
}
}
while(j--){
ballList[j].pos(x, py + 3 * r * (j + 1));
}
}
},
render : function(){
var i = ballList.length;
var j = popList.length;
while(i--){
ballList[i].render();
}
while(j--){
popList[j].render();
}
},
on : function(type, handle){
custEvent.add(type, handle);
},
off : function(type, handle){
custEvent.remove(type, handle);
},
destroy : function(){
var i = ballList.length;
while(i--){
ballList[i].destroy();
}
custEvent.destroy();
}
};
init();
return me;
}
module.exports = BallQueue;
});
+64
View File
@@ -0,0 +1,64 @@
/**
* @fileoverview BeginStage
* @author Random | http://weibo.com/random
* @date 2015-03-05
*/
define(function(require, exports, module) {
"use strict";
var addEvent = require("lib/addEvent");
var CustEvent = require("lib/CustEvent");
var util = require("lib/util");
var custEvent = CustEvent();
var level = 0;
var EVENT_START = "start";
function BeginStage(node){
var btnStart = node.getElementsByClassName("button")[0];
var txtLevel = node.getElementsByClassName("text")[0];
var txtAr = document.getElementById("txtAr");
function init(){
addEvent(btnStart, "click", function(){
custEvent.fire(EVENT_START, level);
});
if(util.isAndroid){
txtAr.innerHTML = "GO";
}else{
txtAr.innerHTML ="▶";
}
}
var me = {
show : function(){
node.style.display = "";
},
hide : function(){
node.style.display = "none";
},
level : function(lv){
level = lv;
txtLevel.innerHTML = "level " + lv;
},
on : function(type, handle){
custEvent.add(type, handle);
},
off : function(type, handle){
custEvent.remove(type, handle);
}
};
init();
return me;
}
module.exports = BeginStage;
});
+30
View File
@@ -0,0 +1,30 @@
/**
* @fileoverview Collide
* @author Random | http://weibo.com/random
* @date 2015-02-05
*/
define(function(require, exports, module) {
"use strict";
var util = require("lib/util");
var Collide = {
check : function(core, ball, scale){
var childs = core.childs();
var i = childs.length;
var d = Math.ceil(2 * ball.rad());
scale = scale || 1;
while(i--){
if(ball !== childs[i].ball && util.getPointDistance(ball.pos(), childs[i].ball.pos()) <= d + Math.ceil(2 * scale)){
return true;
}
}
return false;
}
};
module.exports = Collide;
});
+101
View File
@@ -0,0 +1,101 @@
/**
* @fileoverview Core
* @author Random | http://weibo.com/random
* @date 2015-02-05
*/
define(function(require, exports, module) {
"use strict";
var util = require("lib/util");
var Ball = require("general/Ball");
function Core(canvas, stage, num, fontSize, scale){
var angle = 0;
var color = "#ffffff";
var childs = [];
var r = 50;
var x = canvas.width / 2;
var y = 4 * r * scale;
var ball;
var me;
scale = scale || 1;
ball = Ball(stage, r, num, fontSize, scale);
ball.pos(x, y);
function updateChilds(){
var i = childs.length;
var cx;
var cy;
var dx;
var dy;
while(i--){
cx = Math.cos((childs[i].angle + me.angle()) * Math.PI / 180) * 3 * r * scale + x;
cy = Math.sin((childs[i].angle + me.angle()) * Math.PI / 180) * 3 * r * scale + y;
dx = cx / Math.abs(cx);
dy = cy / Math.abs(cy);
childs[i].ball.pos(cx, cy);
}
}
me = {
pos : ball.pos,
scale : ball.scale,
rad : ball.rad,
angle : function(ag){
typeof ag !== "undefined" && (angle = ag);
return angle;
},
addChild : function(angle, ball){
childs.push({
angle :angle,
ball : ball
});
},
clear : function(){
childs = [];
},
childs : function(){
return childs;
},
update : function(){
updateChilds();
},
render : function(){
var l = childs.length;
var i;
var w = canvas.width;
var h = canvas.height;
stage.clearRect(0, 0, w, h);
for(i=0; i<l; i++){
util.drawLine(stage, x, y, childs[i].ball.pos().x, childs[i].ball.pos().y, "#ffffff", 1.5 * scale);
childs[i].ball.render();
}
ball.render();
},
destroy : function(){
me.clear();
ball = null;
me = null;
}
};
return me;
}
module.exports = Core;
});
+172
View File
@@ -0,0 +1,172 @@
/**
* @fileoverview Game
* @author Random | http://weibo.com/random
* @date 2015-03-04
*/
define(function(require, exports, module) {
"use strict";
var Scene = require("general/Scene");
var Switcher = require("general/Switcher");
var BeginStage = require("general/BeginStage");
var addEvent = require("lib/addEvent");
var Storage = require("lib/Storage");
var util = require("lib/util");
var stopEvent = require("lib/stopEvent");
//var LevelCode = require("general/LevelCode");
var canvas = document.getElementById("stage");
var bsNode = document.getElementById("begin");
var tip = document.getElementById("tip");
var btnFW = document.getElementById("btnFW");
var btnReset = document.getElementById("btnReset");
var wxArrow = document.getElementById("wxArrow");
var stage = canvas.getContext("2d");
var FPS = 60;
var BASE_HEIGHT = 560;
var STORAGE_KEY = "core-ball-level";
var WX_SHARE_TEXT = "Core Ball(酷啵)-练手活的HTML5游戏,我已玩到第#{level}关了,你也来试试吧!";
var SHARE_HREF = "sinaweibo://share?content=Core Ball(酷啵) - 练手活的HTML5小游戏,我已玩到第#{level}关了,你也来试试吧! http://coreball.sinaapp.com";
var scene;
var beginStage = BeginStage(bsNode);
var switcher;
var level = +Storage.getValue(STORAGE_KEY) || 1;
var scale;
var isResetting = false
var tid = 0;
function adaptScreen(){
var width = document.body.scrollWidth || document.documentElement.scrollWidth;
var height = document.body.scrollHeight || document.documentElement.scrollHeight;
canvas.width = width;
canvas.height = height;
switcher = Switcher(stage, width, height);
bsNode.style.backgroundColor = switcher.color;
bsNode.style.width = width + "px";
bsNode.style.height = height + "px";
scale = height / 560;
}
function updateSharedHref(){
btnFW.href = SHARE_HREF.replace(/#\{level\}/, level);
}
function initForward(){
if(util.isWeixin){
addEvent(btnFW, "mousedown", function(){
wxArrow.style.display = "";
});
}else if(util.isMobile){
updateSharedHref();
}else{
//http://service.weibo.com/share/share.php?url=http://ra.ndom.me/core-ball/index.html&type=button&language=zh_cn&appkey=2hwszt&searchPic=true&style=number
}
}
function updateLevel(lv){
level = +lv;
Storage.setValue(STORAGE_KEY, level);
document.title = WX_SHARE_TEXT.replace(/\#\{level\}/, level);
beginStage.level(level);
!util.isWeixin && util.isMobile && updateSharedHref();
}
function initEvent(){
addEvent(document.body, "mousedown", function(evt){
var i;
if(evt && evt.changedTouches){
i = evt.changedTouches.length;
while(i--){
scene.shot();
}
}else{
scene.shot();
}
evt.target.getAttribute("data-capture")!="1" && stopEvent(evt);
});
addEvent(wxArrow, "mousedown", function(){
wxArrow.style.display = "none";
});
addEvent(btnReset, "mousedown", function(){
if(!isResetting){
isResetting = true;
tip.style.display = "";
updateLevel(1);
setTimeout(function(){
tip.style.display = "none";
isResetting = false;
}, 1000);
}
});
scene.on("passed", function(){
switcher.switchStage(0, function(){
scene.enabled = false;
updateLevel(level + 1);
canvas.style.display = "none";
beginStage.show();
});
});
scene.on("failed", function(){
switcher.switchStage(0, function(){
scene.enabled = false;
canvas.style.display = "none";
beginStage.level(level);
beginStage.show();
});
});
beginStage.on("start", function(){
canvas.style.display = "";
beginStage.hide();
switcher.switchStage(1, function(){
scene.run(level);
});
});
}
function timerHandle(){
window.clearTimeout(tid);
scene.update();
scene.render();
switcher.update();
switcher.render();
tid = window.setTimeout(timerHandle, 1000 / FPS);
}
function init(){
adaptScreen();
scene = Scene(document.body, canvas, stage, scale);
initEvent();
initForward();
beginStage.level(level);
beginStage.show();
timerHandle();
}
var Game = {
start : init
};
module.exports = Game;
});
+35
View File
@@ -0,0 +1,35 @@
/**
* @fileoverview LevelCode
* @author Random | http://weibo.com/random
* @date 2015-03-13
*/
define(function(require, exports, module) {
"use strict";
var md5 = require("lib/md5");
var SALT = "Handsome";
var map = {};
var l = 60;
var i;
for(i=1; i<=l; i++){
map[md5(i + SALT)] = i;
}
module.exports = {
encode : function(n){
var k;
for(k in map){
if(map[k] == n){
return k;
}
}
},
decode : function(code){
return map[code];
}
};
});
+292
View File
@@ -0,0 +1,292 @@
/**
* @fileoverview Levels
* @author Random | http://weibo.com/random
* @date 2015-03-06
*/
define(function(require, exports, module) {
"use strict";
var addEvent = require("lib/addEvent");
var Levels = {};
var k;
function typeAB(v, d){
return function(){
var angle = 0;
return function(){
angle += v * d % 360;
return angle;
};
};
}
function typeC(v, td){
return function(){
var angle = 0;
var d = 1;
var t = +(new Date);
return function(){
var t2 = +(new Date);
if(t2 - t > td){
d = -d;
t = t2;
}
angle += d * v % 360;
return angle;
};
};
}
function typeD(v, sum, td, d){
return function(){
var angle = 0;
var t = +(new Date);
return function(){
var t2 = +(new Date);
if(t2 - t > td){
v = sum - v;
t = t2;
}
angle += v * d % 360;
return angle;
};
};
}
function typeE(v1, v2){
var d = 1;
var map = {
"-1" : v2,
"1" : v1
};
var v = v2 ? map[d] : v1;
addEvent(document.body, "mousedown", function(){
d = -d;
v = v2 ? map[d] : v1;
});
return function(){
var angle = 0;
return function(){
angle += v * d % 360;
return angle;
};
};
}
function typeDE(v, sum, td, d){
addEvent(document.body, "mousedown", function(){
d = -d;
});
return function(){
var angle = 0;
var t = +(new Date);
return function(){
var t2 = +(new Date);
if(t2 - t > td){
v = sum - v;
t = t2;
}
angle += v * d % 360;
return angle;
};
};
}
function typeF(v1, v2, td1, td2){
return function(){
var angle = 0;
var t = +(new Date);
var i = 0;
var arr = [[v1, td1], [v2, td2]];
var d = 1;
return function(){
var t2 = +(new Date);
var v = arr[i][0];
if(t2 - t > arr[i][1]){
v = arr[i][0];
i = (i + 1) % 2;
t = +(new Date);
d = -d;
}
angle += d * v;
return angle;
}
}
}
var roundTypes = {
"A1" : typeAB(1.5, 1),
"A2" : typeAB(1.5, -1),
"B1" : typeAB(2.5, 1),
"B2" : typeAB(2.5, -1),
"C1" : typeC(2.2, 3000),
"C2" : typeC(3.5, 2000),
"D1" : typeD(2, 2.3, 1200, 1),
"D2" : typeD(2, 2.3, 1200, -1),
"D3" : typeD(4, 4.5, 700, 1),
"D4" : typeD(4, 4.5, 700, -1),
"D5" : typeD(4, 4.5, 1700, 1),
"D6" : typeD(4, 4.5, 1700, -1),
"E1" : typeE(2),
"E2" : typeDE(2, 2.3, 1000, 1),
"E3" : typeDE(2, 2.5, 1000, 1),
"E4" : typeE(3, 2),
"E5" : typeE(1.5, 3.2),
"F1" : typeF(2, 0.3, 200, 300),
"F2" : typeF(3.5, 1, 250, 1500),
"F3" : typeF(0.5, 1.8, 350, 1500),
"F4" : typeF(1.8, 0.5, 1000, 150),
"F5" : typeF(0.5, 2.2, 350, 1500)
};
var childsTypes = {
"0" : [],
"2" : [0, 180],
"3" : [0, 120, 240],
"4" : [0, 90, 180, 270],
"5" : [0, 72, 144, 216, 288],
"6" : [0, 60, 120, 180, 240, 300],
"7" : [0, 52, 103, 155, 206, 258, 309],
"8" : [0, 45, 90, 135, 180, 225, 270, 315],
"9" : [0, 40, 80, 120, 160, 200, 240, 280, 320],
"10" : [0, 36, 72, 108, 144, 180, 216, 252, 288, 324],
"11" : [0, 33, 66, 99, 131, 164, 197, 230, 262, 295, 328],
"12" : [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330],
"13" : [0, 28, 56, 84, 111, 139, 167, 194, 222, 250, 277, 305, 333],
"14" : [0, 26, 52, 78, 103, 129, 155, 180, 206, 232, 258, 283, 309, 335],
"15" : [0, 24, 48, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336],
"16" : [0, 23, 45, 68, 90, 113, 135, 158, 180, 203, 225, 248, 270, 293, 315, 338]
};
var data = {
"1" : ["4", 8, "A1"],
"2" : ["6", 10, "A1"],
"3" : ["2", 20, "A1"],
"4" : ["8", 12, "A2"],
"5" : ["12", 8, "A1"],
"6" : ["10", 10, "A2"],
"7" : ["11", 12, "A1"],
"8" : ["14", 6, "A2"],
"9" : ["0", 26, "A2"],
"10" : ["14", 10, "A1"],
"11" : ["10", 8, "B1"],
"12" : ["6", 12, "B2"],
"13" : ["12", 4, "B1"],
"14" : ["8", 14, "B2"],
"15" : ["8", 6, "B1"],
"16" : ["5", 10, "B2"],
"17" : ["6", 12, "B1"],
"18" : ["8", 14, "B2"],
"19" : ["0", 23, "B1"],
"20" : ["10", 13, "B2"],
"21" : ["4", 12, "C1"],
"22" : ["6", 10, "C1"],
"23" : ["8", 12, "C1"],
"24" : ["7", 14, "C1"],
"25" : ["2", 18, "C1"],
"26" : ["4", 18, "C1"],
"27" : ["0", 24, "C1"],
"28" : ["4", 10, "C2"],
"29" : ["6", 13, "C2"],
"30" : ["4", 20, "C1"],
"31" : ["6", 8, "D1"],
"32" : ["2", 12, "D2"],
"33" : ["3", 14, "D2"],
"34" : ["3", 18, "D1"],
"35" : ["8", 12, "D1"],
"36" : ["7", 15, "D2"],
"37" : ["16", 8, "D2"],
"38" : ["0", 23, "D1"],
"39" : ["12", 12, "D1"],
"40" : ["12", 15, "D2"],
"41" : ["5", 10, "E1"],
"42" : ["6", 12, "E1"],
"43" : ["3", 15, "E1"],
"44" : ["3", 19, "E1"],
"45" : ["0", 24, "E1"],
"46" : ["2", 15, "E2"],
"47" : ["4", 16, "E2"],
"48" : ["12", 8, "E2"],
"49" : ["3", 20, "E2"],
"50" : ["16", 14, "E3"],
"51" : ["6", 10, "D3"],
"52" : ["2", 18, "D4"],
"53" : ["8", 14, "D3"],
"54" : ["0", 24, "D4"],
"55" : ["4", 21, "D3"],
"56" : ["16", 16, "A1"],
"57" : ["4", 22, "C1"],
"58" : ["4", 26, "D1"],
"59" : ["4", 25, "E2"],
"60" : ["12", 14, "E2"],
"61" : ["10", 11, "F1"],
"62" : ["4", 21, "F1"],
"63" : ["8", 16, "F1"],
"64" : ["2", 24, "F1"],
"65" : ["16", 8, "F1"],
"66" : ["12", 14, "F2"],
"67" : ["8", 19, "F2"],
"68" : ["3", 21, "F2"],
"69" : ["0", 32, "F2"],
"70" : ["8", 20, "F1"],
"71" : ["12", 12, "F5"],
"72" : ["8", 18, "F3"],
"73" : ["15", 15, "F5"],
"74" : ["3", 18, "F3"],
"75" : ["3", 22, "F5"],
"76" : ["5", 22, "F4"],
"77" : ["6", 21, "F4"],
"78" : ["9", 18, "F4"],
"79" : ["8", 21, "F4"],
"80" : ["6", 24, "F4"],
"81" : ["5", 12, "E4"],
"82" : ["7", 14, "E4"],
"83" : ["2", 21, "E4"],
"84" : ["0", 24, "E4"],
"85" : ["7", 16, "E4"],
"86" : ["12", 13, "E5"],
"87" : ["4", 15, "E5"],
"88" : ["5", 19, "E5"],
"89" : ["8", 18, "E4"],
"90" : ["16", 16, "E4"]
};
function bindLevles(lv, ct, count, rt){
Levels[lv] = {
childs : childsTypes[ct],
queueCount : count,
round : roundTypes[rt]
};
}
for(k in data){
bindLevles(k, data[k][0], data[k][1], data[k][2]);
}
module.exports = Levels;
});
+196
View File
@@ -0,0 +1,196 @@
/**
* @fileoverview Scene
* @author Random | http://weibo.com/random
* @date 2015-02-11
*/
define(function(require, exports, module) {
"use strict";
var CustEvent = require("lib/CustEvent");
var Core = require("general/Core");
var Ball = require("general/Ball");
var BallQueue = require("general/BallQueue");
var Collide = require("general/Collide");
var Levels = require("general/Levels");
var util = require("lib/util");
var EVENT_PASSED = "passed";
var EVENT_FAILED = "failed";
var custEvent = CustEvent();
function Scene(container, canvas, stage, scale){
var me;
var state = "run";
var level = 1;
var ts;
var core;
var ballQueue;
var roundHandle;
var failedBall;
function initStage(conf){
var childs = conf.childs;
var i = childs.length;
roundHandle = conf.round();
core && core.destroy();
core = Core(canvas, stage, level, 50, scale);
while(i--){
core.addChild(childs[i], Ball(stage, null, "", null, scale));
}
ballQueue && ballQueue.destroy();
ballQueue = BallQueue(conf.queueCount, canvas.width / 2, core.pos().y + core.rad() * 4, stage, scale);
ballQueue.on("popup", function(ball){
core.addChild(90 - core.angle(), ball);
if(Collide.check(core, ball, scale)){
failedBall = ball;
fail();
}else{
!ballQueue.ballList.length && pass();
}
});
}
function stageUpdate(){
if(roundHandle){
core.angle(roundHandle());
core.update();
ballQueue.update();
}
}
function updatePass(){
var childs = core.childs();
var i = childs.length;
var angle;
var v = 25;
var dx;
var dy;
var pos;
container.style.backgroundColor = me.bgColor;
while(i--){
angle = childs[i].angle + core.angle();
dx = Math.cos(angle * Math.PI / 180) * v;
dy = Math.sin(angle * Math.PI / 180) * v;
pos = childs[i].ball.pos();
childs[i].ball.pos(pos.x + dx, pos.y + dy);
}
}
function updateFail(t){
var rs = [25, 15, 20, 15];
var l = rs.length;
var tm = 200;
var m = tm / l;
var i;
core.update();
for(i=1; i<=l; i++){
t > m * i && failedBall.rad(rs[i-1] * scale);
}
}
function pass(){
if(state !== "pass"){
container.style.backgroundColor = "#1CB01A";
state = "pass";
ts = +(new Date);
}
}
function fail(){
if(stage !== "fail"){
container.style.backgroundColor = "#B8111C";
state = "fail";
ts = +(new Date);
}
}
function toBeContinued(){
var text = "to be continued...";
var w = util.getTextWidth(stage, 0, 0, text, 30 * scale);
util.drawText(stage, (canvas.width - w) / 2, 200 * scale, text, 30 * scale, "yellow");
}
me = {
enabled : false,
run : function(lv){
var conf = Levels[lv];
level = lv;
if(conf){
me.enabled = true;
initStage(conf);
container.style.backgroundColor = "#000";
state = "run";
}else{
toBeContinued();
}
},
shot : function(){
ballQueue && ballQueue.ballList.length && ballQueue.popup();
},
update : function(){
var t;
if(!me.enabled){
return;
}
if(state === "run"){
stageUpdate();
}else if(state === "pass"){
updatePass();
if(+(new Date) - ts > 1000){
state = "";
custEvent.fire(EVENT_PASSED);
}
}else if(state === "fail"){
t = +(new Date) - ts;
updateFail(t);
if(t > 1000){
state = "";
custEvent.fire(EVENT_FAILED);
}
}
},
render : function(){
if(me.enabled){
core.render();
ballQueue.render();
}
},
on : function(type, handle){
custEvent.add(type, handle);
},
off : function(type, handle){
custEvent.remove(type, handle);
}
};
return me;
}
module.exports = Scene;
});
+84
View File
@@ -0,0 +1,84 @@
/**
* @fileoverview Switcher
* @author Random | http://weibo.com/random
* @date 2015-03-04
*/
define(function(require, exports, module) {
"use strict";
function Switcher(stage, width, height){
var color;
var callBack = null;
var type;
var isEnd = false;
var me = {
point : [0, 0],
enabled : false,
color : "#c8c8c8",
update : function(){
var p = me.point;
var v = 30;
if(me.enabled){
if(type === 0){
color = me.color;
if(p[0] < width / 2){
p[0] = Math.min(p[0] + v, width / 2);
me.point = p;
}else{
me.point = p;
isEnd = true;
}
}else if(type === 1){
color = "#000";
if(p[0] > width / 2){
p[0] = Math.max(p[0] - v, width / 2);
me.point = p;
}else{
me.point = p;
isEnd = true;
}
}
}
},
render : function(){
var p = me.point;
if(me.enabled){
stage.fillStyle = color;
stage.fillRect(p[0] - width / 2, p[1] - height / 2, width, height);
if(isEnd){
me.enabled = false
callBack && callBack();
}
}
},
switchStage : function(tp, cb){
if(tp === 0){
me.point = [-width / 2, height /2];
}else if(tp === 1){
stage.fillStyle = me.color;
stage.fillRect(0, 0, width, height);
me.point = [width + width / 2, height /2];
}
me.enabled = true;
isEnd = false;
type = tp;
callBack = cb;
}
};
return me;
}
module.exports = Switcher;
});
+28
View File
@@ -0,0 +1,28 @@
/**
* @fileoverview Tween
* @author Random | http://weibo.com/random
* @date 2015-03-09
*/
define(function(require, exports, module) {
"use strict";
var Tween = {
simple : function(sv, ev, st, d){
var v = (ev - sv) / d;
var t = +(new Date);
if(t - st < d){
Tween.isEnd = false;
return sv + (t - st) * v;
}else {
Tween.isEnd = true;
return ev;
}
},
isEnd : true
};
module.exports = Tween;
});
+77
View File
@@ -0,0 +1,77 @@
/**
* @fileoverview 自定义事件
* @author Random | http://weibo.com/random
* @date 2013-05-21
*/
define(function(require, exports, module){
module.exports = function(target){
var events={};
!target && (target={});
function getType(obj){
return Object.prototype.toString.call(obj).slice(8,-1).toLowerCase();
}
return {
add:function(type,handle){
if (getType(handle) !== "function") {
return;
}
var evts=events;
type=type.toLowerCase();
!evts[type] && (evts[type]=[]);
evts[type].push(handle);
},
remove:function(type,handle){
var evts=events[type];
var i;
type=type.toLowerCase();
if (getType(handle) !== "function" || !evts || !evts.length) {
return;
}
for(i=evts.length-1;i>=0;i--){
evts[i]===handle && evts.splice(i,1);
}
},
fire:function(type){
var evts;
var args;
var i;
var l;
type=type.toLowerCase();
evts=events[type];
if (!evts || !evts.length) {
return;
}
args=Array.prototype.slice.call(arguments,1);
l=evts.length;
for(i=0;i<l;i++){
evts[i].apply(target,args);
}
},
destroy : function(){
var i;
var l=events.length-1;
for(i=l;i>=0;i--){
evts.splice(i,1);
}
}
};
};
});
+27
View File
@@ -0,0 +1,27 @@
/**
* @fileoverview Storage
* @author Random | http://weibo.com/random
* @date 2015-03-11
*/
define(function(require, exports, module) {
"use strict";
var Storage = {
setValue : function(key, value){
try{
window.localStorage && (window.localStorage[key] = value);
}catch(ex){}
},
getValue : function(key){
if(window.localStorage){
try{
return window.localStorage[key];
}catch(ex){}
}
}
};
module.exports = Storage;
});
+26
View File
@@ -0,0 +1,26 @@
/**
* @fileoverview addEvent
* @author Random | http://weibo.com/random
* @date 2015-03-05
*/
define(function(require, exports, module) {
var util = require("lib/util");
var map = {
"click" : "touchstart",
"mousedown" : "touchstart",
"mouseup" : "touchend"
};
module.exports = function(dom, type, handle, isCapture){
if(dom.addEventListener){
dom.addEventListener(util.isMobile ? map[type] || type : type, handle, isCapture);
}else if(dom.attachEvent){
dom.attachEvent("on" + type, handle);
}else{
dom["on" + type] = handle;
}
};
});
+274
View File
@@ -0,0 +1,274 @@
/*
* JavaScript MD5 1.0.1
* https://github.com/blueimp/JavaScript-MD5
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*
* Based on
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*jslint bitwise: true */
/*global unescape, define */
(function ($) {
'use strict';
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y) {
var lsw = (x & 0xFFFF) + (y & 0xFFFF),
msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt) {
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t) {
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
}
function md5_ff(a, b, c, d, x, s, t) {
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t) {
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t) {
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t) {
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length.
*/
function binl_md5(x, len) {
/* append padding */
x[len >> 5] |= 0x80 << (len % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var i, olda, oldb, oldc, oldd,
a = 1732584193,
b = -271733879,
c = -1732584194,
d = 271733878;
for (i = 0; i < x.length; i += 16) {
olda = a;
oldb = b;
oldc = c;
oldd = d;
a = md5_ff(a, b, c, d, x[i], 7, -680876936);
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897);
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416);
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063);
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682);
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510);
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632);
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i], 20, -373897302);
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691);
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083);
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438);
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690);
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467);
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784);
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558);
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060);
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174);
d = md5_hh(d, a, b, c, x[i], 11, -358537222);
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487);
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i], 6, -198630844);
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571);
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359);
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070);
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return [a, b, c, d];
}
/*
* Convert an array of little-endian words to a string
*/
function binl2rstr(input) {
var i,
output = '';
for (i = 0; i < input.length * 32; i += 8) {
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF);
}
return output;
}
/*
* Convert a raw string to an array of little-endian words
* Characters >255 have their high-byte silently ignored.
*/
function rstr2binl(input) {
var i,
output = [];
output[(input.length >> 2) - 1] = undefined;
for (i = 0; i < output.length; i += 1) {
output[i] = 0;
}
for (i = 0; i < input.length * 8; i += 8) {
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32);
}
return output;
}
/*
* Calculate the MD5 of a raw string
*/
function rstr_md5(s) {
return binl2rstr(binl_md5(rstr2binl(s), s.length * 8));
}
/*
* Calculate the HMAC-MD5, of a key and some data (raw strings)
*/
function rstr_hmac_md5(key, data) {
var i,
bkey = rstr2binl(key),
ipad = [],
opad = [],
hash;
ipad[15] = opad[15] = undefined;
if (bkey.length > 16) {
bkey = binl_md5(bkey, key.length * 8);
}
for (i = 0; i < 16; i += 1) {
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8);
return binl2rstr(binl_md5(opad.concat(hash), 512 + 128));
}
/*
* Convert a raw string to a hex string
*/
function rstr2hex(input) {
var hex_tab = '0123456789abcdef',
output = '',
x,
i;
for (i = 0; i < input.length; i += 1) {
x = input.charCodeAt(i);
output += hex_tab.charAt((x >>> 4) & 0x0F) +
hex_tab.charAt(x & 0x0F);
}
return output;
}
/*
* Encode a string as utf-8
*/
function str2rstr_utf8(input) {
return unescape(encodeURIComponent(input));
}
/*
* Take string arguments and return either raw or hex encoded strings
*/
function raw_md5(s) {
return rstr_md5(str2rstr_utf8(s));
}
function hex_md5(s) {
return rstr2hex(raw_md5(s));
}
function raw_hmac_md5(k, d) {
return rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d));
}
function hex_hmac_md5(k, d) {
return rstr2hex(raw_hmac_md5(k, d));
}
function md5(string, key, raw) {
if (!key) {
if (!raw) {
return hex_md5(string);
}
return raw_md5(string);
}
if (!raw) {
return hex_hmac_md5(key, string);
}
return raw_hmac_md5(key, string);
}
if (typeof define === 'function' && define.amd) {
define(function () {
return md5;
});
} else {
$.md5 = md5;
}
}(this));
+36
View File
@@ -0,0 +1,36 @@
/*
RequireJS 2.1.10 Copyright (c) 2010-2014, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
*/
var requirejs,require,define;
(function(ca){function G(b){return"[object Function]"===N.call(b)}function H(b){return"[object Array]"===N.call(b)}function v(b,c){if(b){var d;for(d=0;d<b.length&&(!b[d]||!c(b[d],d,b));d+=1);}}function U(b,c){if(b){var d;for(d=b.length-1;-1<d&&(!b[d]||!c(b[d],d,b));d-=1);}}function s(b,c){return ga.call(b,c)}function j(b,c){return s(b,c)&&b[c]}function B(b,c){for(var d in b)if(s(b,d)&&c(b[d],d))break}function V(b,c,d,g){c&&B(c,function(c,h){if(d||!s(b,h))g&&"object"===typeof c&&c&&!H(c)&&!G(c)&&!(c instanceof
RegExp)?(b[h]||(b[h]={}),V(b[h],c,d,g)):b[h]=c});return b}function t(b,c){return function(){return c.apply(b,arguments)}}function da(b){throw b;}function ea(b){if(!b)return b;var c=ca;v(b.split("."),function(b){c=c[b]});return c}function C(b,c,d,g){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.requireModules=g;d&&(c.originalError=d);return c}function ha(b){function c(a,e,b){var f,n,c,d,g,h,i,I=e&&e.split("/");n=I;var m=l.map,k=m&&m["*"];if(a&&"."===a.charAt(0))if(e){n=
I.slice(0,I.length-1);a=a.split("/");e=a.length-1;l.nodeIdCompat&&R.test(a[e])&&(a[e]=a[e].replace(R,""));n=a=n.concat(a);d=n.length;for(e=0;e<d;e++)if(c=n[e],"."===c)n.splice(e,1),e-=1;else if(".."===c)if(1===e&&(".."===n[2]||".."===n[0]))break;else 0<e&&(n.splice(e-1,2),e-=2);a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if(b&&m&&(I||k)){n=a.split("/");e=n.length;a:for(;0<e;e-=1){d=n.slice(0,e).join("/");if(I)for(c=I.length;0<c;c-=1)if(b=j(m,I.slice(0,c).join("/")))if(b=j(b,d)){f=b;
g=e;break a}!h&&(k&&j(k,d))&&(h=j(k,d),i=e)}!f&&h&&(f=h,g=i);f&&(n.splice(0,g,f),a=n.join("/"))}return(f=j(l.pkgs,a))?f:a}function d(a){z&&v(document.getElementsByTagName("script"),function(e){if(e.getAttribute("data-requiremodule")===a&&e.getAttribute("data-requirecontext")===i.contextName)return e.parentNode.removeChild(e),!0})}function g(a){var e=j(l.paths,a);if(e&&H(e)&&1<e.length)return e.shift(),i.require.undef(a),i.require([a]),!0}function u(a){var e,b=a?a.indexOf("!"):-1;-1<b&&(e=a.substring(0,
b),a=a.substring(b+1,a.length));return[e,a]}function m(a,e,b,f){var n,d,g=null,h=e?e.name:null,l=a,m=!0,k="";a||(m=!1,a="_@r"+(N+=1));a=u(a);g=a[0];a=a[1];g&&(g=c(g,h,f),d=j(p,g));a&&(g?k=d&&d.normalize?d.normalize(a,function(a){return c(a,h,f)}):c(a,h,f):(k=c(a,h,f),a=u(k),g=a[0],k=a[1],b=!0,n=i.nameToUrl(k)));b=g&&!d&&!b?"_unnormalized"+(Q+=1):"";return{prefix:g,name:k,parentMap:e,unnormalized:!!b,url:n,originalName:l,isDefine:m,id:(g?g+"!"+k:k)+b}}function q(a){var e=a.id,b=j(k,e);b||(b=k[e]=new i.Module(a));
return b}function r(a,e,b){var f=a.id,n=j(k,f);if(s(p,f)&&(!n||n.defineEmitComplete))"defined"===e&&b(p[f]);else if(n=q(a),n.error&&"error"===e)b(n.error);else n.on(e,b)}function w(a,e){var b=a.requireModules,f=!1;if(e)e(a);else if(v(b,function(e){if(e=j(k,e))e.error=a,e.events.error&&(f=!0,e.emit("error",a))}),!f)h.onError(a)}function x(){S.length&&(ia.apply(A,[A.length,0].concat(S)),S=[])}function y(a){delete k[a];delete W[a]}function F(a,e,b){var f=a.map.id;a.error?a.emit("error",a.error):(e[f]=
!0,v(a.depMaps,function(f,c){var d=f.id,g=j(k,d);g&&(!a.depMatched[c]&&!b[d])&&(j(e,d)?(a.defineDep(c,p[d]),a.check()):F(g,e,b))}),b[f]=!0)}function D(){var a,e,b=(a=1E3*l.waitSeconds)&&i.startTime+a<(new Date).getTime(),f=[],c=[],h=!1,k=!0;if(!X){X=!0;B(W,function(a){var i=a.map,m=i.id;if(a.enabled&&(i.isDefine||c.push(a),!a.error))if(!a.inited&&b)g(m)?h=e=!0:(f.push(m),d(m));else if(!a.inited&&(a.fetched&&i.isDefine)&&(h=!0,!i.prefix))return k=!1});if(b&&f.length)return a=C("timeout","Load timeout for modules: "+
f,null,f),a.contextName=i.contextName,w(a);k&&v(c,function(a){F(a,{},{})});if((!b||e)&&h)if((z||fa)&&!Y)Y=setTimeout(function(){Y=0;D()},50);X=!1}}function E(a){s(p,a[0])||q(m(a[0],null,!0)).init(a[1],a[2])}function L(a){var a=a.currentTarget||a.srcElement,e=i.onScriptLoad;a.detachEvent&&!Z?a.detachEvent("onreadystatechange",e):a.removeEventListener("load",e,!1);e=i.onScriptError;(!a.detachEvent||Z)&&a.removeEventListener("error",e,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function M(){var a;
for(x();A.length;){a=A.shift();if(null===a[0])return w(C("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));E(a)}}var X,$,i,K,Y,l={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},k={},W={},aa={},A=[],p={},T={},ba={},N=1,Q=1;K={require:function(a){return a.require?a.require:a.require=i.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?a.exports:a.exports=p[a.map.id]={}},module:function(a){return a.module?a.module:
a.module={id:a.map.id,uri:a.map.url,config:function(){return j(l.config,a.map.id)||{}},exports:K.exports(a)}}};$=function(a){this.events=j(aa,a.id)||{};this.map=a;this.shim=j(l.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};$.prototype={init:function(a,e,b,f){f=f||{};if(!this.inited){this.factory=e;if(b)this.on("error",b);else this.events.error&&(b=t(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=b;this.inited=
!0;this.ignore=f.ignore;f.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,e){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=e)},fetch:function(){if(!this.fetched){this.fetched=!0;i.startTime=(new Date).getTime();var a=this.map;if(this.shim)i.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],t(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=
this.map.url;T[a]||(T[a]=!0,i.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,e,b=this.map.id;e=this.depExports;var f=this.exports,c=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(G(c)){if(this.events.error&&this.map.isDefine||h.onError!==da)try{f=i.execCb(b,c,e,f)}catch(d){a=d}else f=i.execCb(b,c,e,f);this.map.isDefine&&void 0===f&&((e=this.module)?f=e.exports:this.usingExports&&
(f=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:null,a.requireType=this.map.isDefine?"define":"require",w(this.error=a)}else f=c;this.exports=f;if(this.map.isDefine&&!this.ignore&&(p[b]=f,h.onResourceLoad))h.onResourceLoad(i,this.map,this.depMaps);y(b);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else this.fetch()}},callPlugin:function(){var a=
this.map,b=a.id,d=m(a.prefix);this.depMaps.push(d);r(d,"defined",t(this,function(f){var d,g;g=j(ba,this.map.id);var J=this.map.name,u=this.map.parentMap?this.map.parentMap.name:null,p=i.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(f.normalize&&(J=f.normalize(J,function(a){return c(a,u,!0)})||""),f=m(a.prefix+"!"+J,this.map.parentMap),r(f,"defined",t(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),g=j(k,f.id)){this.depMaps.push(f);
if(this.events.error)g.on("error",t(this,function(a){this.emit("error",a)}));g.enable()}}else g?(this.map.url=i.nameToUrl(g),this.load()):(d=t(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),d.error=t(this,function(a){this.inited=!0;this.error=a;a.requireModules=[b];B(k,function(a){0===a.map.id.indexOf(b+"_unnormalized")&&y(a.map.id)});w(a)}),d.fromText=t(this,function(f,c){var g=a.name,J=m(g),k=O;c&&(f=c);k&&(O=!1);q(J);s(l.config,b)&&(l.config[g]=l.config[b]);try{h.exec(f)}catch(j){return w(C("fromtexteval",
"fromText eval for "+b+" failed: "+j,j,[b]))}k&&(O=!0);this.depMaps.push(J);i.completeLoad(g);p([g],d)}),f.load(a.name,p,d,l))}));i.enable(d,this);this.pluginMaps[d.id]=d},enable:function(){W[this.map.id]=this;this.enabling=this.enabled=!0;v(this.depMaps,t(this,function(a,b){var c,f;if("string"===typeof a){a=m(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[b]=a;if(c=j(K,a.id)){this.depExports[b]=c(this);return}this.depCount+=1;r(a,"defined",t(this,function(a){this.defineDep(b,
a);this.check()}));this.errback&&r(a,"error",t(this,this.errback))}c=a.id;f=k[c];!s(K,c)&&(f&&!f.enabled)&&i.enable(a,this)}));B(this.pluginMaps,t(this,function(a){var b=j(k,a.id);b&&!b.enabled&&i.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,b){var c=this.events[a];c||(c=this.events[a]=[]);c.push(b)},emit:function(a,b){v(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};i={config:l,contextName:b,registry:k,defined:p,urlFetched:T,defQueue:A,Module:$,makeModuleMap:m,
nextTick:h.nextTick,onError:w,configure:function(a){a.baseUrl&&"/"!==a.baseUrl.charAt(a.baseUrl.length-1)&&(a.baseUrl+="/");var b=l.shim,c={paths:!0,bundles:!0,config:!0,map:!0};B(a,function(a,b){c[b]?(l[b]||(l[b]={}),V(l[b],a,!0,!0)):l[b]=a});a.bundles&&B(a.bundles,function(a,b){v(a,function(a){a!==b&&(ba[a]=b)})});a.shim&&(B(a.shim,function(a,c){H(a)&&(a={deps:a});if((a.exports||a.init)&&!a.exportsFn)a.exportsFn=i.makeShimExports(a);b[c]=a}),l.shim=b);a.packages&&v(a.packages,function(a){var b,
a="string"===typeof a?{name:a}:a;b=a.name;a.location&&(l.paths[b]=a.location);l.pkgs[b]=a.name+"/"+(a.main||"main").replace(ja,"").replace(R,"")});B(k,function(a,b){!a.inited&&!a.map.unnormalized&&(a.map=m(b))});if(a.deps||a.callback)i.require(a.deps||[],a.callback)},makeShimExports:function(a){return function(){var b;a.init&&(b=a.init.apply(ca,arguments));return b||a.exports&&ea(a.exports)}},makeRequire:function(a,e){function g(f,c,d){var j,l;e.enableBuildCallback&&(c&&G(c))&&(c.__requireJsBuild=
!0);if("string"===typeof f){if(G(c))return w(C("requireargs","Invalid require call"),d);if(a&&s(K,f))return K[f](k[a.id]);if(h.get)return h.get(i,f,a,g);j=m(f,a,!1,!0);j=j.id;return!s(p,j)?w(C("notloaded",'Module name "'+j+'" has not been loaded yet for context: '+b+(a?"":". Use require([])"))):p[j]}M();i.nextTick(function(){M();l=q(m(null,a));l.skipMap=e.skipMap;l.init(f,c,d,{enabled:!0});D()});return g}e=e||{};V(g,{isBrowser:z,toUrl:function(b){var e,d=b.lastIndexOf("."),g=b.split("/")[0];if(-1!==
d&&(!("."===g||".."===g)||1<d))e=b.substring(d,b.length),b=b.substring(0,d);return i.nameToUrl(c(b,a&&a.id,!0),e,!0)},defined:function(b){return s(p,m(b,a,!1,!0).id)},specified:function(b){b=m(b,a,!1,!0).id;return s(p,b)||s(k,b)}});a||(g.undef=function(b){x();var c=m(b,a,!0),e=j(k,b);d(b);delete p[b];delete T[c.url];delete aa[b];U(A,function(a,c){a[0]===b&&A.splice(c,1)});e&&(e.events.defined&&(aa[b]=e.events),y(b))});return g},enable:function(a){j(k,a.id)&&q(a).enable()},completeLoad:function(a){var b,
c,f=j(l.shim,a)||{},d=f.exports;for(x();A.length;){c=A.shift();if(null===c[0]){c[0]=a;if(b)break;b=!0}else c[0]===a&&(b=!0);E(c)}c=j(k,a);if(!b&&!s(p,a)&&c&&!c.inited){if(l.enforceDefine&&(!d||!ea(d)))return g(a)?void 0:w(C("nodefine","No define call for "+a,null,[a]));E([a,f.deps||[],f.exportsFn])}D()},nameToUrl:function(a,b,c){var f,d,g;(f=j(l.pkgs,a))&&(a=f);if(f=j(ba,a))return i.nameToUrl(f,b,c);if(h.jsExtRegExp.test(a))f=a+(b||"");else{f=l.paths;a=a.split("/");for(d=a.length;0<d;d-=1)if(g=a.slice(0,
d).join("/"),g=j(f,g)){H(g)&&(g=g[0]);a.splice(0,d,g);break}f=a.join("/");f+=b||(/^data\:|\?/.test(f)||c?"":".js");f=("/"===f.charAt(0)||f.match(/^[\w\+\.\-]+:/)?"":l.baseUrl)+f}return l.urlArgs?f+((-1===f.indexOf("?")?"?":"&")+l.urlArgs):f},load:function(a,b){h.load(i,a,b)},execCb:function(a,b,c,d){return b.apply(d,c)},onScriptLoad:function(a){if("load"===a.type||ka.test((a.currentTarget||a.srcElement).readyState))P=null,a=L(a),i.completeLoad(a.id)},onScriptError:function(a){var b=L(a);if(!g(b.id))return w(C("scripterror",
"Script error for: "+b.id,a,[b.id]))}};i.require=i.makeRequire();return i}var h,x,y,D,L,E,P,M,q,Q,la=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,ma=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,R=/\.js$/,ja=/^\.\//;x=Object.prototype;var N=x.toString,ga=x.hasOwnProperty,ia=Array.prototype.splice,z=!!("undefined"!==typeof window&&"undefined"!==typeof navigator&&window.document),fa=!z&&"undefined"!==typeof importScripts,ka=z&&"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,
Z="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),F={},r={},S=[],O=!1;if("undefined"===typeof define){if("undefined"!==typeof requirejs){if(G(requirejs))return;r=requirejs;requirejs=void 0}"undefined"!==typeof require&&!G(require)&&(r=require,require=void 0);h=requirejs=function(b,c,d,g){var u,m="_";!H(b)&&"string"!==typeof b&&(u=b,H(c)?(b=c,c=d,d=g):b=[]);u&&u.context&&(m=u.context);(g=j(F,m))||(g=F[m]=h.s.newContext(m));u&&g.configure(u);return g.require(b,c,d)};h.config=function(b){return h(b)};
h.nextTick="undefined"!==typeof setTimeout?function(b){setTimeout(b,4)}:function(b){b()};require||(require=h);h.version="2.1.10";h.jsExtRegExp=/^\/|:|\?|\.js$/;h.isBrowser=z;x=h.s={contexts:F,newContext:ha};h({});v(["toUrl","undef","defined","specified"],function(b){h[b]=function(){var c=F._;return c.require[b].apply(c,arguments)}});if(z&&(y=x.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0]))y=x.head=D.parentNode;h.onError=da;h.createNode=function(b){var c=
b.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml","html:script"):document.createElement("script");c.type=b.scriptType||"text/javascript";c.charset="utf-8";c.async=!0;return c};h.load=function(b,c,d){var g=b&&b.config||{};if(z)return g=h.createNode(g,c,d),g.setAttribute("data-requirecontext",b.contextName),g.setAttribute("data-requiremodule",c),g.attachEvent&&!(g.attachEvent.toString&&0>g.attachEvent.toString().indexOf("[native code"))&&!Z?(O=!0,g.attachEvent("onreadystatechange",b.onScriptLoad)):
(g.addEventListener("load",b.onScriptLoad,!1),g.addEventListener("error",b.onScriptError,!1)),g.src=d,M=g,D?y.insertBefore(g,D):y.appendChild(g),M=null,g;if(fa)try{importScripts(d),b.completeLoad(c)}catch(j){b.onError(C("importscripts","importScripts failed for "+c+" at "+d,j,[c]))}};z&&!r.skipDataMain&&U(document.getElementsByTagName("script"),function(b){y||(y=b.parentNode);if(L=b.getAttribute("data-main"))return q=L,r.baseUrl||(E=q.split("/"),q=E.pop(),Q=E.length?E.join("/")+"/":"./",r.baseUrl=
Q),q=q.replace(R,""),h.jsExtRegExp.test(q)&&(q=L),r.deps=r.deps?r.deps.concat(q):[q],!0});define=function(b,c,d){var g,h;"string"!==typeof b&&(d=c,c=b,b=null);H(c)||(d=c,c=null);!c&&G(d)&&(c=[],d.length&&(d.toString().replace(la,"").replace(ma,function(b,d){c.push(d)}),c=(1===d.length?["require"]:["require","exports","module"]).concat(c)));if(O){if(!(g=M))P&&"interactive"===P.readyState||U(document.getElementsByTagName("script"),function(b){if("interactive"===b.readyState)return P=b}),g=P;g&&(b||
(b=g.getAttribute("data-requiremodule")),h=F[g.getAttribute("data-requirecontext")])}(h?h.defQueue:S).push([b,c,d])};define.amd={jQuery:!0};h.exec=function(b){return eval(b)};h(r)}})(this);
+21
View File
@@ -0,0 +1,21 @@
/**
* @fileoverview stopEvent
* @author Random | http://weibo.com/random
* @date 2015-03-11
*/
define(function(require, exports, module) {
"use strict";
module.exports = function(evt){
if(evt){
if(evt.preventDefault) {
evt.preventDefault();
evt.stopPropagation();
}else{
evt.returnValue = false;
evt.cancelBubble = true;
}
}
};
});
+50
View File
@@ -0,0 +1,50 @@
/**
* @fileoverview util
* @author Random | http://weibo.com/random
* @date 2015-02-05
*/
define(function(require, exports, module) {
"use strict";
module.exports = {
drawCircle : function(ctx, x, y, r, c){
ctx.beginPath();
ctx.arc(x, y, r, 0, 2 * Math.PI, false);
ctx.fillStyle = c || "red";
ctx.fill();
},
drawLine : function(ctx, x1, y1, x2, y2, c, w){
ctx.strokeStyle = c || "red";
ctx.lineWidth = w || 1
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.stroke();
},
drawText : function(ctx, x, y, text, size, c){
ctx.font = size + "px Verdana";
ctx.fillStyle = c || "red";
ctx.fillText(text, x, y);
},
getTextWidth : function(ctx, x, y, text, size, c){
ctx.font = size + "px Verdana";
ctx.fillStyle = c || "red";
return ctx.measureText(text).width;
},
getPointDistance : function(p1, p2){
return Math.floor(Math.sqrt(Math.floor(Math.pow(p1.x - p2.x, 2)) + Math.floor(Math.pow(p1.y - p2.y, 2))));
},
isMobile : (/(mobile|iphone|ipod|ipad|ios|android|windows phone)/i).test(navigator.userAgent),
isAndroid : (/android/i).test(navigator.userAgent),
isWeixin : (/MicroMessenger/i).test(navigator.userAgent)
};
});
+15
View File
@@ -0,0 +1,15 @@
/**
* @fileoverview index
* @author Random | http://weibo.com/random
* @date 2015-02-05
*/
define("page/index", function(require, exports, module) {
"use strict";
var Game = require("general/Game");
Game.start();
});
require(["page/index"]);
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

File diff suppressed because one or more lines are too long
@@ -0,0 +1,114 @@
/**
* @fileoverview
* @author Random | http://weibo.com/random
* @created 2014-07-15
*/
var fs = require("fs");
var amdjsBuild = require("amdjs-build");
var TRANS_DIR = './_transport/';
var COMBI_DIR = './_combi/';
var AMDJS_BUILD_DIR = './_amdjs_build/';
var DEST_DIR = './built/';
var SRC_DIR = "../../js/";
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean : {
before : [TRANS_DIR, COMBI_DIR, AMDJS_BUILD_DIR, DEST_DIR],
after: [TRANS_DIR, COMBI_DIR, AMDJS_BUILD_DIR]
},
transport: {
options: {
paths: [SRC_DIR],
alias: {
"jquery": "conf/jquery"
},
debug: false
},
target: {
files: [{
cwd: SRC_DIR,
expand: true,
src: [
//srcFile,
'**/*.js',
'!conf/requireConf.js',
'!lib/require.js'
],
dest: TRANS_DIR
}]
}
},
combi: {
target: {
options: {
modulesPath : TRANS_DIR,
seajsUse : "",
complete : combiComplete
},
files: [{
cwd: TRANS_DIR,
expand: true,
src: "page/*.js",
dest: COMBI_DIR
}]
}
},
uglify: {
options: {
report: 'min'
},
target: {
files: [{
cwd: AMDJS_BUILD_DIR,
expand: true,
src: "*.js",
dest: DEST_DIR
}]
}
}
});
function combiComplete(fileList){
if(!fs.existsSync(AMDJS_BUILD_DIR)){
fs.mkdirSync(AMDJS_BUILD_DIR);
}
fileList.forEach(function(file){
var fileName;
var arr;
if(file.indexOf("/") > -1){
arr = file.split("/");
fileName = arr.pop();
}else{
fileName = file;
}
amdjsBuild(file, AMDJS_BUILD_DIR + fileName.replace(/\.js$/, ".min.js"), "$AJB");
});
}
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-cmd-transport');
grunt.loadNpmTasks('grunt-cmd-combi');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', '默认任务', function() {
console.log("grunt build: 将项目目录js/page/下的js文件分别合并压缩到当前built目录");
});
grunt.registerTask('build', ['clean:before', 'transport','combi', 'uglify', 'clean:after']);
//grunt.registerTask('build', ['clean:before', 'transport', 'combi']);
};
+694
View File
@@ -0,0 +1,694 @@
"undefined" == typeof window.define && ((window.define = function () {}), (window.define.amd = 1)),
"undefined" == typeof window.$AJB && (window.$AJB = {}),
($AJB.lib = {}),
($AJB.general = {}),
($AJB.page = {}),
($AJB.lib.stopEvent = function () {
"use strict";
return function (a) {
a && (a.preventDefault ? (a.preventDefault(), a.stopPropagation()) : ((a.returnValue = !1), (a.cancelBubble = !0)));
};
}),
($AJB.lib.Storage = function () {
"use strict";
var a = {
setValue: function (a, b) {
window.localStorage && (window.localStorage[a] = b);
},
getValue: function (a) {
return window.localStorage ? window.localStorage[a] : void 0;
},
};
return a;
}),
($AJB.general.BeginStage = function () {
"use strict";
function a(a) {
function c() {
b(h, "click", function () {
e.fire(g, f);
}),
(j.innerHTML = d.isAndroid ? "GO" : "▶");
}
var h = a.getElementsByClassName("button")[0],
i = a.getElementsByClassName("text")[0],
j = document.getElementById("txtAr"),
k = {
show: function () {
a.style.display = "";
},
hide: function () {
a.style.display = "none";
},
level: function (a) {
(f = a), (i.innerHTML = "level " + a);
},
on: function (a, b) {
e.add(a, b);
},
off: function (a, b) {
e.remove(a, b);
},
};
return c(), k;
}
var b = $AJB.lib.addEvent(),
c = $AJB.lib.CustEvent(),
d = $AJB.lib.util(),
e = c(),
f = 0,
g = "start";
return a;
}),
($AJB.general.Switcher = function () {
"use strict";
function a(a, b, c) {
var d,
e,
f = null,
g = !1,
h = {
point: [0, 0],
enabled: !1,
color: "#c8c8c8",
update: function () {
var a = h.point,
c = 30;
h.enabled &&
(0 === e
? ((d = h.color), a[0] < b / 2 ? ((a[0] = Math.min(a[0] + c, b / 2)), (h.point = a)) : ((h.point = a), (g = !0)))
: 1 === e && ((d = "#000"), a[0] > b / 2 ? ((a[0] = Math.max(a[0] - c, b / 2)), (h.point = a)) : ((h.point = a), (g = !0))));
},
render: function () {
var e = h.point;
h.enabled && ((a.fillStyle = d), a.fillRect(e[0] - b / 2, e[1] - c / 2, b, c), g && ((h.enabled = !1), f && f()));
},
switchStage: function (d, i) {
0 === d ? (h.point = [-b / 2, c / 2]) : 1 === d && ((a.fillStyle = h.color), a.fillRect(0, 0, b, c), (h.point = [b + b / 2, c / 2])), (h.enabled = !0), (g = !1), (e = d), (f = i);
},
};
return h;
}
return a;
}),
($AJB.lib.addEvent = function () {
var a = $AJB.lib.util(),
b = { click: "touchstart", mousedown: "touchstart", mouseup: "touchend" };
return function (c, d, e, f) {
c.addEventListener ? c.addEventListener(a.isMobile ? b[d] || d : d, e, f) : c.attachEvent ? c.attachEvent("on" + d, e) : (c["on" + d] = e);
};
}),
($AJB.general.Levels = function () {
"use strict";
function a(a, b) {
return function () {
var c = 0;
return function () {
return (c += (a * b) % 360);
};
};
}
function b(a, b) {
return function () {
var c = 0,
d = 1,
e = +new Date();
return function () {
var f = +new Date();
return f - e > b && ((d = -d), (e = f)), (c += (d * a) % 360);
};
};
}
function c(a, b, c, d) {
return function () {
var e = 0,
f = +new Date();
return function () {
var g = +new Date();
return g - f > c && ((a = b - a), (f = g)), (e += (a * d) % 360);
};
};
}
function d(a) {
var b = 1;
return (
h(document.body, "mousedown", function () {
b = -b;
}),
function () {
var c = 0;
return function () {
return (c += (a * b) % 360);
};
}
);
}
function e(a, b, c, d) {
return (
h(document.body, "mousedown", function () {
d = -d;
}),
function () {
var e = 0,
f = +new Date();
return function () {
var g = +new Date();
return g - f > c && ((a = b - a), (f = g)), (e += (a * d) % 360);
};
}
);
}
function f(a, b, c, d) {
i[a] = { childs: k[b], queueCount: c, round: j[d] };
}
var g,
h = $AJB.lib.addEvent(),
i = {},
j = {
A1: a(1.5, 1),
A2: a(1.5, -1),
B1: a(2.5, 1),
B2: a(2.5, -1),
C1: b(2.2, 3e3),
C2: b(3.5, 2e3),
D1: c(2, 2.3, 1200, 1),
D2: c(2, 2.3, 1200, -1),
D3: c(4, 4.5, 1700, 1),
D4: c(4, 4.5, 1700, -1),
D5: c(4, 4.5, 1700, 1),
D6: c(4, 4.5, 1700, -1),
E1: d(2),
E2: e(2, 2.3, 1e3, 1),
},
k = {
0: [],
2: [0, 180],
3: [0, 120, 240],
4: [0, 90, 180, 270],
5: [0, 72, 144, 216, 288],
6: [0, 60, 120, 180, 240, 300],
7: [0, 52, 103, 155, 206, 258, 309],
8: [0, 45, 90, 135, 180, 225, 270, 315],
9: [0, 40, 80, 120, 160, 200, 240, 280, 320],
10: [0, 36, 72, 108, 144, 180, 216, 252, 288, 324],
11: [0, 33, 66, 99, 131, 164, 197, 230, 262, 295, 328],
12: [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330],
13: [0, 28, 56, 84, 111, 139, 167, 194, 222, 250, 277, 305, 333],
14: [0, 26, 52, 78, 103, 129, 155, 180, 206, 232, 258, 283, 309, 335],
15: [0, 24, 48, 72, 96, 120, 144, 168, 192, 216, 240, 264, 288, 312, 336],
16: [0, 23, 45, 68, 90, 113, 135, 158, 180, 203, 225, 248, 270, 293, 315, 338],
},
l = {
1: ["4", 8, "A1"],
2: ["6", 10, "A1"],
3: ["2", 20, "A1"],
4: ["8", 12, "A2"],
5: ["12", 8, "A1"],
6: ["10", 10, "A2"],
7: ["12", 13, "A1"],
8: ["16", 3, "A2"],
9: ["0", 26, "A2"],
10: ["16", 10, "A1"],
11: ["10", 8, "B1"],
12: ["6", 12, "B2"],
13: ["12", 4, "B1"],
14: ["8", 14, "B2"],
15: ["8", 6, "B1"],
16: ["5", 10, "B2"],
17: ["6", 12, "B1"],
18: ["8", 14, "B2"],
19: ["0", 23, "B1"],
20: ["10", 13, "B2"],
21: ["4", 12, "C1"],
22: ["6", 10, "C1"],
23: ["8", 12, "C1"],
24: ["7", 14, "C1"],
25: ["2", 18, "C1"],
26: ["4", 18, "C1"],
27: ["0", 24, "C1"],
28: ["4", 10, "C2"],
29: ["6", 13, "C2"],
30: ["4", 20, "C1"],
31: ["6", 8, "D1"],
32: ["2", 12, "D2"],
33: ["3", 14, "D2"],
34: ["3", 18, "D1"],
35: ["8", 12, "D1"],
36: ["7", 15, "D2"],
37: ["16", 8, "D2"],
38: ["0", 23, "D1"],
39: ["12", 12, "D1"],
40: ["12", 15, "D2"],
41: ["5", 10, "E1"],
42: ["6", 12, "E1"],
43: ["3", 15, "E1"],
44: ["3", 19, "E1"],
45: ["0", 24, "E1"],
46: ["2", 15, "E2"],
47: ["4", 16, "E2"],
48: ["12", 8, "E2"],
49: ["3", 20, "E2"],
50: ["16", 14, "E2"],
51: ["4", 6, "D3"],
52: ["4", 12, "D4"],
53: ["6", 13, "D3"],
54: ["0", 24, "D4"],
55: ["4", 21, "D3"],
56: ["16", 16, "A1"],
57: ["4", 24, "C1"],
58: ["4", 26, "D1"],
59: ["4", 25, "E2"],
60: ["13", 19, "E2"],
};
for (g in l) f(g, l[g][0], l[g][1], l[g][2]);
return i;
}),
($AJB.general.Collide = function () {
"use strict";
var a = $AJB.lib.util(),
b = {
check: function (b, c, d) {
var e = b.childs(),
f = e.length,
g = Math.ceil(2 * c.rad());
for (d = d || 1; f--; ) if (c !== e[f].ball && a.getPointDistance(c.pos(), e[f].ball.pos()) <= g + Math.ceil(2 * d)) return !0;
return !1;
},
};
return b;
}),
($AJB.general.Tween = function () {
"use strict";
var a = {
simple: function (b, c, d, e) {
var f = (c - b) / e,
g = +new Date();
return e > g - d ? ((a.isEnd = !1), b + (g - d) * f) : ((a.isEnd = !0), c);
},
isEnd: !0,
};
return a;
}),
($AJB.general.BallQueue = function () {
"use strict";
function a(a, f, g, h, i) {
function j() {
var b,
d,
e = k(a),
j = e.length;
for (b = 0; j > b; b++) (d = c(h, null, e[b], null, i)), d.pos(f, g + 3 * d.rad() * b), m.push(d);
}
function k(a) {
for (var b = a, c = []; b--; ) c.push(b + 1);
return c;
}
var l,
m = [],
n = [],
o = b();
return (
(i = i || 1),
(l = {
ballList: m,
add: function () {},
remove: function (a) {
var b = m[a];
return m.splice(a, 1), b;
},
clear: function () {
(n = []), (m = []);
},
popup: function () {
var a = m.shift();
(a.st = +new Date()), (a.sv = a.pos().y), n.push(a);
},
update: function () {
var a,
b,
c,
h = n.length,
i = m.length;
if (h) {
for (b = n[0].rad(), a = g - 3 * b; h--; ) n[h].pos(f, d.simple(n[h].sv, a, n[h].st, 50)), (c = n[n.length - 1].pos().y), n[h].pos().y === a && (o.fire(e, n[h]), n.splice(h, 1));
for (; i--; ) m[i].pos(f, c + 3 * b * (i + 1));
}
},
render: function () {
for (var a = m.length, b = n.length; a--; ) m[a].render();
for (; b--; ) n[b].render();
},
on: function (a, b) {
o.add(a, b);
},
off: function (a, b) {
o.remove(a, b);
},
destroy: function () {
for (var a = m.length; a--; ) m[a].destroy();
o.destroy();
},
}),
j(),
l
);
}
var b = $AJB.lib.CustEvent(),
c = $AJB.general.Ball(),
d = $AJB.general.Tween(),
e = "popup";
return a;
}),
($AJB.general.Ball = function () {
"use strict";
function a(a, c, d, e, f) {
function g() {
var c = b.getTextWidth(a, 0, 0, d, e);
b.drawText(a, i - c / 2, j + e / 2, d, e, "black");
}
var h,
i = 0,
j = 0;
return (
(f = f || 1),
(c = (c || 12) * f),
(e = (e || 15) * f),
(h = {
pos: function (a, b) {
return "undefined" != typeof a && (i = a), "undefined" != typeof b && (j = b), { x: i, y: j };
},
scale: function (a) {
return "undefined" != typeof a && (f = a), f;
},
rad: function (a) {
return "undefined" != typeof a && (c = a), c;
},
render: function (e) {
b.drawCircle(a, i, j, c, "#ffffff"), "undefined" != typeof d ? g(d) : "undefined" != typeof e && g(e);
},
destroy: function () {
h = null;
},
})
);
}
var b = $AJB.lib.util();
return a;
}),
($AJB.lib.util = function () {
"use strict";
return {
drawCircle: function (a, b, c, d, e) {
a.beginPath(), a.arc(b, c, d, 0, 2 * Math.PI, !1), (a.fillStyle = e || "red"), a.fill();
},
drawLine: function (a, b, c, d, e, f, g) {
(a.strokeStyle = f || "red"), (a.lineWidth = g || 1), a.beginPath(), a.moveTo(b, c), a.lineTo(d, e), a.stroke();
},
drawText: function (a, b, c, d, e, f) {
(a.font = e + "px Verdana"), (a.fillStyle = f || "red"), a.fillText(d, b, c);
},
getTextWidth: function (a, b, c, d, e, f) {
return (a.font = e + "px Verdana"), (a.fillStyle = f || "red"), a.measureText(d).width;
},
getPointDistance: function (a, b) {
return Math.floor(Math.sqrt(Math.floor(Math.pow(a.x - b.x, 2)) + Math.floor(Math.pow(a.y - b.y, 2))));
},
isMobile: /(mobile|iphone|ipod|ipad|ios|android|windows phone)/i.test(navigator.userAgent),
isAndroid: /android/i.test(navigator.userAgent),
isWeixin: /MicroMessenger/i.test(navigator.userAgent),
};
}),
($AJB.general.Core = function () {
"use strict";
function a(a, d, e, f, g) {
function h() {
for (var a, b, c, d, e = l.length; e--; )
(a = 3 * Math.cos(((l[e].angle + j.angle()) * Math.PI) / 180) * m * g + n), (b = 3 * Math.sin(((l[e].angle + j.angle()) * Math.PI) / 180) * m * g + o), (c = a / Math.abs(a)), (d = b / Math.abs(b)), l[e].ball.pos(a, b);
}
var i,
j,
k = 0,
l = [],
m = 50,
n = a.width / 2,
o = 4 * m * g;
return (
(g = g || 1),
(i = c(d, m, e, f, g)),
i.pos(n, o),
(j = {
pos: i.pos,
scale: i.scale,
rad: i.rad,
angle: function (a) {
return "undefined" != typeof a && (k = a), k;
},
addChild: function (a, b) {
l.push({ angle: a, ball: b });
},
clear: function () {
l = [];
},
childs: function () {
return l;
},
update: function () {
h();
},
render: function () {
var c,
e = l.length,
f = a.width,
h = a.height;
for (d.clearRect(0, 0, f, h), c = 0; e > c; c++) b.drawLine(d, n, o, l[c].ball.pos().x, l[c].ball.pos().y, "#ffffff", 1.5 * g), l[c].ball.render();
i.render();
},
destroy: function () {
j.clear(), (i = null), (j = null);
},
})
);
}
var b = $AJB.lib.util(),
c = $AJB.general.Ball();
return a;
}),
($AJB.lib.CustEvent = function () {
return function (a) {
function b(a) {
return Object.prototype.toString.call(a).slice(8, -1).toLowerCase();
}
var c = {};
return (
!a && (a = {}),
{
add: function (a, d) {
if ("function" === b(d)) {
var e = c;
(a = a.toLowerCase()), !e[a] && (e[a] = []), e[a].push(d);
}
},
remove: function (a, d) {
var e,
f = c[a];
if (((a = a.toLowerCase()), "function" === b(d) && f && f.length)) for (e = f.length - 1; e >= 0; e--) f[e] === d && f.splice(e, 1);
},
fire: function (b) {
var d, e, f, g;
if (((b = b.toLowerCase()), (d = c[b]), d && d.length)) for (e = Array.prototype.slice.call(arguments, 1), g = d.length, f = 0; g > f; f++) d[f].apply(a, e);
},
destroy: function () {
var a,
b = c.length - 1;
for (a = b; a >= 0; a--) evts.splice(a, 1);
},
}
);
};
}),
($AJB.general.Scene = function () {
"use strict";
function a(a, b, l, m) {
function n(a) {
var g = a.childs,
h = g.length;
for (y = a.round(), w && w.destroy(), w = c(b, l, B, 50, m); h--; ) w.addChild(g[h], d(l, null, "", null, m));
x && x.destroy(),
(x = e(a.queueCount, b.width / 2, w.pos().y + 4 * w.rad(), l, m)),
x.on("popup", function (a) {
w.addChild(90 - w.angle(), a), f.check(w, a, m) ? ((z = a), s()) : !x.ballList.length && r();
});
}
function o() {
y && (w.angle(y()), w.update(), x.update());
}
function p() {
var b,
c,
d,
e,
f = w.childs(),
g = f.length,
h = 25;
for (a.style.backgroundColor = u.bgColor; g--; ) (b = f[g].angle + w.angle()), (c = Math.cos((b * Math.PI) / 180) * h), (d = Math.sin((b * Math.PI) / 180) * h), (e = f[g].ball.pos()), f[g].ball.pos(e.x + c, e.y + d);
}
function q(a) {
var b,
c = [25, 15, 20, 15],
d = c.length,
e = 200,
f = e / d;
for (w.update(), b = 1; d >= b; b++) a > f * b && z.rad(c[b - 1] * m);
}
function r() {
"pass" !== A && ((a.style.backgroundColor = "#1CB01A"), (A = "pass"), (v = +new Date()));
}
function s() {
"fail" !== l && ((a.style.backgroundColor = "#B8111C"), (A = "fail"), (v = +new Date()));
}
function t() {
var a = "to be continued...",
c = h.getTextWidth(l, 0, 0, a, 30 * m);
h.drawText(l, (b.width - c) / 2, 200 * m, a, 30 * m, "yellow");
}
var u,
v,
w,
x,
y,
z,
A = "run",
B = 1;
return (u = {
enabled: !1,
run: function (b) {
var c = g[b];
(B = b), c ? ((u.enabled = !0), n(c), (a.style.backgroundColor = "#000"), (A = "run")) : t();
},
shot: function () {
x && x.ballList.length && x.popup();
},
update: function () {
var a;
u.enabled && ("run" === A ? o() : "pass" === A ? (p(), +new Date() - v > 1e3 && ((A = ""), k.fire(i))) : "fail" === A && ((a = +new Date() - v), q(a), a > 1e3 && ((A = ""), k.fire(j))));
},
render: function () {
u.enabled && (w.render(), x.render());
},
on: function (a, b) {
k.add(a, b);
},
off: function (a, b) {
k.remove(a, b);
},
});
}
var b = $AJB.lib.CustEvent(),
c = $AJB.general.Core(),
d = $AJB.general.Ball(),
e = $AJB.general.BallQueue(),
f = $AJB.general.Collide(),
g = $AJB.general.Levels(),
h = $AJB.lib.util(),
i = "passed",
j = "failed",
k = b();
return a;
}),
($AJB.general.Game = function () {
"use strict";
function a() {
var a = document.body.scrollWidth || document.documentElement.scrollWidth,
b = document.body.scrollHeight || document.documentElement.scrollHeight;
(r.width = a), (r.height = b), (i = l(x, a, b)), (s.style.backgroundColor = i.color), (s.style.width = a + "px"), (s.style.height = b + "px"), (j = b / 560);
}
function b() {
u.href = B.replace(/#\{level\}/, D);
}
function c() {
p.isWeixin
? n(u, "mousedown", function () {
w.style.display = "";
})
: p.isMobile && b();
}
function d(a) {
(D = +a), o.setValue(z, D), (document.title = A.replace(/\#\{level\}/, D)), C.level(D), !p.isWeixin && p.isMobile && b();
}
function e() {
n(document.body, "mousedown", function (a) {
var b;
if (a && a.changedTouches) for (b = a.changedTouches.length; b--; ) h.shot();
else h.shot();
"1" != a.target.getAttribute("data-capture") && q(a);
}),
n(w, "mousedown", function () {
w.style.display = "none";
}),
n(v, "mousedown", function () {
E ||
((E = !0),
(t.style.display = ""),
d(1),
setTimeout(function () {
(t.style.display = "none"), (E = !1);
}, 1e3));
}),
h.on("passed", function () {
i.switchStage(0, function () {
(h.enabled = !1), d(D + 1), (r.style.display = "none"), C.show();
});
}),
h.on("failed", function () {
i.switchStage(0, function () {
(h.enabled = !1), (r.style.display = "none"), C.level(D), C.show();
});
}),
C.on("start", function () {
(r.style.display = ""),
C.hide(),
i.switchStage(1, function () {
h.run(D);
});
});
}
function f() {
window.clearTimeout(F), h.update(), h.render(), i.update(), i.render(), (F = window.setTimeout(f, 1e3 / y));
}
function g() {
a(), (h = k(document.body, r, x, j)), e(), c(), C.level(D), C.show(), f();
}
var h,
i,
j,
k = $AJB.general.Scene(),
l = $AJB.general.Switcher(),
m = $AJB.general.BeginStage(),
n = $AJB.lib.addEvent(),
o = $AJB.lib.Storage(),
p = $AJB.lib.util(),
q = $AJB.lib.stopEvent(),
r = document.getElementById("stage"),
s = document.getElementById("begin"),
t = document.getElementById("tip"),
u = document.getElementById("btnFW"),
v = document.getElementById("btnReset"),
w = document.getElementById("wxArrow"),
x = r.getContext("2d"),
y = 60,
z = "core-ball-level",
A = "Core Ball(酷啵)-练手活的HTML5游戏,我已玩到第#{level}关了,你也来试试吧!",
B = "sinaweibo://share?content=Core Ball(酷啵) - 练手活的HTML5小游戏,我已玩到第#{level}关了,你也来试试吧! http://coreball.sinaapp.com",
C = m(s),
D = +o.getValue(z) || 1,
E = !1,
F = 0,
G = { start: g };
return G;
}),
($AJB.page.index = function () {
"use strict";
var a = $AJB.general.Game();
a.start();
}),
$AJB.page.index();
+6255 -1
View File
File diff suppressed because one or more lines are too long
+5
View File
@@ -58,6 +58,11 @@
if ((event.keyCode === 32 || event.keyCode === 38 || event.keyCode === 40) && event.target === document.body) {
event.preventDefault();
}
if (event.key.toLowerCase() === 'q' && event.ctrlKey) {
event.preventDefault();
data.lives.amount = "Infinity";
updateDataElement(data.lives);
}
},
false
);
Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
{"intro":{"name":"intro","components":{"Transform":{"position":{"x":0,"y":0,"z":0},"$type":"TransformData"}},"children":[{"name":"high_tracks3_high_group_place","components":{"Transform":{"position":{"x":0,"y":0,"z":-180},"$type":"TransformData"}},"children":[]},{"name":"bag_place","components":{"Transform":{"position":{"x":0.141,"y":0.604,"z":-18.326},"$type":"TransformData"}},"children":[]},{"name":"Ground","components":{"Transform":{"position":{"x":0,"y":0,"z":0},"$type":"TransformData"}},"children":[]},{"name":"trains","components":{"Transform":{"position":{"x":-20,"y":0,"z":0},"$type":"TransformData"}},"children":[{"name":"train_sub_1_place","components":{"Transform":{"position":{"x":-20,"y":0,"z":-30},"$type":"TransformData"}},"children":[]},{"name":"train_start_place","components":{"Transform":{"position":{"x":-20,"y":0,"z":-30},"$type":"TransformData"}},"children":[]},{"name":"train_sub_1_place","components":{"Transform":{"position":{"x":-20,"y":0,"z":30},"$type":"TransformData"}},"children":[]}]},{"name":"high_tracks3_high_group_place","components":{"Transform":{"position":{"x":0,"y":0,"z":0},"$type":"TransformData"}},"children":[]},{"name":"lightSignal_group_place","components":{"Transform":{"position":{"x":10,"y":0,"z":0},"$type":"TransformData"}},"children":[]}]}}
@@ -0,0 +1,21 @@
{
"lang": "en",
"bundlepath": " ",
"env": "1103_seoul",
"env_builtin": "1103_seoul",
"char": "jake",
"loading_en": "loading",
"loading_pt-br": "carregando",
"revivals": 3,
"reviveTimeout": 6,
"pokiSdkDebug": false,
"commercials": false,
"rewardedBreaks": false,
"rewardedBreaksMobile": false,
"autoload": false,
"leaderboards": false,
"useDefaultPrompt": false,
"vconsole": false,
"monitor": false,
"maxNicknameChars": 15
}
@@ -0,0 +1,53 @@
{
"STR_L_HTML5": "This game uses HTML5. If it loads but does not run, please update your web browser",
"menu": "Menu",
"toprun": "Top Run",
"highscores": "High Scores",
"collect": "Collect",
"characters": "Characters",
"boards": "Boards",
"awards": "Awards",
"boosts": "Boosts",
"free_stuff": "Free Stuff",
"store": "Store",
"resume": "Resume",
"play": "Play",
"pause": "Pause",
"gameover": "Game Over",
"wip": "(WIP)",
"free": "Free!",
"save_me": "Save me!",
"leaderboards": "Leaderboards",
"score": "Score",
"coins": "Coins",
"high_score": "High Score",
"new_high_score": "New High Score!",
"settings": "Settings",
"tap_to_play": "Tap to play",
"tap_to_play_desktop": "Press space to play",
"nickname_prompt": "Set your nickname",
"ok": "OK",
"cancel": "Cancel",
"sound": "Sound",
"on": "On",
"off": "Off",
"nickname": "Nickname",
"tutorial_good": "Fresh Moves!",
"tutorial_hoverboard": "Double Tap for\nHoverboard",
"tutorial_hoverboard_desktop": "Press Space for\nHoverboard",
"tutorial_finished": "You rock! Now GO!",
"tutorial_up": "Swipe Up",
"tutorial_up_desktop": "Press Arrow Key Up",
"tutorial_down": "Swipe Down",
"tutorial_down_desktop": "Press Arrow Key Down",
"tutorial_left": "Swipe Left",
"tutorial_left_desktop": "Press Arrow Key Left",
"tutorial_right": "Swipe Right",
"tutorial_right_desktop": "Press Arrow Key Right",
"privacy_policy": "More games",
"privacy_policy_link": "https://zazgames.com/"
}
@@ -0,0 +1,6 @@
@font-face {
font-family: 'Lilita One';
src: url('lilita-one.woff2') format('woff2'), url('lilita-one.woff') format('woff');
font-weight: normal;
font-style: normal;
}
Binary file not shown.
@@ -0,0 +1,6 @@
@font-face {
font-family: 'Titan One';
src: url('titan-one.woff2') format('woff2'), url('titan-one.woff') format('woff');
font-weight: normal;
font-style: normal;
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 932 B

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Some files were not shown because too many files have changed in this diff Show More