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,344 lines (1,343 loc) • 296 kB
JSON
{
"type": "File",
"start": 0,
"end": 2154,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 74,
"column": 33
}
},
"program": {
"type": "Program",
"start": 0,
"end": 2154,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 74,
"column": 33
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 14
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "Manager"
},
"name": "Manager"
}
}
],
"source": {
"type": "StringLiteral",
"start": 20,
"end": 31,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 31
}
},
"extra": {
"rawValue": "./Manager",
"raw": "'./Manager'"
},
"value": "./Manager"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Manages all Persistent Objects in the Engine. A PersistentObject is a child of \n * GameObject, and sibling of SceneObjects.\n * \n * PersistentObjects exist and update in all scenes, changing scenes will not inturrupt this object.\n ",
"start": 34,
"end": 273,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 8,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 274,
"end": 2001,
"loc": {
"start": {
"line": 9,
"column": 0
},
"end": {
"line": 68,
"column": 1
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "ClassDeclaration",
"start": 281,
"end": 2001,
"loc": {
"start": {
"line": 9,
"column": 7
},
"end": {
"line": 68,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 287,
"end": 305,
"loc": {
"start": {
"line": 9,
"column": 13
},
"end": {
"line": 9,
"column": 31
},
"identifierName": "_PersistentManager"
},
"name": "_PersistentManager",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 314,
"end": 321,
"loc": {
"start": {
"line": 9,
"column": 40
},
"end": {
"line": 9,
"column": 47
},
"identifierName": "Manager"
},
"name": "Manager"
},
"body": {
"type": "ClassBody",
"start": 322,
"end": 2001,
"loc": {
"start": {
"line": 9,
"column": 48
},
"end": {
"line": 68,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 328,
"end": 403,
"loc": {
"start": {
"line": 10,
"column": 4
},
"end": {
"line": 13,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 328,
"end": 339,
"loc": {
"start": {
"line": 10,
"column": 4
},
"end": {
"line": 10,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor"
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 342,
"end": 403,
"loc": {
"start": {
"line": 10,
"column": 18
},
"end": {
"line": 13,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 352,
"end": 360,
"loc": {
"start": {
"line": 11,
"column": 8
},
"end": {
"line": 11,
"column": 16
}
},
"expression": {
"type": "CallExpression",
"start": 352,
"end": 359,
"loc": {
"start": {
"line": 11,
"column": 8
},
"end": {
"line": 11,
"column": 15
}
},
"callee": {
"type": "Super",
"start": 352,
"end": 357,
"loc": {
"start": {
"line": 11,
"column": 8
},
"end": {
"line": 11,
"column": 13
}
}
},
"arguments": []
}
},
{
"type": "ExpressionStatement",
"start": 369,
"end": 397,
"loc": {
"start": {
"line": 12,
"column": 8
},
"end": {
"line": 12,
"column": 36
}
},
"expression": {
"type": "AssignmentExpression",
"start": 369,
"end": 396,
"loc": {
"start": {
"line": 12,
"column": 8
},
"end": {
"line": 12,
"column": 35
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 369,
"end": 391,
"loc": {
"start": {
"line": 12,
"column": 8
},
"end": {
"line": 12,
"column": 30
}
},
"object": {
"type": "ThisExpression",
"start": 369,
"end": 373,
"loc": {
"start": {
"line": 12,
"column": 8
},
"end": {
"line": 12,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 374,
"end": 391,
"loc": {
"start": {
"line": 12,
"column": 13
},
"end": {
"line": 12,
"column": 30
},
"identifierName": "persistentObjects"
},
"name": "persistentObjects"
},
"computed": false
},
"right": {
"type": "ObjectExpression",
"start": 394,
"end": 396,
"loc": {
"start": {
"line": 12,
"column": 33
},
"end": {
"line": 12,
"column": 35
}
},
"properties": []
}
}
}
],
"directives": [],
"trailingComments": null
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * When a PersistentObject is created, it is assigned to the PersistentManager through this function.\n * The manager will keep reference to the Object and handle Engine events.\n * \n * @param {persistentObject} persistentObject A PersistentObject.\n ",
"start": 409,
"end": 683,
"loc": {
"start": {
"line": 15,
"column": 4
},
"end": {
"line": 20,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 688,
"end": 960,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 27,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 688,
"end": 712,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 21,
"column": 28
},
"identifierName": "registerPersistentObject"
},
"name": "registerPersistentObject",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 713,
"end": 729,
"loc": {
"start": {
"line": 21,
"column": 29
},
"end": {
"line": 21,
"column": 45
},
"identifierName": "persistentObject"
},
"name": "persistentObject"
}
],
"body": {
"type": "BlockStatement",
"start": 731,
"end": 960,
"loc": {
"start": {
"line": 21,
"column": 47
},
"end": {
"line": 27,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 741,
"end": 804,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 71
}
},
"expression": {
"type": "AssignmentExpression",
"start": 741,
"end": 803,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 70
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 741,
"end": 784,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 51
}
},
"object": {
"type": "MemberExpression",
"start": 741,
"end": 763,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 30
}
},
"object": {
"type": "ThisExpression",
"start": 741,
"end": 745,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 746,
"end": 763,
"loc": {
"start": {
"line": 22,
"column": 13
},
"end": {
"line": 22,
"column": 30
},
"identifierName": "persistentObjects"
},
"name": "persistentObjects"
},
"computed": false
},
"property": {
"type": "MemberExpression",
"start": 764,
"end": 783,
"loc": {
"start": {
"line": 22,
"column": 31
},
"end": {
"line": 22,
"column": 50
}
},
"object": {
"type": "Identifier",
"start": 764,
"end": 780,
"loc": {
"start": {
"line": 22,
"column": 31
},
"end": {
"line": 22,
"column": 47
},
"identifierName": "persistentObject"
},
"name": "persistentObject"
},
"property": {
"type": "Identifier",
"start": 781,
"end": 783,
"loc": {
"start": {
"line": 22,
"column": 48
},
"end": {
"line": 22,
"column": 50
},
"identifierName": "id"
},
"name": "id"
},
"computed": false
},
"computed": true
},
"right": {
"type": "Identifier",
"start": 787,
"end": 803,
"loc": {
"start": {
"line": 22,
"column": 54
},
"end": {
"line": 22,
"column": 70
},
"identifierName": "persistentObject"
},
"name": "persistentObject"
}
}
},
{
"type": "VariableDeclaration",
"start": 813,
"end": 919,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 25,
"column": 9
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 817,
"end": 919,
"loc": {
"start": {
"line": 23,
"column": 12
},
"end": {
"line": 25,
"column": 9
}
},
"id": {
"type": "Identifier",
"start": 817,
"end": 835,
"loc": {
"start": {
"line": 23,
"column": 12
},
"end": {
"line": 23,
"column": 30
},
"identifierName": "deregisterCallback"
},
"name": "deregisterCallback"
},
"init": {
"type": "ArrowFunctionExpression",
"start": 838,
"end": 919,
"loc": {
"start": {
"line": 23,
"column": 33
},
"end": {
"line": 25,
"column": 9
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 844,
"end": 919,
"loc": {
"start": {
"line": 23,
"column": 39
},
"end": {
"line": 25,
"column": 9
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 858,
"end": 909,
"loc": {
"start": {
"line": 24,
"column": 12
},
"end": {
"line": 24,
"column": 63
}
},
"expression": {
"type": "UnaryExpression",
"start": 858,
"end": 908,
"loc": {
"start": {
"line": 24,
"column": 12
},
"end": {
"line": 24,
"column": 62
}
},
"operator": "delete",
"prefix": true,
"argument": {
"type": "MemberExpression",
"start": 865,
"end": 908,
"loc": {
"start": {
"line": 24,
"column": 19
},
"end": {
"line": 24,
"column": 62
}
},
"object": {
"type": "MemberExpression",
"start": 865,
"end": 887,
"loc": {
"start": {
"line": 24,
"column": 19
},
"end": {
"line": 24,
"column": 41
}
},
"object": {
"type": "ThisExpression",
"start": 865,
"end": 869,
"loc": {
"start": {
"line": 24,
"column": 19
},
"end": {
"line": 24,
"column": 23
}
}
},
"property": {
"type": "Identifier",
"start": 870,
"end": 887,
"loc": {
"start": {
"line": 24,
"column": 24
},
"end": {
"line": 24,
"column": 41
},
"identifierName": "persistentObjects"
},
"name": "persistentObjects"
},
"computed": false
},
"property": {
"type": "MemberExpression",
"start": 888,
"end": 907,
"loc": {
"start": {
"line": 24,
"column": 42
},
"end": {
"line": 24,
"column": 61
}
},
"object": {
"type": "Identifier",
"start": 888,
"end": 904,
"loc": {
"start": {
"line": 24,
"column": 42
},
"end": {
"line": 24,
"column": 58
},
"identifierName": "persistentObject"
},
"name": "persistentObject"
},
"property": {
"type": "Identifier",
"start": 905,
"end": 907,
"loc": {
"start": {
"line": 24,
"column": 59
},
"end": {
"line": 24,
"column": 61
},
"identifierName": "id"
},
"name": "id"
},
"computed": false
},
"computed": true
},
"extra": {
"parenthesizedArgument": false
}
}
}
],
"directives": []
}
}
}
],
"kind": "let"
},
{
"type": "ReturnStatement",
"start": 928,
"end": 954,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 34
}
},
"argument": {
"type": "Identifier",
"start": 935,
"end": 953,
"loc": {
"start": {
"line": 26,
"column": 15
},
"end": {
"line": 26,
"column": 33
},
"identifierName": "deregisterCallback"
},
"name": "deregisterCallback"
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * When a PersistentObject is created, it is assigned to the PersistentManager through this function.\n * The manager will keep reference to the Object and handle Engine events.\n * \n * @param {persistentObject} persistentObject A PersistentObject.\n ",
"start": 409,
"end": 683,
"loc": {
"start": {
"line": 15,
"column": 4
},
"end": {
"line": 20,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Calls update on all Persistent Objects.\n ",
"start": 966,
"end": 1024,
"loc": {
"start": {
"line": 29,
"column": 4
},
"end": {
"line": 31,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 1029,
"end": 1222,
"loc": {
"start": {
"line": 32,
"column": 4
},
"end": {
"line": 37,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 1029,
"end": 1035,
"loc": {
"start": {
"line": 32,
"column": 4
},
"end": {
"line": 32,
"column": 10
},
"identifierName": "update"
},
"name": "update",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 1038,
"end": 1222,
"loc": {
"start": {
"line": 32,
"column": 13
},
"end": {
"line": 37,
"column": 5
}
},
"body": [
{
"type": "VariableDeclaration",
"start": 1048,
"end": 1098,
"loc": {
"start": {
"line": 33,
"column": 8
},
"end": {
"line": 33,
"column": 58
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 1052,
"end": 1097,
"loc": {
"start": {
"line": 33,
"column": 12
},
"end": {
"line": 33,
"column": 57
}
},
"id": {
"type": "Identifier",
"start": 1052,
"end": 1059,
"loc": {
"start": {
"line": 33,
"column": 12
},
"end": {
"line": 33,
"column": 19
},
"identifierName": "objKeys"
},
"name": "objKeys"
},
"init": {
"type": "CallExpression",
"start": 1062,
"end": 1097,
"loc": {
"start": {
"line": 33,
"column": 22
},
"end": {
"line": 33,
"column": 57
}
},
"callee": {
"type": "MemberExpression",
"start": 1062,
"end": 1073,
"loc": {
"start": {
"line": 33,
"column": 22
},
"end": {
"line": 33,
"column": 33
}
},
"object": {
"type": "Identifier",
"start": 1062,
"end": 1068,
"loc": {
"start": {
"line": 33,
"column": 22
},
"end": {
"line": 33,
"column": 28
},
"identifierName": "Object"
},
"name": "Object"
},
"property": {
"type": "Identifier",
"start": 1069,
"end": 1073,
"loc": {
"start": {
"line": 33,
"column": 29
},
"end": {
"line": 33,
"column": 33
},
"identifierName": "keys"
},
"name": "keys"
},
"computed": false
},
"arguments": [
{
"type": "MemberExpression",
"start": 1074,
"end": 1096,
"loc": {
"start": {
"line": 33,
"column": 34
},
"end": {
"line": 33,
"column": 56
}
},
"object": {
"type": "ThisExpression",
"start": 1074,
"end": 1078,
"loc": {
"start": {
"line": 33,
"column": 34
},
"end": {
"line": 33,
"column": 38
}
}
},
"property": {
"type": "Identifier",
"start": 1079,
"end": 1096,
"loc": {
"start": {
"line": 33,
"column": 39
},
"end": {
"line": 33,
"column": 56
},
"identifierName": "persistentObjects"
},
"name": "persistentObjects"
},
"computed": false
}
]
}
}
],
"kind": "let"
},
{
"type": "ForStatement",
"start": 1107,
"end": 1216,
"loc": {
"start": {
"line": 34,
"column": 8
},
"end": {
"line": 36,
"column": 9
}
},
"init": {
"type": "VariableDeclaration",
"start": 1112,
"end": 1121,
"loc": {
"start": {
"line": 34,
"column": 13
},
"end": {
"line": 34,
"column": 22
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 1116,
"end": 1121,
"loc": {
"start": {
"line": 34,
"column": 17
},
"end": {
"line": 34,
"column": 22
}
},
"id": {
"type": "Identifier",
"start": 1116,
"end": 1117,
"loc": {
"start": {
"line": 34,
"column": 17
},
"end": {
"line": 34,
"column": 18
},
"identifierName": "i"
},
"name": "i"
},
"init": {
"type": "NumericLiteral",
"start": 1120,
"end": 1121,
"loc": {
"start": {
"line": 34,
"column": 21
},
"end": {
"line": 34,
"column": 22
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
],
"kind": "let"
},
"test": {
"type": "BinaryExpression",
"start": 1123,
"end": 1141,
"loc": {
"start": {
"line": 34,
"column": 24
},
"end": {
"line": 34,
"column": 42
}
},
"left": {
"type": "Identifier",
"start": 1123,
"end": 1124,
"loc": {
"start": {
"line": 34,
"column": 24
},
"end": {
"line": 34,
"column": 25
},
"identifierName": "i"
},
"name": "i"
},
"operator": "<",
"right": {
"type": "MemberExpression",
"start": 1127,
"end": 1141,
"loc": {
"start": {
"line": 34,
"column": 28
},
"end": {
"line": 34,
"column": 42
}
},
"object": {
"type": "Identifier",
"start": 1127,
"end": 1134,
"loc": {
"start": {
"line": 34,
"column": 28
},
"end": {
"line": 34,
"column": 35
},
"identifierName": "objKeys"
},
"name": "objKeys"
},
"property": {
"type": "Identifier",
"start": 1135,
"end": 1141,
"loc": {
"start": {
"line": 34,
"column": 36
},
"end": {
"line": 34,
"column": 42
},
"identifierName": "length"
},
"name": "length"