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,354 lines (1,353 loc) • 327 kB
JSON
{
"type": "File",
"start": 0,
"end": 2630,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 87,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 2630,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 87,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "ExportDefaultDeclaration",
"start": 224,
"end": 2630,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 87,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 239,
"end": 2630,
"loc": {
"start": {
"line": 6,
"column": 15
},
"end": {
"line": 87,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 245,
"end": 253,
"loc": {
"start": {
"line": 6,
"column": 21
},
"end": {
"line": 6,
"column": 29
},
"identifierName": "Messager"
},
"name": "Messager",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 254,
"end": 2630,
"loc": {
"start": {
"line": 6,
"column": 30
},
"end": {
"line": 87,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 260,
"end": 370,
"loc": {
"start": {
"line": 7,
"column": 4
},
"end": {
"line": 11,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 260,
"end": 271,
"loc": {
"start": {
"line": 7,
"column": 4
},
"end": {
"line": 7,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor"
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 274,
"end": 370,
"loc": {
"start": {
"line": 7,
"column": 18
},
"end": {
"line": 11,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 284,
"end": 311,
"loc": {
"start": {
"line": 8,
"column": 8
},
"end": {
"line": 8,
"column": 35
}
},
"expression": {
"type": "AssignmentExpression",
"start": 284,
"end": 310,
"loc": {
"start": {
"line": 8,
"column": 8
},
"end": {
"line": 8,
"column": 34
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 284,
"end": 306,
"loc": {
"start": {
"line": 8,
"column": 8
},
"end": {
"line": 8,
"column": 30
}
},
"object": {
"type": "ThisExpression",
"start": 284,
"end": 288,
"loc": {
"start": {
"line": 8,
"column": 8
},
"end": {
"line": 8,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 289,
"end": 306,
"loc": {
"start": {
"line": 8,
"column": 13
},
"end": {
"line": 8,
"column": 30
},
"identifierName": "listenerIDCounter"
},
"name": "listenerIDCounter"
},
"computed": false
},
"right": {
"type": "NumericLiteral",
"start": 309,
"end": 310,
"loc": {
"start": {
"line": 8,
"column": 33
},
"end": {
"line": 8,
"column": 34
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
},
{
"type": "ExpressionStatement",
"start": 320,
"end": 335,
"loc": {
"start": {
"line": 9,
"column": 8
},
"end": {
"line": 9,
"column": 23
}
},
"expression": {
"type": "AssignmentExpression",
"start": 320,
"end": 334,
"loc": {
"start": {
"line": 9,
"column": 8
},
"end": {
"line": 9,
"column": 22
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 320,
"end": 329,
"loc": {
"start": {
"line": 9,
"column": 8
},
"end": {
"line": 9,
"column": 17
}
},
"object": {
"type": "ThisExpression",
"start": 320,
"end": 324,
"loc": {
"start": {
"line": 9,
"column": 8
},
"end": {
"line": 9,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 325,
"end": 329,
"loc": {
"start": {
"line": 9,
"column": 13
},
"end": {
"line": 9,
"column": 17
},
"identifierName": "data"
},
"name": "data"
},
"computed": false
},
"right": {
"type": "ObjectExpression",
"start": 332,
"end": 334,
"loc": {
"start": {
"line": 9,
"column": 20
},
"end": {
"line": 9,
"column": 22
}
},
"properties": []
}
}
},
{
"type": "ExpressionStatement",
"start": 344,
"end": 364,
"loc": {
"start": {
"line": 10,
"column": 8
},
"end": {
"line": 10,
"column": 28
}
},
"expression": {
"type": "AssignmentExpression",
"start": 344,
"end": 363,
"loc": {
"start": {
"line": 10,
"column": 8
},
"end": {
"line": 10,
"column": 27
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 344,
"end": 358,
"loc": {
"start": {
"line": 10,
"column": 8
},
"end": {
"line": 10,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 344,
"end": 348,
"loc": {
"start": {
"line": 10,
"column": 8
},
"end": {
"line": 10,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 349,
"end": 358,
"loc": {
"start": {
"line": 10,
"column": 13
},
"end": {
"line": 10,
"column": 22
},
"identifierName": "listeners"
},
"name": "listeners"
},
"computed": false
},
"right": {
"type": "ObjectExpression",
"start": 361,
"end": 363,
"loc": {
"start": {
"line": 10,
"column": 25
},
"end": {
"line": 10,
"column": 27
}
},
"properties": []
}
}
}
],
"directives": [],
"trailingComments": null
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Updates the data at a specific location in the Messager storage dictionary.\n * If there are listeners, notify them.\n * \n * @param {string} key Dictionary key name.\n * @param {*} data Data to set.\n ",
"start": 376,
"end": 606,
"loc": {
"start": {
"line": 13,
"column": 4
},
"end": {
"line": 19,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 611,
"end": 802,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 27,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 611,
"end": 614,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 7
},
"identifierName": "set"
},
"name": "set",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 615,
"end": 618,
"loc": {
"start": {
"line": 20,
"column": 8
},
"end": {
"line": 20,
"column": 11
},
"identifierName": "key"
},
"name": "key"
},
{
"type": "Identifier",
"start": 620,
"end": 624,
"loc": {
"start": {
"line": 20,
"column": 13
},
"end": {
"line": 20,
"column": 17
},
"identifierName": "data"
},
"name": "data"
}
],
"body": {
"type": "BlockStatement",
"start": 626,
"end": 802,
"loc": {
"start": {
"line": 20,
"column": 19
},
"end": {
"line": 27,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 636,
"end": 658,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 30
}
},
"expression": {
"type": "AssignmentExpression",
"start": 636,
"end": 657,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 29
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 636,
"end": 650,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 22
}
},
"object": {
"type": "MemberExpression",
"start": 636,
"end": 645,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 17
}
},
"object": {
"type": "ThisExpression",
"start": 636,
"end": 640,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 641,
"end": 645,
"loc": {
"start": {
"line": 21,
"column": 13
},
"end": {
"line": 21,
"column": 17
},
"identifierName": "data"
},
"name": "data"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 646,
"end": 649,
"loc": {
"start": {
"line": 21,
"column": 18
},
"end": {
"line": 21,
"column": 21
},
"identifierName": "key"
},
"name": "key"
},
"computed": true
},
"right": {
"type": "Identifier",
"start": 653,
"end": 657,
"loc": {
"start": {
"line": 21,
"column": 25
},
"end": {
"line": 21,
"column": 29
},
"identifierName": "data"
},
"name": "data"
}
}
},
{
"type": "IfStatement",
"start": 667,
"end": 796,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 26,
"column": 9
}
},
"test": {
"type": "BinaryExpression",
"start": 671,
"end": 698,
"loc": {
"start": {
"line": 22,
"column": 12
},
"end": {
"line": 22,
"column": 39
}
},
"left": {
"type": "MemberExpression",
"start": 671,
"end": 690,
"loc": {
"start": {
"line": 22,
"column": 12
},
"end": {
"line": 22,
"column": 31
}
},
"object": {
"type": "MemberExpression",
"start": 671,
"end": 685,
"loc": {
"start": {
"line": 22,
"column": 12
},
"end": {
"line": 22,
"column": 26
}
},
"object": {
"type": "ThisExpression",
"start": 671,
"end": 675,
"loc": {
"start": {
"line": 22,
"column": 12
},
"end": {
"line": 22,
"column": 16
}
}
},
"property": {
"type": "Identifier",
"start": 676,
"end": 685,
"loc": {
"start": {
"line": 22,
"column": 17
},
"end": {
"line": 22,
"column": 26
},
"identifierName": "listeners"
},
"name": "listeners"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 686,
"end": 689,
"loc": {
"start": {
"line": 22,
"column": 27
},
"end": {
"line": 22,
"column": 30
},
"identifierName": "key"
},
"name": "key"
},
"computed": true
},
"operator": "==",
"right": {
"type": "NullLiteral",
"start": 694,
"end": 698,
"loc": {
"start": {
"line": 22,
"column": 35
},
"end": {
"line": 22,
"column": 39
}
}
}
},
"consequent": {
"type": "BlockStatement",
"start": 700,
"end": 749,
"loc": {
"start": {
"line": 22,
"column": 41
},
"end": {
"line": 24,
"column": 9
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 714,
"end": 739,
"loc": {
"start": {
"line": 23,
"column": 12
},
"end": {
"line": 23,
"column": 37
}
},
"expression": {
"type": "AssignmentExpression",
"start": 714,
"end": 738,
"loc": {
"start": {
"line": 23,
"column": 12
},
"end": {
"line": 23,
"column": 36
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 714,
"end": 733,
"loc": {
"start": {
"line": 23,
"column": 12
},
"end": {
"line": 23,
"column": 31
}
},
"object": {
"type": "MemberExpression",
"start": 714,
"end": 728,
"loc": {
"start": {
"line": 23,
"column": 12
},
"end": {
"line": 23,
"column": 26
}
},
"object": {
"type": "ThisExpression",
"start": 714,
"end": 718,
"loc": {
"start": {
"line": 23,
"column": 12
},
"end": {
"line": 23,
"column": 16
}
}
},
"property": {
"type": "Identifier",
"start": 719,
"end": 728,
"loc": {
"start": {
"line": 23,
"column": 17
},
"end": {
"line": 23,
"column": 26
},
"identifierName": "listeners"
},
"name": "listeners"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 729,
"end": 732,
"loc": {
"start": {
"line": 23,
"column": 27
},
"end": {
"line": 23,
"column": 30
},
"identifierName": "key"
},
"name": "key"
},
"computed": true
},
"right": {
"type": "ArrayExpression",
"start": 736,
"end": 738,
"loc": {
"start": {
"line": 23,
"column": 34
},
"end": {
"line": 23,
"column": 36
}
},
"elements": []
}
}
}
],
"directives": []
},
"alternate": {
"type": "BlockStatement",
"start": 755,
"end": 796,
"loc": {
"start": {
"line": 24,
"column": 15
},
"end": {
"line": 26,
"column": 9
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 769,
"end": 786,
"loc": {
"start": {
"line": 25,
"column": 12
},
"end": {
"line": 25,
"column": 29
}
},
"expression": {
"type": "CallExpression",
"start": 769,
"end": 785,
"loc": {
"start": {
"line": 25,
"column": 12
},
"end": {
"line": 25,
"column": 28
}
},
"callee": {
"type": "MemberExpression",
"start": 769,
"end": 780,
"loc": {
"start": {
"line": 25,
"column": 12
},
"end": {
"line": 25,
"column": 23
}
},
"object": {
"type": "ThisExpression",
"start": 769,
"end": 773,
"loc": {
"start": {
"line": 25,
"column": 12
},
"end": {
"line": 25,
"column": 16
}
}
},
"property": {
"type": "Identifier",
"start": 774,
"end": 780,
"loc": {
"start": {
"line": 25,
"column": 17
},
"end": {
"line": 25,
"column": 23
},
"identifierName": "notify"
},
"name": "notify"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 781,
"end": 784,
"loc": {
"start": {
"line": 25,
"column": 24
},
"end": {
"line": 25,
"column": 27
},
"identifierName": "key"
},
"name": "key"
}
]
}
}
],
"directives": []
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Updates the data at a specific location in the Messager storage dictionary.\n * If there are listeners, notify them.\n * \n * @param {string} key Dictionary key name.\n * @param {*} data Data to set.\n ",
"start": 376,
"end": 606,
"loc": {
"start": {
"line": 13,
"column": 4
},
"end": {
"line": 19,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Notifies all listeners currently waiting on updates at\n * the location of the dictionary key.\n * \n * @param {string} key Dictionary key name.\n ",
"start": 808,
"end": 980,
"loc": {
"start": {
"line": 29,
"column": 4
},
"end": {
"line": 34,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 985,
"end": 1138,
"loc": {
"start": {
"line": 35,
"column": 4
},
"end": {
"line": 39,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 985,
"end": 991,
"loc": {
"start": {
"line": 35,
"column": 4
},
"end": {
"line": 35,
"column": 10
},
"identifierName": "notify"
},
"name": "notify",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 992,
"end": 995,
"loc": {
"start": {
"line": 35,
"column": 11
},
"end": {
"line": 35,
"column": 14
},
"identifierName": "key"
},
"name": "key"
}
],
"body": {
"type": "BlockStatement",
"start": 997,
"end": 1138,
"loc": {
"start": {
"line": 35,
"column": 16
},
"end": {
"line": 39,
"column": 5
}
},
"body": [
{
"type": "ForStatement",
"start": 1007,
"end": 1132,
"loc": {
"start": {
"line": 36,
"column": 8
},
"end": {
"line": 38,
"column": 9
}
},
"init": {
"type": "VariableDeclaration",
"start": 1012,
"end": 1021,
"loc": {
"start": {
"line": 36,
"column": 13
},
"end": {
"line": 36,
"column": 22
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 1016,
"end": 1021,
"loc": {
"start": {
"line": 36,
"column": 17
},
"end": {
"line": 36,
"column": 22
}
},
"id": {
"type": "Identifier",
"start": 1016,
"end": 1017,
"loc": {
"start": {
"line": 36,
"column": 17
},
"end": {
"line": 36,
"column": 18
},
"identifierName": "i"
},
"name": "i"
},
"init": {
"type": "NumericLiteral",
"start": 1020,
"end": 1021,
"loc": {
"start": {
"line": 36,
"column": 21
},
"end": {
"line": 36,
"column": 22
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
],
"kind": "let"
},
"test": {
"type": "BinaryExpression",
"start": 1023,
"end": 1053,
"loc": {
"start": {
"line": 36,
"column": 24
},
"end": {
"line": 36,
"column": 54
}
},
"left": {
"type": "Identifier",
"start": 1023,
"end": 1024,
"loc": {
"start": {
"line": 36,
"column": 24
},
"end": {
"line": 36,
"column": 25
},
"identifierName": "i"
},
"name": "i"
},
"operator": "<",
"right": {
"type": "MemberExpression",
"start": 1027,
"end": 1053,
"loc": {
"start": {
"line": 36,
"column": 28
},
"end": {
"line": 36,
"column": 54
}
},
"object": {
"type": "MemberExpression",
"start": 1027,
"end": 1046,
"loc": {
"start": {
"line": 36,
"column": 28
},
"end": {
"line": 36,
"column": 47
}
},
"object": {
"type": "MemberExpression",
"start": 1027,
"end": 1041,
"loc": {
"start": {
"line": 36,
"column": 28
},
"end": {
"line": 36,
"column": 42
}
},
"object": {
"type": "ThisExpression",
"start": 1027,
"end": 1031,
"loc": {
"start": {
"line": 36,
"column": 28
},
"end": {
"line": 36,
"column": 32
}
}
},
"property": {