UNPKG

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,866 lines (1,865 loc) 74.1 kB
{ "type": "File", "start": 0, "end": 876, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 23, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 876, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 23, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 38, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 38 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 17, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 17 } }, "local": { "type": "Identifier", "start": 7, "end": 17, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 17 }, "identifierName": "GameObject" }, "name": "GameObject" } } ], "source": { "type": "StringLiteral", "start": 23, "end": 37, "loc": { "start": { "line": 1, "column": 23 }, "end": { "line": 1, "column": 37 } }, "extra": { "rawValue": "./GameObject", "raw": "\"./GameObject\"" }, "value": "./GameObject" } }, { "type": "ImportDeclaration", "start": 39, "end": 90, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 51 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 46, "end": 58, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 19 } }, "local": { "type": "Identifier", "start": 46, "end": 58, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 19 }, "identifierName": "SceneManager" }, "name": "SceneManager" } } ], "source": { "type": "StringLiteral", "start": 64, "end": 89, "loc": { "start": { "line": 2, "column": 25 }, "end": { "line": 2, "column": 50 } }, "extra": { "rawValue": "../manager/SceneManager", "raw": "'../manager/SceneManager'" }, "value": "../manager/SceneManager" } }, { "type": "ImportDeclaration", "start": 91, "end": 129, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 38 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 98, "end": 103, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 12 } }, "local": { "type": "Identifier", "start": 98, "end": 103, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 12 }, "identifierName": "Point" }, "name": "Point" } } ], "source": { "type": "StringLiteral", "start": 109, "end": 128, "loc": { "start": { "line": 3, "column": 18 }, "end": { "line": 3, "column": 37 } }, "extra": { "rawValue": "../internal/Point", "raw": "'../internal/Point'" }, "value": "../internal/Point" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * A GameObject which exists only on the current active scene.\n * When this object is instantiated, it registers with the current active scene\n * through the SceneManager.\n * \n ", "start": 131, "end": 314, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 10, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 315, "end": 876, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 23, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 330, "end": 876, "loc": { "start": { "line": 11, "column": 15 }, "end": { "line": 23, "column": 1 } }, "id": { "type": "Identifier", "start": 336, "end": 347, "loc": { "start": { "line": 11, "column": 21 }, "end": { "line": 11, "column": 32 }, "identifierName": "SceneObject" }, "name": "SceneObject", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 356, "end": 366, "loc": { "start": { "line": 11, "column": 41 }, "end": { "line": 11, "column": 51 }, "identifierName": "GameObject" }, "name": "GameObject" }, "body": { "type": "ClassBody", "start": 367, "end": 876, "loc": { "start": { "line": 11, "column": 52 }, "end": { "line": 23, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 674, "end": 874, "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 22, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 674, "end": 685, "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 19, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "AssignmentPattern", "start": 686, "end": 715, "loc": { "start": { "line": 19, "column": 16 }, "end": { "line": 19, "column": 45 } }, "left": { "type": "Identifier", "start": 686, "end": 694, "loc": { "start": { "line": 19, "column": 16 }, "end": { "line": 19, "column": 24 }, "identifierName": "position" }, "name": "position" }, "right": { "type": "NewExpression", "start": 697, "end": 715, "loc": { "start": { "line": 19, "column": 27 }, "end": { "line": 19, "column": 45 } }, "callee": { "type": "Identifier", "start": 701, "end": 706, "loc": { "start": { "line": 19, "column": 31 }, "end": { "line": 19, "column": 36 }, "identifierName": "Point" }, "name": "Point" }, "arguments": [ { "type": "NumericLiteral", "start": 707, "end": 708, "loc": { "start": { "line": 19, "column": 37 }, "end": { "line": 19, "column": 38 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, { "type": "NumericLiteral", "start": 710, "end": 711, "loc": { "start": { "line": 19, "column": 40 }, "end": { "line": 19, "column": 41 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, { "type": "NumericLiteral", "start": 713, "end": 714, "loc": { "start": { "line": 19, "column": 43 }, "end": { "line": 19, "column": 44 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } ] } }, { "type": "AssignmentPattern", "start": 717, "end": 744, "loc": { "start": { "line": 19, "column": 47 }, "end": { "line": 19, "column": 74 } }, "left": { "type": "Identifier", "start": 717, "end": 721, "loc": { "start": { "line": 19, "column": 47 }, "end": { "line": 19, "column": 51 }, "identifierName": "size" }, "name": "size" }, "right": { "type": "NewExpression", "start": 724, "end": 744, "loc": { "start": { "line": 19, "column": 54 }, "end": { "line": 19, "column": 74 } }, "callee": { "type": "Identifier", "start": 728, "end": 733, "loc": { "start": { "line": 19, "column": 58 }, "end": { "line": 19, "column": 63 }, "identifierName": "Point" }, "name": "Point" }, "arguments": [ { "type": "NumericLiteral", "start": 734, "end": 736, "loc": { "start": { "line": 19, "column": 64 }, "end": { "line": 19, "column": 66 } }, "extra": { "rawValue": 32, "raw": "32" }, "value": 32 }, { "type": "NumericLiteral", "start": 738, "end": 740, "loc": { "start": { "line": 19, "column": 68 }, "end": { "line": 19, "column": 70 } }, "extra": { "rawValue": 32, "raw": "32" }, "value": 32 }, { "type": "NumericLiteral", "start": 742, "end": 743, "loc": { "start": { "line": 19, "column": 72 }, "end": { "line": 19, "column": 73 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 } ] } }, { "type": "AssignmentPattern", "start": 746, "end": 758, "loc": { "start": { "line": 19, "column": 76 }, "end": { "line": 19, "column": 88 } }, "left": { "type": "Identifier", "start": 746, "end": 754, "loc": { "start": { "line": 19, "column": 76 }, "end": { "line": 19, "column": 84 }, "identifierName": "rotation" }, "name": "rotation" }, "right": { "type": "NumericLiteral", "start": 757, "end": 758, "loc": { "start": { "line": 19, "column": 87 }, "end": { "line": 19, "column": 88 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } } ], "body": { "type": "BlockStatement", "start": 760, "end": 874, "loc": { "start": { "line": 19, "column": 90 }, "end": { "line": 22, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 770, "end": 802, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 40 } }, "expression": { "type": "CallExpression", "start": 770, "end": 801, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 39 } }, "callee": { "type": "Super", "start": 770, "end": 775, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 20, "column": 13 } } }, "arguments": [ { "type": "Identifier", "start": 776, "end": 784, "loc": { "start": { "line": 20, "column": 14 }, "end": { "line": 20, "column": 22 }, "identifierName": "position" }, "name": "position" }, { "type": "Identifier", "start": 786, "end": 790, "loc": { "start": { "line": 20, "column": 24 }, "end": { "line": 20, "column": 28 }, "identifierName": "size" }, "name": "size" }, { "type": "Identifier", "start": 792, "end": 800, "loc": { "start": { "line": 20, "column": 30 }, "end": { "line": 20, "column": 38 }, "identifierName": "rotation" }, "name": "rotation" } ] } }, { "type": "ExpressionStatement", "start": 811, "end": 868, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 65 } }, "expression": { "type": "AssignmentExpression", "start": 811, "end": 867, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 64 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 811, "end": 826, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 23 } }, "object": { "type": "ThisExpression", "start": 811, "end": 815, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 12 } } }, "property": { "type": "Identifier", "start": 816, "end": 826, "loc": { "start": { "line": 21, "column": 13 }, "end": { "line": 21, "column": 23 }, "identifierName": "deregister" }, "name": "deregister" }, "computed": false }, "right": { "type": "CallExpression", "start": 829, "end": 867, "loc": { "start": { "line": 21, "column": 26 }, "end": { "line": 21, "column": 64 } }, "callee": { "type": "MemberExpression", "start": 829, "end": 861, "loc": { "start": { "line": 21, "column": 26 }, "end": { "line": 21, "column": 58 } }, "object": { "type": "Identifier", "start": 829, "end": 841, "loc": { "start": { "line": 21, "column": 26 }, "end": { "line": 21, "column": 38 }, "identifierName": "SceneManager" }, "name": "SceneManager" }, "property": { "type": "Identifier", "start": 842, "end": 861, "loc": { "start": { "line": 21, "column": 39 }, "end": { "line": 21, "column": 58 }, "identifierName": "registerSceneObject" }, "name": "registerSceneObject" }, "computed": false }, "arguments": [ { "type": "ThisExpression", "start": 862, "end": 866, "loc": { "start": { "line": 21, "column": 59 }, "end": { "line": 21, "column": 63 } } } ] } } } ], "directives": [] }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Default position, size and rotation of the Object.\n * \n * @param {Point} position A point of creation in the world.\n * @param {Point} size A point representing scale of the object.\n * @param {number} rotation A number representing angular rotation (in degrees).\n ", "start": 373, "end": 669, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 18, "column": 7 } } } ] } ] }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * A GameObject which exists only on the current active scene.\n * When this object is instantiated, it registers with the current active scene\n * through the SceneManager.\n * \n ", "start": 131, "end": 314, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 10, "column": 3 } } } ], "trailingComments": [] }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * A GameObject which exists only on the current active scene.\n * When this object is instantiated, it registers with the current active scene\n * through the SceneManager.\n * \n ", "start": 131, "end": 314, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 10, "column": 3 } } } ] } ], "directives": [] }, "comments": [ { "type": "CommentBlock", "value": "*\n * A GameObject which exists only on the current active scene.\n * When this object is instantiated, it registers with the current active scene\n * through the SceneManager.\n * \n ", "start": 131, "end": 314, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 10, "column": 3 } } }, { "type": "CommentBlock", "value": "*\n * Default position, size and rotation of the Object.\n * \n * @param {Point} position A point of creation in the world.\n * @param {Point} size A point representing scale of the object.\n * @param {number} rotation A number representing angular rotation (in degrees).\n ", "start": 373, "end": 669, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 18, "column": 7 } } } ], "tokens": [ { "type": { "label": "import", "keyword": "import", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "import", "start": 0, "end": 6, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 6 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "GameObject", "start": 7, "end": 17, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 17 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "from", "start": 18, "end": 22, "loc": { "start": { "line": 1, "column": 18 }, "end": { "line": 1, "column": 22 } } }, { "type": { "label": "string", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "./GameObject", "start": 23, "end": 37, "loc": { "start": { "line": 1, "column": 23 }, "end": { "line": 1, "column": 37 } } }, { "type": { "label": ";", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "start": 37, "end": 38, "loc": { "start": { "line": 1, "column": 37 }, "end": { "line": 1, "column": 38 } } }, { "type": { "label": "import", "keyword": "import", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "import", "start": 39, "end": 45, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 6 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "SceneManager", "start": 46, "end": 58, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 19 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "from", "start": 59, "end": 63, "loc": { "start": { "line": 2, "column": 20 }, "end": { "line": 2, "column": 24 } } }, { "type": { "label": "string", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "../manager/SceneManager", "start": 64, "end": 89, "loc": { "start": { "line": 2, "column": 25 }, "end": { "line": 2, "column": 50 } } }, { "type": { "label": ";", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "start": 89, "end": 90, "loc": { "start": { "line": 2, "column": 50 }, "end": { "line": 2, "column": 51 } } }, { "type": { "label": "import", "keyword": "import", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "import", "start": 91, "end": 97, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 6 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "Point", "start": 98, "end": 103, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 12 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "from", "start": 104, "end": 108, "loc": { "start": { "line": 3, "column": 13 }, "end": { "line": 3, "column": 17 } } }, { "type": { "label": "string", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "../internal/Point", "start": 109, "end": 128, "loc": { "start": { "line": 3, "column": 18 }, "end": { "line": 3, "column": 37 } } }, { "type": { "label": ";", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "start": 128, "end": 129, "loc": { "start": { "line": 3, "column": 37 }, "end": { "line": 3, "column": 38 } } }, { "type": "CommentBlock", "value": "*\n * A GameObject which exists only on the current active scene.\n * When this object is instantiated, it registers with the current active scene\n * through the SceneManager.\n * \n ", "start": 131, "end": 314, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 10, "column": 3 } } }, { "type": { "label": "export", "keyword": "export", "beforeExpr": false, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "export", "start": 315, "end": 321, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 6 } } }, { "type": { "label": "default", "keyword": "default", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "default", "start": 322, "end": 329, "loc": { "start": { "line": 11, "column": 7 }, "end": { "line": 11, "column": 14 } } }, { "type": { "label": "class", "keyword": "class", "beforeExpr": false, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "class", "start": 330, "end": 335, "loc": { "start": { "line": 11, "column": 15 }, "end": { "line": 11, "column": 20 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "SceneObject", "start": 336, "end": 347, "loc": { "start": { "line": 11, "column": 21 }, "end": { "line": 11, "column": 32 } } }, { "type": { "label": "extends", "keyword": "extends", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "extends", "start": 348, "end": 355, "loc": { "start": { "line": 11, "column": 33 }, "end": { "line": 11, "column": 40 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "GameObject", "start": 356, "end": 366, "loc": { "start": { "line": 11, "column": 41 }, "end": { "line": 11, "column": 51 } } }, { "type": { "label": "{", "beforeExpr": true, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "start": 367, "end": 368, "loc": { "start": { "line": 11, "column": 52 }, "end": { "line": 11, "column": 53 } } }, { "type": "CommentBlock", "value": "*\n * Default position, size and rotation of the Object.\n * \n * @param {Point} position A point of creation in the world.\n * @param {Point} size A point representing scale of the object.\n * @param {number} rotation A number representing angular rotation (in degrees).\n ", "start": 373, "end": 669, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 18, "column": 7 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "constructor", "start": 674, "end": 685, "loc": { "start": { "line": 19, "column": 4 }, "end": { "line": 19, "column": 15 } } }, { "type": { "label": "(", "beforeExpr": true, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "start": 685, "end": 686, "loc": { "start": { "line": 19, "column": 15 }, "end": { "line": 19, "column": 16 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "position", "start": 686, "end": 694, "loc": { "start": { "line": 19, "column": 16 }, "end": { "line": 19, "column": 24 } } }, { "type": { "label": "=", "beforeExpr": true, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": true, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "=", "start": 695, "end": 696, "loc": { "start": { "line": 19, "column": 25 }, "end": { "line": 19, "column": 26 } } }, { "type": { "label": "new", "keyword": "new", "beforeExpr": true, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "value": "new", "start": 697, "end": 700, "loc": { "start": { "line": 19, "column": 27 }, "end": { "line": 19, "column": 30 } } }, { "type": { "label": "name", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "value": "Point", "start": 701, "end": 706, "loc": { "start": { "line": 19, "column": 31 }, "end": { "line": 19, "column": 36 } } }, { "type": { "label": "(", "beforeExpr": true, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null }, "start": 706, "end": 707, "loc": { "start": { "line": 19, "column": 36 }, "end": { "line": 19, "column": 37 } } }, { "type": { "label": "num", "beforeExpr": false, "startsExpr": true, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false,