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
+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"]);