forked from RSamaium/RPG-JS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpg-beta-2.js
83 lines (70 loc) · 1.86 KB
/
rpg-beta-2.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*!
* RPG JavaScript Library Beta 2.0
* http://rpgjs.com
*
* Copyright 2011, Samuel Ronce
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Includes Easel.js (modified)
* http://easeljs.com
* Copyright 2011, Grant Skinner
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* Date: December 08, 2011
*/
RPGJS = {}
RPGJS.loadPath = "rpgjs/core/";
RPGJS.params = {};
RPGJS.dirPluginsName = "../plugins";
RPGJS.plugins = [];
RPGJS.commons_scripts = ["../libs/easel-3.2-modified.min", "cache", "input", "effects", "animations", "scene", "window"];
RPGJS.local_scripts = ["rpg", "interpreter", "event", "player"];
RPGJS.load = function(params, callback) {
if (typeof params === "function") {
callback = params;
params = {};
}
RPGJS.params = params;
var current_load = 0, i,
plugins = [],
scripts = RPGJS.commons_scripts;
scripts = scripts.concat(RPGJS.local_scripts);
if (params.plugins) {
plugins = params.plugins;
for (var i=0 ; i < plugins.length ; i++) {
RPGJS.plugins.push(plugins[i]);
plugins[i] = RPGJS.dirPluginsName + '/' + plugins[i];
}
scripts = scripts.concat(plugins);
}
loadScript(scripts[current_load]);
function loadFinish() {
current_load++;
if (scripts[current_load]) {
loadScript(scripts[current_load]);
}
else {
if (callback) {
window.onload = callback;
}
}
}
function loadScript(filename) {
var script = document.createElement("script");
script.type = "text/javascript";
if (script.readyState){
script.onreadystatechange = function(){
if (script.readyState == "loaded" ||
script.readyState == "complete"){
script.onreadystatechange = null;
loadFinish();
}
}
} else {
script.onload = loadFinish;
}
script.src = RPGJS.loadPath + filename + '.js';
document.getElementsByTagName("head")[0].appendChild(script);
}
}
Database = {};