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,321 lines (1,320 loc) 278 kB
{ "type": "File", "start": 0, "end": 2659, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 75, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 2659, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 75, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 44, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 44 } }, "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": "Updateable" }, "name": "Updateable" } } ], "source": { "type": "StringLiteral", "start": 23, "end": 43, "loc": { "start": { "line": 1, "column": 23 }, "end": { "line": 1, "column": 43 } }, "extra": { "rawValue": "../base/Updateable", "raw": "'../base/Updateable'" }, "value": "../base/Updateable" } }, { "type": "ImportDeclaration", "start": 45, "end": 84, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 39 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 54, "end": 65, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 20 } }, "imported": { "type": "Identifier", "start": 54, "end": 65, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 20 }, "identifierName": "SceneObject" }, "name": "SceneObject" }, "local": { "type": "Identifier", "start": 54, "end": 65, "loc": { "start": { "line": 2, "column": 9 }, "end": { "line": 2, "column": 20 }, "identifierName": "SceneObject" }, "name": "SceneObject" } } ], "source": { "type": "StringLiteral", "start": 73, "end": 83, "loc": { "start": { "line": 2, "column": 28 }, "end": { "line": 2, "column": 38 } }, "extra": { "rawValue": "../entry", "raw": "'../entry'" }, "value": "../entry" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Baseclass for all scenes. When creating a new scene, it should inherit this\n * class. \n * Scenes keep track of their scene objects and viewports. The scene baseclass has\n * functions for registering these with the scene.\n ", "start": 86, "end": 317, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 9, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 318, "end": 2659, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 75, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 333, "end": 2659, "loc": { "start": { "line": 10, "column": 15 }, "end": { "line": 75, "column": 1 } }, "id": { "type": "Identifier", "start": 339, "end": 344, "loc": { "start": { "line": 10, "column": 21 }, "end": { "line": 10, "column": 26 }, "identifierName": "Scene" }, "name": "Scene", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 353, "end": 363, "loc": { "start": { "line": 10, "column": 35 }, "end": { "line": 10, "column": 45 }, "identifierName": "Updateable" }, "name": "Updateable" }, "body": { "type": "ClassBody", "start": 364, "end": 2659, "loc": { "start": { "line": 10, "column": 46 }, "end": { "line": 75, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 438, "end": 573, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 20, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 438, "end": 449, "loc": { "start": { "line": 15, "column": 4 }, "end": { "line": 15, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 452, "end": 573, "loc": { "start": { "line": 15, "column": 18 }, "end": { "line": 20, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 462, "end": 470, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 16 } }, "expression": { "type": "CallExpression", "start": 462, "end": 469, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 15 } }, "callee": { "type": "Super", "start": 462, "end": 467, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 13 } } }, "arguments": [] } }, { "type": "ExpressionStatement", "start": 479, "end": 506, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 35 } }, "expression": { "type": "AssignmentExpression", "start": 479, "end": 505, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 34 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 479, "end": 501, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 30 } }, "object": { "type": "ThisExpression", "start": 479, "end": 483, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 12 } } }, "property": { "type": "Identifier", "start": 484, "end": 501, "loc": { "start": { "line": 17, "column": 13 }, "end": { "line": 17, "column": 30 }, "identifierName": "viewportIDCounter" }, "name": "viewportIDCounter" }, "computed": false }, "right": { "type": "NumericLiteral", "start": 504, "end": 505, "loc": { "start": { "line": 17, "column": 33 }, "end": { "line": 17, "column": 34 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } } }, { "type": "ExpressionStatement", "start": 515, "end": 538, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 31 } }, "expression": { "type": "AssignmentExpression", "start": 515, "end": 537, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 30 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 515, "end": 532, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 25 } }, "object": { "type": "ThisExpression", "start": 515, "end": 519, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 12 } } }, "property": { "type": "Identifier", "start": 520, "end": 532, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 18, "column": 25 }, "identifierName": "sceneObjects" }, "name": "sceneObjects" }, "computed": false }, "right": { "type": "ArrayExpression", "start": 535, "end": 537, "loc": { "start": { "line": 18, "column": 28 }, "end": { "line": 18, "column": 30 } }, "elements": [] } } }, { "type": "ExpressionStatement", "start": 547, "end": 567, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 28 } }, "expression": { "type": "AssignmentExpression", "start": 547, "end": 566, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 27 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 547, "end": 561, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 22 } }, "object": { "type": "ThisExpression", "start": 547, "end": 551, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 12 } } }, "property": { "type": "Identifier", "start": 552, "end": 561, "loc": { "start": { "line": 19, "column": 13 }, "end": { "line": 19, "column": 22 }, "identifierName": "viewports" }, "name": "viewports" }, "computed": false }, "right": { "type": "ArrayExpression", "start": 564, "end": 566, "loc": { "start": { "line": 19, "column": 25 }, "end": { "line": 19, "column": 27 } }, "elements": [] } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Builds the SceneObjects and Viewports list.\n ", "start": 371, "end": 433, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 14, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * When a SceneObject is created, it is routed through the SceneManager to the current\n * active scene to this function. The SceneObject will register with the scene to be referenced\n * on update/pause/destruct calls on a scene specific basis.\n * \n * @param {SceneObject} sceneObject A SceneObject to register.\n ", "start": 579, "end": 921, "loc": { "start": { "line": 22, "column": 4 }, "end": { "line": 28, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 926, "end": 1318, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 39, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 926, "end": 945, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 29, "column": 23 }, "identifierName": "registerSceneObject" }, "name": "registerSceneObject", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 946, "end": 957, "loc": { "start": { "line": 29, "column": 24 }, "end": { "line": 29, "column": 35 }, "identifierName": "sceneObject" }, "name": "sceneObject" } ], "body": { "type": "BlockStatement", "start": 959, "end": 1318, "loc": { "start": { "line": 29, "column": 37 }, "end": { "line": 39, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 969, "end": 1005, "loc": { "start": { "line": 30, "column": 8 }, "end": { "line": 30, "column": 44 } }, "expression": { "type": "CallExpression", "start": 969, "end": 1004, "loc": { "start": { "line": 30, "column": 8 }, "end": { "line": 30, "column": 43 } }, "callee": { "type": "MemberExpression", "start": 969, "end": 991, "loc": { "start": { "line": 30, "column": 8 }, "end": { "line": 30, "column": 30 } }, "object": { "type": "MemberExpression", "start": 969, "end": 986, "loc": { "start": { "line": 30, "column": 8 }, "end": { "line": 30, "column": 25 } }, "object": { "type": "ThisExpression", "start": 969, "end": 973, "loc": { "start": { "line": 30, "column": 8 }, "end": { "line": 30, "column": 12 } } }, "property": { "type": "Identifier", "start": 974, "end": 986, "loc": { "start": { "line": 30, "column": 13 }, "end": { "line": 30, "column": 25 }, "identifierName": "sceneObjects" }, "name": "sceneObjects" }, "computed": false }, "property": { "type": "Identifier", "start": 987, "end": 991, "loc": { "start": { "line": 30, "column": 26 }, "end": { "line": 30, "column": 30 }, "identifierName": "push" }, "name": "push" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 992, "end": 1003, "loc": { "start": { "line": 30, "column": 31 }, "end": { "line": 30, "column": 42 }, "identifierName": "sceneObject" }, "name": "sceneObject" } ] } }, { "type": "VariableDeclaration", "start": 1014, "end": 1277, "loc": { "start": { "line": 31, "column": 8 }, "end": { "line": 37, "column": 9 } }, "declarations": [ { "type": "VariableDeclarator", "start": 1018, "end": 1277, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 37, "column": 9 } }, "id": { "type": "Identifier", "start": 1018, "end": 1036, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 30 }, "identifierName": "deregisterCallback" }, "name": "deregisterCallback" }, "init": { "type": "ArrowFunctionExpression", "start": 1039, "end": 1277, "loc": { "start": { "line": 31, "column": 33 }, "end": { "line": 37, "column": 9 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 1045, "end": 1277, "loc": { "start": { "line": 31, "column": 39 }, "end": { "line": 37, "column": 9 } }, "body": [ { "type": "ForStatement", "start": 1059, "end": 1267, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 36, "column": 13 } }, "init": { "type": "VariableDeclaration", "start": 1064, "end": 1073, "loc": { "start": { "line": 32, "column": 17 }, "end": { "line": 32, "column": 26 } }, "declarations": [ { "type": "VariableDeclarator", "start": 1068, "end": 1073, "loc": { "start": { "line": 32, "column": 21 }, "end": { "line": 32, "column": 26 } }, "id": { "type": "Identifier", "start": 1068, "end": 1069, "loc": { "start": { "line": 32, "column": 21 }, "end": { "line": 32, "column": 22 }, "identifierName": "i" }, "name": "i" }, "init": { "type": "NumericLiteral", "start": 1072, "end": 1073, "loc": { "start": { "line": 32, "column": 25 }, "end": { "line": 32, "column": 26 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } } ], "kind": "let" }, "test": { "type": "BinaryExpression", "start": 1075, "end": 1103, "loc": { "start": { "line": 32, "column": 28 }, "end": { "line": 32, "column": 56 } }, "left": { "type": "Identifier", "start": 1075, "end": 1076, "loc": { "start": { "line": 32, "column": 28 }, "end": { "line": 32, "column": 29 }, "identifierName": "i" }, "name": "i" }, "operator": "<", "right": { "type": "MemberExpression", "start": 1079, "end": 1103, "loc": { "start": { "line": 32, "column": 32 }, "end": { "line": 32, "column": 56 } }, "object": { "type": "MemberExpression", "start": 1079, "end": 1096, "loc": { "start": { "line": 32, "column": 32 }, "end": { "line": 32, "column": 49 } }, "object": { "type": "ThisExpression", "start": 1079, "end": 1083, "loc": { "start": { "line": 32, "column": 32 }, "end": { "line": 32, "column": 36 } } }, "property": { "type": "Identifier", "start": 1084, "end": 1096, "loc": { "start": { "line": 32, "column": 37 }, "end": { "line": 32, "column": 49 }, "identifierName": "sceneObjects" }, "name": "sceneObjects" }, "computed": false }, "property": { "type": "Identifier", "start": 1097, "end": 1103, "loc": { "start": { "line": 32, "column": 50 }, "end": { "line": 32, "column": 56 }, "identifierName": "length" }, "name": "length" }, "computed": false } }, "update": { "type": "UpdateExpression", "start": 1105, "end": 1108, "loc": { "start": { "line": 32, "column": 58 }, "end": { "line": 32, "column": 61 } }, "operator": "++", "prefix": false, "argument": { "type": "Identifier", "start": 1105, "end": 1106, "loc": { "start": { "line": 32, "column": 58 }, "end": { "line": 32, "column": 59 }, "identifierName": "i" }, "name": "i" } }, "body": { "type": "BlockStatement", "start": 1110, "end": 1267, "loc": { "start": { "line": 32, "column": 63 }, "end": { "line": 36, "column": 13 } }, "body": [ { "type": "IfStatement", "start": 1128, "end": 1225, "loc": { "start": { "line": 33, "column": 16 }, "end": { "line": 34, "column": 51 } }, "test": { "type": "BinaryExpression", "start": 1132, "end": 1172, "loc": { "start": { "line": 33, "column": 20 }, "end": { "line": 33, "column": 60 } }, "left": { "type": "MemberExpression", "start": 1132, "end": 1155, "loc": { "start": { "line": 33, "column": 20 }, "end": { "line": 33, "column": 43 } }, "object": { "type": "MemberExpression", "start": 1132, "end": 1152, "loc": { "start": { "line": 33, "column": 20 }, "end": { "line": 33, "column": 40 } }, "object": { "type": "MemberExpression", "start": 1132, "end": 1149, "loc": { "start": { "line": 33, "column": 20 }, "end": { "line": 33, "column": 37 } }, "object": { "type": "ThisExpression", "start": 1132, "end": 1136, "loc": { "start": { "line": 33, "column": 20