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,601 lines (1,600 loc) 313 kB
{ "type": "File", "start": 0, "end": 2795, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 100, "column": 29 } }, "program": { "type": "Program", "start": 0, "end": 2795, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 100, "column": 29 } }, "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" } }, { "type": "ImportDeclaration", "start": 33, "end": 77, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 44 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 40, "end": 53, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 20 } }, "local": { "type": "Identifier", "start": 40, "end": 53, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 20 }, "identifierName": "RenderManager" }, "name": "RenderManager" } } ], "source": { "type": "StringLiteral", "start": 59, "end": 76, "loc": { "start": { "line": 2, "column": 26 }, "end": { "line": 2, "column": 43 } }, "extra": { "rawValue": "./RenderManager", "raw": "'./RenderManager'" }, "value": "./RenderManager" } }, { "type": "ImportDeclaration", "start": 78, "end": 124, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 46 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 85, "end": 99, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 21 } }, "local": { "type": "Identifier", "start": 85, "end": 99, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 21 }, "identifierName": "ProgramManager" }, "name": "ProgramManager" } } ], "source": { "type": "StringLiteral", "start": 105, "end": 123, "loc": { "start": { "line": 3, "column": 27 }, "end": { "line": 3, "column": 45 } }, "extra": { "rawValue": "./ProgramManager", "raw": "'./ProgramManager'" }, "value": "./ProgramManager" } }, { "type": "ImportDeclaration", "start": 125, "end": 167, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 42 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 132, "end": 144, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 19 } }, "local": { "type": "Identifier", "start": 132, "end": 144, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 19 }, "identifierName": "SceneManager" }, "name": "SceneManager" } } ], "source": { "type": "StringLiteral", "start": 150, "end": 166, "loc": { "start": { "line": 4, "column": 25 }, "end": { "line": 4, "column": 41 } }, "extra": { "rawValue": "./SceneManager", "raw": "'./SceneManager'" }, "value": "./SceneManager" } }, { "type": "ImportDeclaration", "start": 168, "end": 206, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 38 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 175, "end": 185, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 17 } }, "local": { "type": "Identifier", "start": 175, "end": 185, "loc": { "start": { "line": 5, "column": 7 }, "end": { "line": 5, "column": 17 }, "identifierName": "DOMManager" }, "name": "DOMManager" } } ], "source": { "type": "StringLiteral", "start": 191, "end": 205, "loc": { "start": { "line": 5, "column": 23 }, "end": { "line": 5, "column": 37 } }, "extra": { "rawValue": "./DOMManager", "raw": "'./DOMManager'" }, "value": "./DOMManager" } }, { "type": "ImportDeclaration", "start": 207, "end": 259, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 52 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 214, "end": 231, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 24 } }, "local": { "type": "Identifier", "start": 214, "end": 231, "loc": { "start": { "line": 6, "column": 7 }, "end": { "line": 6, "column": 24 }, "identifierName": "PersistentManager" }, "name": "PersistentManager" } } ], "source": { "type": "StringLiteral", "start": 237, "end": 258, "loc": { "start": { "line": 6, "column": 30 }, "end": { "line": 6, "column": 51 } }, "extra": { "rawValue": "./PersistentManager", "raw": "'./PersistentManager'" }, "value": "./PersistentManager" } }, { "type": "ImportDeclaration", "start": 260, "end": 302, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 42 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 267, "end": 279, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 19 } }, "local": { "type": "Identifier", "start": 267, "end": 279, "loc": { "start": { "line": 7, "column": 7 }, "end": { "line": 7, "column": 19 }, "identifierName": "InputManager" }, "name": "InputManager" } } ], "source": { "type": "StringLiteral", "start": 285, "end": 301, "loc": { "start": { "line": 7, "column": 25 }, "end": { "line": 7, "column": 41 } }, "extra": { "rawValue": "./InputManager", "raw": "'./InputManager'" }, "value": "./InputManager" } }, { "type": "ImportDeclaration", "start": 303, "end": 345, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 42 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 310, "end": 322, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 19 } }, "local": { "type": "Identifier", "start": 310, "end": 322, "loc": { "start": { "line": 8, "column": 7 }, "end": { "line": 8, "column": 19 }, "identifierName": "AudioManager" }, "name": "AudioManager" } } ], "source": { "type": "StringLiteral", "start": 328, "end": 344, "loc": { "start": { "line": 8, "column": 25 }, "end": { "line": 8, "column": 41 } }, "extra": { "rawValue": "./AudioManager", "raw": "'./AudioManager'" }, "value": "./AudioManager" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * A singleton & Manager.\n * \n * This class manages the core ECS system & game loop. It calls all other Managers\n * required to start. \n * \n * TODO: This system will be rewritten to allow Manager plugins to be added by the \n * user without editing the Engine.\n ", "start": 347, "end": 615, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 18, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "start": 616, "end": 2666, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 94, "column": 1 } }, "specifiers": [], "source": null, "declaration": { "type": "ClassDeclaration", "start": 623, "end": 2666, "loc": { "start": { "line": 19, "column": 7 }, "end": { "line": 94, "column": 1 } }, "id": { "type": "Identifier", "start": 629, "end": 643, "loc": { "start": { "line": 19, "column": 13 }, "end": { "line": 19, "column": 27 }, "identifierName": "_EngineManager" }, "name": "_EngineManager", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 652, "end": 659, "loc": { "start": { "line": 19, "column": 36 }, "end": { "line": 19, "column": 43 }, "identifierName": "Manager" }, "name": "Manager" }, "body": { "type": "ClassBody", "start": 660, "end": 2666, "loc": { "start": { "line": 19, "column": 44 }, "end": { "line": 94, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 666, "end": 810, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 25, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 666, "end": 677, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 20, "column": 15 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 680, "end": 810, "loc": { "start": { "line": 20, "column": 18 }, "end": { "line": 25, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 690, "end": 698, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 16 } }, "expression": { "type": "CallExpression", "start": 690, "end": 697, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 15 } }, "callee": { "type": "Super", "start": 690, "end": 695, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 21, "column": 13 } } }, "arguments": [] } }, { "type": "ExpressionStatement", "start": 707, "end": 730, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 31 } }, "expression": { "type": "AssignmentExpression", "start": 707, "end": 729, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 30 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 707, "end": 724, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 25 } }, "object": { "type": "ThisExpression", "start": 707, "end": 711, "loc": { "start": { "line": 22, "column": 8 }, "end": { "line": 22, "column": 12 } } }, "property": { "type": "Identifier", "start": 712, "end": 724, "loc": { "start": { "line": 22, "column": 13 }, "end": { "line": 22, "column": 25 }, "identifierName": "MS_PER_FRAME" }, "name": "MS_PER_FRAME" }, "computed": false }, "right": { "type": "NumericLiteral", "start": 727, "end": 729, "loc": { "start": { "line": 22, "column": 28 }, "end": { "line": 22, "column": 30 } }, "extra": { "rawValue": 20, "raw": "20" }, "value": 20 } } }, { "type": "ExpressionStatement", "start": 739, "end": 772, "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 23, "column": 41 } }, "expression": { "type": "AssignmentExpression", "start": 739, "end": 771, "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 23, "column": 40 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 739, "end": 764, "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 23, "column": 33 } }, "object": { "type": "ThisExpression", "start": 739, "end": 743, "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 23, "column": 12 } } }, "property": { "type": "Identifier", "start": 744, "end": 764, "loc": { "start": { "line": 23, "column": 13 }, "end": { "line": 23, "column": 33 }, "identifierName": "coreUpdateLoopHandle" }, "name": "coreUpdateLoopHandle" }, "computed": false }, "right": { "type": "NullLiteral", "start": 767, "end": 771, "loc": { "start": { "line": 23, "column": 36 }, "end": { "line": 23, "column": 40 } } } } }, { "type": "ExpressionStatement", "start": 781, "end": 804, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 31 } }, "expression": { "type": "AssignmentExpression", "start": 781, "end": 803, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 30 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 781, "end": 795, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 22 } }, "object": { "type": "ThisExpression", "start": 781, "end": 785, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 12 } } }, "property": { "type": "Identifier", "start": 786, "end": 795, "loc": { "start": { "line": 24, "column": 13 }, "end": { "line": 24, "column": 22 }, "identifierName": "hasPaused" }, "name": "hasPaused" }, "computed": false }, "right": { "type": "BooleanLiteral", "start": 798, "end": 803, "loc": { "start": { "line": 24, "column": 25 }, "end": { "line": 24, "column": 30 } }, "value": false } } } ], "directives": [], "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Called when the Engine should start all systems.\n * This also includes specific setup code to get the game running, \n * including setting up the render loop.\n ", "start": 816, "end": 1000, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 31, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1005, "end": 1560, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 50, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1005, "end": 1010, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 32, "column": 9 }, "identifierName": "start" }, "name": "start", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 1013, "end": 1560, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 50, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1073, "end": 1092, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 27 } }, "expression": { "type": "CallExpression", "start": 1073, "end": 1091, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 26 } }, "callee": { "type": "MemberExpression", "start": 1073, "end": 1089, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 24 } }, "object": { "type": "Identifier", "start": 1073, "end": 1083, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 34, "column": 18 }, "identifierName": "DOMManager" }, "name": "DOMManager", "leadingComments": null }, "property": { "type": "Identifier", "start": 1084, "end": 1089, "loc": { "start": { "line": 34, "column": 19 }, "end": { "line": 34, "column": 24 }, "identifierName": "start" }, "name": "start" }, "computed": false, "leadingComments": null }, "arguments": [], "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": "Needs to be first to target the canvas.", "start": 1023, "end": 1064, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 49 } } } ] }, { "type": "ExpressionStatement", "start": 1101, "end": 1127, "loc": { "start": { "line": 35, "column": 8 }, "end": { "line": 35, "column": 34 } }, "expression": { "type": "CallExpression", "start": 1101, "end": 1126, "loc": { "start": { "line": 35, "column": 8 }, "end": { "line": 35, "column": 33 } }, "callee": { "type": "MemberExpression", "start": 1101, "end": 1124, "loc": { "start": { "line": 35, "column": 8 }, "end": { "line": 35, "column": 31 } }, "object": { "type": "Identifier", "start": 1101, "end": 1118, "loc": { "start": { "line": 35, "column": 8 }, "end": { "line": 35, "column": 25 }, "identifierName": "PersistentManager" }, "name": "PersistentManager" }, "property": { "type": "Identifier", "start": 1119, "end": 1124, "loc": { "start": { "line": 35, "column": 26 }, "end": { "line": 35, "column": 31 }, "identifierName": "start" }, "name": "start" }, "computed": false }, "arguments": [] } }, { "type": "ExpressionStatement", "start": 1136, "end": 1157, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 29 } }, "expression": { "type": "CallExpression", "start": 1136, "end": 1156, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 28 } }, "callee": { "type": "MemberExpression", "start": 1136, "end": 1154, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 26 } }, "object": { "type": "Identifier", "start": 1136, "end": 1148, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 20 }, "identifierName": "SceneManager" }, "name": "SceneManager" }, "property": { "type": "Identifier", "start": 1149, "end": 1154, "loc": { "start": { "line": 36, "column": 21 }, "end": { "line": 36, "column": 26 }, "identifierName": "start" }, "name": "start" }, "computed": false }, "arguments": [] }, "trailingComments": [ { "type": "CommentLine", "value": "Needs to be ahead of RenderManager to init Programs for WebGL.", "start": 1167, "end": 1231, "loc": { "start": { "line": 38, "column": 8 }, "end": { "line": 38, "column": 72 } } } ] }, { "type": "ExpressionStatement", "start": 1240, "end": 1263, "loc": { "start": { "line": 39, "column": 8 }, "end": { "line": 39, "column": 31 } }, "expression": { "type": "CallExpression", "start": 1240, "end": 1262, "loc": { "start": { "line": 39, "column": 8 }, "end": { "line": 39, "column": 30 } }, "callee": { "type": "MemberExpression", "start": 1240, "end": 1260, "loc": { "start": { "line": 39, "column": 8 }, "end": { "line": 39, "column": 28 } }, "object": { "type": "Identifier", "start": 1240, "end": 1254, "loc": { "start": { "line": 39, "column": 8 }, "end": { "line": 39, "column": 22 }, "identifierName": "ProgramManager" }, "name": "ProgramManager", "leadingComments": null }, "property": { "type": "Identifier", "start": 1255, "end": 1260, "loc": { "start": { "line": 39, "column": 23 }, "end": { "line": 39, "column": 28 }, "identifierName": "start" }, "name": "start" }, "computed": false, "leadingComments": null }, "arguments": [], "leadingComments": null }, "leadingComments": [ { "type": "CommentLine", "value": "Needs to be ahead of RenderManager to init Programs for WebGL.", "start": 1167, "end": 1231, "loc": { "start": { "line": 38, "column": 8 }, "end": { "line": 38, "column": 72 } } } ] }, { "type": "ExpressionStatement", "start": 1272, "end": 1294, "loc": { "start": { "line": 40, "column": 8 }, "end": { "line": 40, "column": 30 } }, "expression": { "type": "CallExpression", "start": 1272, "end": 1293, "loc": { "start": { "line": 40, "column": 8 }, "end": { "line": 40, "column": 29 } }, "callee": { "type": "MemberExpression", "start": 1272, "end": 1291, "loc": { "start": { "line": 40, "column": 8 }, "end": { "line": 40, "column": 27 } }, "object": { "type": "Identifier", "start": 1272, "end": 1285, "loc": { "start": { "line": 40, "column": 8 }, "end": { "line": 40, "column": 21 }, "identifierName": "RenderManager" }, "name": "RenderManager" }, "property": { "type": "Identifier", "start": 1286, "end": 1291, "loc": { "start": { "line": 40, "column": 22 }, "end": { "line": 40,