seed-engine
Version:
A Lightweight 2D game engine using WebGL2. The engine is designed on the focus of creating a bridge between creating and publishing games to the Seed Network as modules.
1,275 lines (1,274 loc) • 166 kB
JSON
{
"type": "File",
"start": 0,
"end": 1788,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 56,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1788,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 56,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "ExportDefaultDeclaration",
"start": 217,
"end": 1788,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 56,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 232,
"end": 1788,
"loc": {
"start": {
"line": 6,
"column": 15
},
"end": {
"line": 56,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 238,
"end": 244,
"loc": {
"start": {
"line": 6,
"column": 21
},
"end": {
"line": 6,
"column": 27
},
"identifierName": "Loader"
},
"name": "Loader",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 245,
"end": 1788,
"loc": {
"start": {
"line": 6,
"column": 28
},
"end": {
"line": 56,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 469,
"end": 693,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 19,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 469,
"end": 480,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 12,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor",
"leadingComments": null
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 481,
"end": 501,
"loc": {
"start": {
"line": 12,
"column": 16
},
"end": {
"line": 12,
"column": 36
},
"identifierName": "loadCompleteCallback"
},
"name": "loadCompleteCallback"
}
],
"body": {
"type": "BlockStatement",
"start": 503,
"end": 693,
"loc": {
"start": {
"line": 12,
"column": 38
},
"end": {
"line": 19,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 513,
"end": 536,
"loc": {
"start": {
"line": 13,
"column": 8
},
"end": {
"line": 13,
"column": 31
}
},
"expression": {
"type": "AssignmentExpression",
"start": 513,
"end": 535,
"loc": {
"start": {
"line": 13,
"column": 8
},
"end": {
"line": 13,
"column": 30
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 513,
"end": 531,
"loc": {
"start": {
"line": 13,
"column": 8
},
"end": {
"line": 13,
"column": 26
}
},
"object": {
"type": "ThisExpression",
"start": 513,
"end": 517,
"loc": {
"start": {
"line": 13,
"column": 8
},
"end": {
"line": 13,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 518,
"end": 531,
"loc": {
"start": {
"line": 13,
"column": 13
},
"end": {
"line": 13,
"column": 26
},
"identifierName": "objectsToLoad"
},
"name": "objectsToLoad"
},
"computed": false
},
"right": {
"type": "NumericLiteral",
"start": 534,
"end": 535,
"loc": {
"start": {
"line": 13,
"column": 29
},
"end": {
"line": 13,
"column": 30
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
},
{
"type": "ExpressionStatement",
"start": 545,
"end": 564,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 27
}
},
"expression": {
"type": "AssignmentExpression",
"start": 545,
"end": 563,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 26
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 545,
"end": 559,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 545,
"end": 549,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 550,
"end": 559,
"loc": {
"start": {
"line": 14,
"column": 13
},
"end": {
"line": 14,
"column": 22
},
"identifierName": "loadCount"
},
"name": "loadCount"
},
"computed": false
},
"right": {
"type": "NumericLiteral",
"start": 562,
"end": 563,
"loc": {
"start": {
"line": 14,
"column": 25
},
"end": {
"line": 14,
"column": 26
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
},
{
"type": "ExpressionStatement",
"start": 573,
"end": 598,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 33
}
},
"expression": {
"type": "AssignmentExpression",
"start": 573,
"end": 597,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 32
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 573,
"end": 593,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 28
}
},
"object": {
"type": "ThisExpression",
"start": 573,
"end": 577,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 578,
"end": 593,
"loc": {
"start": {
"line": 15,
"column": 13
},
"end": {
"line": 15,
"column": 28
},
"identifierName": "loadCountQueued"
},
"name": "loadCountQueued"
},
"computed": false
},
"right": {
"type": "NumericLiteral",
"start": 596,
"end": 597,
"loc": {
"start": {
"line": 15,
"column": 31
},
"end": {
"line": 15,
"column": 32
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
},
{
"type": "ExpressionStatement",
"start": 607,
"end": 628,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 29
}
},
"expression": {
"type": "AssignmentExpression",
"start": 607,
"end": 627,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 28
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 607,
"end": 619,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 20
}
},
"object": {
"type": "ThisExpression",
"start": 607,
"end": 611,
"loc": {
"start": {
"line": 16,
"column": 8
},
"end": {
"line": 16,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 612,
"end": 619,
"loc": {
"start": {
"line": 16,
"column": 13
},
"end": {
"line": 16,
"column": 20
},
"identifierName": "started"
},
"name": "started"
},
"computed": false
},
"right": {
"type": "BooleanLiteral",
"start": 622,
"end": 627,
"loc": {
"start": {
"line": 16,
"column": 23
},
"end": {
"line": 16,
"column": 28
}
},
"value": false
}
}
},
{
"type": "ExpressionStatement",
"start": 638,
"end": 687,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 57
}
},
"expression": {
"type": "AssignmentExpression",
"start": 638,
"end": 686,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 56
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 638,
"end": 663,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 33
}
},
"object": {
"type": "ThisExpression",
"start": 638,
"end": 642,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 643,
"end": 663,
"loc": {
"start": {
"line": 18,
"column": 13
},
"end": {
"line": 18,
"column": 33
},
"identifierName": "loadCompleteCallback"
},
"name": "loadCompleteCallback"
},
"computed": false
},
"right": {
"type": "Identifier",
"start": 666,
"end": 686,
"loc": {
"start": {
"line": 18,
"column": 36
},
"end": {
"line": 18,
"column": 56
},
"identifierName": "loadCompleteCallback"
},
"name": "loadCompleteCallback"
}
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Loader constructor. Requires a callback function; called when all loading elements are complete.\n * \n * @param {function} loadCompleteCallback Callback function once loading is complete.\n ",
"start": 251,
"end": 464,
"loc": {
"start": {
"line": 7,
"column": 4
},
"end": {
"line": 11,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Adds a Promise to the loader. Adding a promise wraps it allow the Loader to determine when loading is done.\n * The load complete callback is not triggered until start() is called.\n * \n * @param {Promise} promise A pending promise.\n ",
"start": 699,
"end": 960,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 26,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 965,
"end": 1278,
"loc": {
"start": {
"line": 27,
"column": 4
},
"end": {
"line": 38,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 965,
"end": 969,
"loc": {
"start": {
"line": 27,
"column": 4
},
"end": {
"line": 27,
"column": 8
},
"identifierName": "load"
},
"name": "load",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 970,
"end": 977,
"loc": {
"start": {
"line": 27,
"column": 9
},
"end": {
"line": 27,
"column": 16
},
"identifierName": "promise"
},
"name": "promise"
}
],
"body": {
"type": "BlockStatement",
"start": 979,
"end": 1278,
"loc": {
"start": {
"line": 27,
"column": 18
},
"end": {
"line": 38,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 989,
"end": 1010,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 29
}
},
"expression": {
"type": "UpdateExpression",
"start": 989,
"end": 1009,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 28
}
},
"operator": "++",
"prefix": false,
"argument": {
"type": "MemberExpression",
"start": 989,
"end": 1007,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 26
}
},
"object": {
"type": "ThisExpression",
"start": 989,
"end": 993,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 994,
"end": 1007,
"loc": {
"start": {
"line": 28,
"column": 13
},
"end": {
"line": 28,
"column": 26
},
"identifierName": "objectsToLoad"
},
"name": "objectsToLoad"
},
"computed": false
}
}
},
{
"type": "ExpressionStatement",
"start": 1019,
"end": 1272,
"loc": {
"start": {
"line": 29,
"column": 8
},
"end": {
"line": 37,
"column": 11
}
},
"expression": {
"type": "CallExpression",
"start": 1019,
"end": 1271,
"loc": {
"start": {
"line": 29,
"column": 8
},
"end": {
"line": 37,
"column": 10
}
},
"callee": {
"type": "MemberExpression",
"start": 1019,
"end": 1031,
"loc": {
"start": {
"line": 29,
"column": 8
},
"end": {
"line": 29,
"column": 20
}
},
"object": {
"type": "Identifier",
"start": 1019,
"end": 1026,
"loc": {
"start": {
"line": 29,
"column": 8
},
"end": {
"line": 29,
"column": 15
},
"identifierName": "promise"
},
"name": "promise"
},
"property": {
"type": "Identifier",
"start": 1027,
"end": 1031,
"loc": {
"start": {
"line": 29,
"column": 16
},
"end": {
"line": 29,
"column": 20
},
"identifierName": "then"
},
"name": "then"
},
"computed": false
},
"arguments": [
{
"type": "ArrowFunctionExpression",
"start": 1032,
"end": 1270,
"loc": {
"start": {
"line": 29,
"column": 21
},
"end": {
"line": 37,
"column": 9
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 1038,
"end": 1270,
"loc": {
"start": {
"line": 29,
"column": 27
},
"end": {
"line": 37,
"column": 9
}
},
"body": [
{
"type": "IfStatement",
"start": 1052,
"end": 1160,
"loc": {
"start": {
"line": 30,
"column": 12
},
"end": {
"line": 33,
"column": 39
}
},
"test": {
"type": "MemberExpression",
"start": 1056,
"end": 1068,
"loc": {
"start": {
"line": 30,
"column": 16
},
"end": {
"line": 30,
"column": 28
}
},
"object": {
"type": "ThisExpression",
"start": 1056,
"end": 1060,
"loc": {
"start": {
"line": 30,
"column": 16
},
"end": {
"line": 30,
"column": 20
}
}
},
"property": {
"type": "Identifier",
"start": 1061,
"end": 1068,
"loc": {
"start": {
"line": 30,
"column": 21
},
"end": {
"line": 30,
"column": 28
},
"identifierName": "started"
},
"name": "started"
},
"computed": false
},
"consequent": {
"type": "ExpressionStatement",
"start": 1086,
"end": 1103,
"loc": {
"start": {
"line": 31,
"column": 16
},
"end": {
"line": 31,
"column": 33
}
},
"expression": {
"type": "UpdateExpression",
"start": 1086,
"end": 1102,
"loc": {
"start": {
"line": 31,
"column": 16
},
"end": {
"line": 31,
"column": 32
}
},
"operator": "++",
"prefix": false,
"argument": {
"type": "MemberExpression",
"start": 1086,
"end": 1100,
"loc": {
"start": {
"line": 31,
"column": 16
},
"end": {
"line": 31,
"column": 30
}
},
"object": {
"type": "ThisExpression",
"start": 1086,
"end": 1090,
"loc": {
"start": {
"line": 31,
"column": 16
},
"end": {
"line": 31,
"column": 20
}
}
},
"property": {
"type": "Identifier",
"start": 1091,
"end": 1100,
"loc": {
"start": {
"line": 31,
"column": 21
},
"end": {
"line": 31,
"column": 30
},
"identifierName": "loadCount"
},
"name": "loadCount"
},
"computed": false
}
}
},
"alternate": {
"type": "ExpressionStatement",
"start": 1137,
"end": 1160,
"loc": {
"start": {
"line": 33,
"column": 16
},
"end": {
"line": 33,
"column": 39
}
},
"expression": {
"type": "UpdateExpression",
"start": 1137,
"end": 1159,
"loc": {
"start": {
"line": 33,
"column": 16
},
"end": {
"line": 33,
"column": 38
}
},
"operator": "++",
"prefix": false,
"argument": {
"type": "MemberExpression",
"start": 1137,
"end": 1157,
"loc": {
"start": {
"line": 33,
"column": 16
},
"end": {
"line": 33,
"column": 36
}
},
"object": {
"type": "ThisExpression",
"start": 1137,
"end": 1141,
"loc": {
"start": {
"line": 33,
"column": 16
},
"end": {
"line": 33,
"column": 20
}
}
},
"property": {
"type": "Identifier",
"start": 1142,
"end": 1157,
"loc": {
"start": {
"line": 33,
"column": 21
},
"end": {
"line": 33,
"column": 36
},
"identifierName": "loadCountQueued"
},
"name": "loadCountQueued"
},
"computed": false
}
}
}
},
{
"type": "IfStatement",
"start": 1174,
"end": 1260,
"loc": {
"start": {
"line": 35,
"column": 12
},
"end": {
"line": 36,
"column": 44
}
},
"test": {
"type": "BinaryExpression",
"start": 1178,
"end": 1214,
"loc": {
"start": {
"line": 35,
"column": 16
},
"end": {
"line": 35,
"column": 52
}
},
"left": {
"type": "MemberExpression",
"start": 1178,
"end": 1192,
"loc": {
"start": {
"line": 35,
"column": 16
},
"end": {
"line": 35,
"column": 30
}
},
"object": {
"type": "ThisExpression",
"start": 1178,
"end": 1182,
"loc": {
"start": {
"line": 35,
"column": 16
},
"end": {
"line": 35,
"column": 20
}
}
},
"property": {
"type": "Identifier",
"start": 1183,
"end": 1192,
"loc": {
"start": {
"line": 35,
"column": 21
},
"end": {
"line": 35,
"column": 30
},
"identifierName": "loadCount"
},
"name": "loadCount"
},
"computed": false
},
"operator": ">=",
"right": {
"type": "MemberExpression",
"start": 1196,
"end": 1214,
"loc": {
"start": {
"line": 35,
"column": 34
},
"end": {
"line": 35,
"column": 52
}
},