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,451 lines (1,450 loc) 1.72 MB
{ "type": "File", "start": 0, "end": 9363, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 251, "column": 28 } }, "program": { "type": "Program", "start": 0, "end": 9363, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 251, "column": 28 } }, "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": 71, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 38 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 40, "end": 50, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 17 } }, "local": { "type": "Identifier", "start": 40, "end": 50, "loc": { "start": { "line": 2, "column": 7 }, "end": { "line": 2, "column": 17 }, "identifierName": "DOMManager" }, "name": "DOMManager" } } ], "source": { "type": "StringLiteral", "start": 56, "end": 70, "loc": { "start": { "line": 2, "column": 23 }, "end": { "line": 2, "column": 37 } }, "extra": { "rawValue": "./DOMManager", "raw": "'./DOMManager'" }, "value": "./DOMManager" } }, { "type": "ImportDeclaration", "start": 72, "end": 113, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 41 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 79, "end": 87, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 15 } }, "local": { "type": "Identifier", "start": 79, "end": 87, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 15 }, "identifierName": "Messager" }, "name": "Messager" } } ], "source": { "type": "StringLiteral", "start": 93, "end": 112, "loc": { "start": { "line": 3, "column": 21 }, "end": { "line": 3, "column": 40 } }, "extra": { "rawValue": "../utils/Messager", "raw": "'../utils/Messager'" }, "value": "../utils/Messager" } }, { "type": "ImportDeclaration", "start": 114, "end": 153, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 39 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 121, "end": 128, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 14 } }, "local": { "type": "Identifier", "start": 121, "end": 128, "loc": { "start": { "line": 4, "column": 7 }, "end": { "line": 4, "column": 14 }, "identifierName": "KeyCode" }, "name": "KeyCode" } } ], "source": { "type": "StringLiteral", "start": 134, "end": 152, "loc": { "start": { "line": 4, "column": 20 }, "end": { "line": 4, "column": 38 } }, "extra": { "rawValue": "../const/KeyCode", "raw": "'../const/KeyCode'" }, "value": "../const/KeyCode" } }, { "type": "ImportDeclaration", "start": 154, "end": 201, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 47 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 163, "end": 175, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 21 } }, "imported": { "type": "Identifier", "start": 163, "end": 175, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 21 }, "identifierName": "SceneManager" }, "name": "SceneManager" }, "local": { "type": "Identifier", "start": 163, "end": 175, "loc": { "start": { "line": 5, "column": 9 }, "end": { "line": 5, "column": 21 }, "identifierName": "SceneManager" }, "name": "SceneManager" } }, { "type": "ImportSpecifier", "start": 177, "end": 182, "loc": { "start": { "line": 5, "column": 23 }, "end": { "line": 5, "column": 28 } }, "imported": { "type": "Identifier", "start": 177, "end": 182, "loc": { "start": { "line": 5, "column": 23 }, "end": { "line": 5, "column": 28 }, "identifierName": "Point" }, "name": "Point" }, "local": { "type": "Identifier", "start": 177, "end": 182, "loc": { "start": { "line": 5, "column": 23 }, "end": { "line": 5, "column": 28 }, "identifierName": "Point" }, "name": "Point" } } ], "source": { "type": "StringLiteral", "start": 190, "end": 200, "loc": { "start": { "line": 5, "column": 36 }, "end": { "line": 5, "column": 46 } }, "extra": { "rawValue": "../entry", "raw": "'../entry'" }, "value": "../entry" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * A manager class intended to manage the javascript callback associated with the DOM.\n * The InputManager filters general DOM events such as key down, key up, left and right click.\n * The manager sorts events into referenceable lists for components to reference each game tick.\n * \n * In result, the InputManager creates a bridge between the DOM and Engine. Components should use the \n * `is` functions to determine if a specific character is down for that game tick. \n * \n * If you want to listen to all characters, for example a textbox input, use events instead. To listen to events, \n * use InputManager.events to access the event. Events are defined in InputManager.EVENT. See Messager.js for more info\n * on listening to events.\n ", "start": 203, "end": 946, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 18, "column": 3 } } } ] }, { "type": "ExportNamedDeclaration", "start": 947, "end": 9237, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 245, "column": 1 } }, "specifiers": [], "source": null, "declaration": { "type": "ClassDeclaration", "start": 954, "end": 9237, "loc": { "start": { "line": 19, "column": 7 }, "end": { "line": 245, "column": 1 } }, "id": { "type": "Identifier", "start": 960, "end": 973, "loc": { "start": { "line": 19, "column": 13 }, "end": { "line": 19, "column": 26 }, "identifierName": "_InputManager" }, "name": "_InputManager", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 982, "end": 989, "loc": { "start": { "line": 19, "column": 35 }, "end": { "line": 19, "column": 42 }, "identifierName": "Manager" }, "name": "Manager" }, "body": { "type": "ClassBody", "start": 990, "end": 9237, "loc": { "start": { "line": 19, "column": 43 }, "end": { "line": 245, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 1106, "end": 1962, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 51, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1106, "end": 1117, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 1120, "end": 1962, "loc": { "start": { "line": 24, "column": 18 }, "end": { "line": 51, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1130, "end": 1138, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 25, "column": 16 } }, "expression": { "type": "CallExpression", "start": 1130, "end": 1137, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 25, "column": 15 } }, "callee": { "type": "Super", "start": 1130, "end": 1135, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 25, "column": 13 } } }, "arguments": [] } }, { "type": "ExpressionStatement", "start": 1152, "end": 1181, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 37 } }, "expression": { "type": "AssignmentExpression", "start": 1152, "end": 1180, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 36 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1152, "end": 1163, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 19 } }, "object": { "type": "ThisExpression", "start": 1152, "end": 1156, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 12 } } }, "property": { "type": "Identifier", "start": 1157, "end": 1163, "loc": { "start": { "line": 26, "column": 13 }, "end": { "line": 26, "column": 19 }, "identifierName": "events" }, "name": "events" }, "computed": false }, "right": { "type": "NewExpression", "start": 1166, "end": 1180, "loc": { "start": { "line": 26, "column": 22 }, "end": { "line": 26, "column": 36 } }, "callee": { "type": "Identifier", "start": 1170, "end": 1178, "loc": { "start": { "line": 26, "column": 26 }, "end": { "line": 26, "column": 34 }, "identifierName": "Messager" }, "name": "Messager" }, "arguments": [] } } }, { "type": "ExpressionStatement", "start": 1190, "end": 1540, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 36, "column": 10 } }, "expression": { "type": "AssignmentExpression", "start": 1190, "end": 1539, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 36, "column": 9 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1190, "end": 1200, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 18 } }, "object": { "type": "ThisExpression", "start": 1190, "end": 1194, "loc": { "start": { "line": 27, "column": 8 }, "end": { "line": 27, "column": 12 } } }, "property": { "type": "Identifier", "start": 1195, "end": 1200, "loc": { "start": { "line": 27, "column": 13 }, "end": { "line": 27, "column": 18 }, "identifierName": "EVENT" }, "name": "EVENT" }, "computed": false }, "right": { "type": "ObjectExpression", "start": 1203, "end": 1539, "loc": { "start": { "line": 27, "column": 21 }, "end": { "line": 36, "column": 9 } }, "properties": [ { "type": "ObjectProperty", "start": 1217, "end": 1249, "loc": { "start": { "line": 28, "column": 12 }, "end": { "line": 28, "column": 44 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1217, "end": 1229, "loc": { "start": { "line": 28, "column": 12 }, "end": { "line": 28, "column": 24 }, "identifierName": "LEFT_PRESSED" }, "name": "LEFT_PRESSED" }, "value": { "type": "StringLiteral", "start": 1231, "end": 1249, "loc": { "start": { "line": 28, "column": 26 }, "end": { "line": 28, "column": 44 } }, "extra": { "rawValue": "mouseLeftPressed", "raw": "'mouseLeftPressed'" }, "value": "mouseLeftPressed" } }, { "type": "ObjectProperty", "start": 1263, "end": 1297, "loc": { "start": { "line": 29, "column": 12 }, "end": { "line": 29, "column": 46 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1263, "end": 1276, "loc": { "start": { "line": 29, "column": 12 }, "end": { "line": 29, "column": 25 }, "identifierName": "LEFT_RELEASED" }, "name": "LEFT_RELEASED" }, "value": { "type": "StringLiteral", "start": 1278, "end": 1297, "loc": { "start": { "line": 29, "column": 27 }, "end": { "line": 29, "column": 46 } }, "extra": { "rawValue": "mouseLeftReleased", "raw": "'mouseLeftReleased'" }, "value": "mouseLeftReleased" } }, { "type": "ObjectProperty", "start": 1311, "end": 1345, "loc": { "start": { "line": 30, "column": 12 }, "end": { "line": 30, "column": 46 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1311, "end": 1324, "loc": { "start": { "line": 30, "column": 12 }, "end": { "line": 30, "column": 25 }, "identifierName": "RIGHT_PRESSED" }, "name": "RIGHT_PRESSED" }, "value": { "type": "StringLiteral", "start": 1326, "end": 1345, "loc": { "start": { "line": 30, "column": 27 }, "end": { "line": 30, "column": 46 } }, "extra": { "rawValue": "mouseRightPressed", "raw": "'mouseRightPressed'" }, "value": "mouseRightPressed" } }, { "type": "ObjectProperty", "start": 1359, "end": 1395, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 48 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1359, "end": 1373, "loc": { "start": { "line": 31, "column": 12 }, "end": { "line": 31, "column": 26 }, "identifierName": "RIGHT_RELEASED" }, "name": "RIGHT_RELEASED" }, "value": { "type": "StringLiteral", "start": 1375, "end": 1395, "loc": { "start": { "line": 31, "column": 28 }, "end": { "line": 31, "column": 48 } }, "extra": { "rawValue": "mouseRightReleased", "raw": "'mouseRightReleased'" }, "value": "mouseRightReleased" } }, { "type": "ObjectProperty", "start": 1409, "end": 1432, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 35 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1409, "end": 1419, "loc": { "start": { "line": 32, "column": 12 }, "end": { "line": 32, "column": 22 }, "identifierName": "MOUSE_MOVE" }, "name": "MOUSE_MOVE" }, "value": { "type": "StringLiteral", "start": 1421, "end": 1432, "loc": { "start": { "line": 32, "column": 24 }, "end": { "line": 32, "column": 35 } }, "extra": { "rawValue": "mouseMove", "raw": "'mouseMove'" }, "value": "mouseMove" } }, { "type": "ObjectProperty", "start": 1446, "end": 1465, "loc": { "start": { "line": 33, "column": 12 }, "end": { "line": 33, "column": 31 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1446, "end": 1454, "loc": { "start": { "line": 33, "column": 12 }, "end": { "line": 33, "column": 20 }, "identifierName": "KEY_DOWN" }, "name": "KEY_DOWN" }, "value": { "type": "StringLiteral", "start": 1456, "end": 1465, "loc": { "start": { "line": 33, "column": 22 }, "end": { "line": 33, "column": 31 } }, "extra": { "rawValue": "keyDown", "raw": "'keyDown'" }, "value": "keyDown" } }, { "type": "ObjectProperty", "start": 1479, "end": 1494, "loc": { "start": { "line": 34, "column": 12 }, "end": { "line": 34, "column": 27 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1479, "end": 1485, "loc": { "start": { "line": 34, "column": 12 }, "end": { "line": 34, "column": 18 }, "identifierName": "KEY_UP" }, "name": "KEY_UP" }, "value": { "type": "StringLiteral", "start": 1487, "end": 1494, "loc": { "start": { "line": 34, "column": 20 }, "end": { "line": 34, "column": 27 } }, "extra": { "rawValue": "keyUp", "raw": "'keyUp'" }, "value": "keyUp" } }, { "type": "ObjectProperty", "start": 1508, "end": 1528, "loc": { "start": { "line": 35, "column": 12 }, "end": { "line": 35, "column": 32 } }, "method": false, "shorthand": false, "computed": false, "key": { "type": "Identifier", "start": 1508, "end": 1511, "loc": { "start": { "line": 35, "column": 12 }, "end": { "line": 35, "column": 15 }, "identifierName": "KEY" }, "name": "KEY" }, "value": { "type": "StringLiteral", "start": 1513, "end": 1528, "loc": { "start": { "line": 35, "column": 17 }, "end": { "line": 35, "column": 32 } }, "extra": { "rawValue": "keyDownRepeat", "raw": "'keyDownRepeat'" }, "value": "keyDownRepeat" } } ] } } }, { "type": "ExpressionStatement", "start": 1549, "end": 1568, "loc": { "start": { "line": 37, "column": 8 }, "end": { "line": 37, "column": 27 } }, "expression": { "type": "AssignmentExpression", "start": 1549, "end": 1567, "loc": { "start": { "line": 37, "column": 8 }, "end": { "line": 37, "column": 26 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1549, "end": 1562, "loc": { "start": { "line": 37, "column": 8 }, "end": { "line": 37, "column": 21 } }, "object": { "type": "ThisExpression", "start": 1549, "end": 1553, "loc": { "start": { "line": 37, "column": 8 }, "end": { "line": 37, "column": 12 } } }, "property": { "type": "Identifier", "start": 1554, "end": 1562, "loc": { "start": { "line": 37, "column": 13 }, "end": { "line": 37, "column": 21 }, "identifierName": "KEY_DOWN" }, "name": "KEY_DOWN" }, "computed": false }, "right": { "type": "ArrayExpression", "start": 1565, "end": 1567, "loc": { "start": { "line": 37, "column": 24 }, "end": { "line": 37, "column": 26 } }, "elements": [] } } }, { "type": "ExpressionStatement", "start": 1577, "end": 1599, "loc": { "start": { "line": 38, "column": 8 }, "end": { "line": 38, "column": 30 } }, "expression": { "type": "AssignmentExpression", "start": 1577, "end": 1598, "loc": { "start": { "line": 38, "column": 8 }, "end": { "line": 38, "column": 29 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1577, "end": 1593, "loc": { "start": { "line": 38, "column": 8 }, "end": { "line": 38, "column": 24 } }, "object": { "type": "ThisExpression", "start": 1577, "end": 1581, "loc": { "start": { "line": 38, "column": 8 }, "end": { "line": 38, "column": 12 } } }, "property": { "type": "Identifier", "start": 1582, "end": 1593, "loc": { "start": { "line": 38, "column": 13 },