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,411 lines 796 kB
{ "type": "File", "start": 0, "end": 6514, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 159, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 6514, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 159, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 36, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 36 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 16, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 16 } }, "local": { "type": "Identifier", "start": 7, "end": 16, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 16 }, "identifierName": "Component" }, "name": "Component" } } ], "source": { "type": "StringLiteral", "start": 22, "end": 35, "loc": { "start": { "line": 1, "column": 22 }, "end": { "line": 1, "column": 35 } }, "extra": { "rawValue": "./Component", "raw": "'./Component'" }, "value": "./Component" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Animation component to be added to a GameObject to create animations inline with\n * the global game loop. Animation Components currently only offer transform interpolation\n * frames. Using buildInterpolation can be used to make custom animations which last n frames.\n ", "start": 38, "end": 315, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 7, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 316, "end": 6514, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 159, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 331, "end": 6514, "loc": { "start": { "line": 8, "column": 15 }, "end": { "line": 159, "column": 1 } }, "id": { "type": "Identifier", "start": 337, "end": 346, "loc": { "start": { "line": 8, "column": 21 }, "end": { "line": 8, "column": 30 }, "identifierName": "Animation" }, "name": "Animation", "leadingComments": null }, "superClass": { "type": "Identifier", "start": 355, "end": 364, "loc": { "start": { "line": 8, "column": 39 }, "end": { "line": 8, "column": 48 }, "identifierName": "Component" }, "name": "Component" }, "body": { "type": "ClassBody", "start": 365, "end": 6514, "loc": { "start": { "line": 8, "column": 49 }, "end": { "line": 159, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 493, "end": 645, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 18, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 493, "end": 504, "loc": { "start": { "line": 13, "column": 4 }, "end": { "line": 13, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 507, "end": 645, "loc": { "start": { "line": 13, "column": 18 }, "end": { "line": 18, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 517, "end": 530, "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 21 } }, "expression": { "type": "CallExpression", "start": 517, "end": 529, "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 20 } }, "callee": { "type": "Super", "start": 517, "end": 522, "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 13 } } }, "arguments": [ { "type": "BooleanLiteral", "start": 523, "end": 528, "loc": { "start": { "line": 14, "column": 14 }, "end": { "line": 14, "column": 19 } }, "value": false } ] } }, { "type": "ExpressionStatement", "start": 539, "end": 568, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 37 } }, "expression": { "type": "AssignmentExpression", "start": 539, "end": 567, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 36 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 539, "end": 553, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 22 } }, "object": { "type": "ThisExpression", "start": 539, "end": 543, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 12 } } }, "property": { "type": "Identifier", "start": 544, "end": 553, "loc": { "start": { "line": 15, "column": 13 }, "end": { "line": 15, "column": 22 }, "identifierName": "className" }, "name": "className" }, "computed": false }, "right": { "type": "StringLiteral", "start": 556, "end": 567, "loc": { "start": { "line": 15, "column": 25 }, "end": { "line": 15, "column": 36 } }, "extra": { "rawValue": "Animation", "raw": "'Animation'" }, "value": "Animation" } } }, { "type": "ExpressionStatement", "start": 577, "end": 605, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 36 } }, "expression": { "type": "AssignmentExpression", "start": 577, "end": 604, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 35 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 577, "end": 599, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 30 } }, "object": { "type": "ThisExpression", "start": 577, "end": 581, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 12 } } }, "property": { "type": "Identifier", "start": 582, "end": 599, "loc": { "start": { "line": 16, "column": 13 }, "end": { "line": 16, "column": 30 }, "identifierName": "interpolationData" }, "name": "interpolationData" }, "computed": false }, "right": { "type": "ObjectExpression", "start": 602, "end": 604, "loc": { "start": { "line": 16, "column": 33 }, "end": { "line": 16, "column": 35 } }, "properties": [] } } }, { "type": "ExpressionStatement", "start": 614, "end": 639, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 33 } }, "expression": { "type": "AssignmentExpression", "start": 614, "end": 638, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 32 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 614, "end": 634, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 28 } }, "object": { "type": "ThisExpression", "start": 614, "end": 618, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 12 } } }, "property": { "type": "Identifier", "start": 619, "end": 634, "loc": { "start": { "line": 17, "column": 13 }, "end": { "line": 17, "column": 28 }, "identifierName": "animationFrames" }, "name": "animationFrames" }, "computed": false }, "right": { "type": "NumericLiteral", "start": 637, "end": 638, "loc": { "start": { "line": 17, "column": 31 }, "end": { "line": 17, "column": 32 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Constructor for the animation component. A GameObject may have more than one Animation component.\n ", "start": 372, "end": 488, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 12, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Returns the frames left until all animations are complete.\n ", "start": 651, "end": 728, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 22, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 733, "end": 799, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 25, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 733, "end": 752, "loc": { "start": { "line": 23, "column": 4 }, "end": { "line": 23, "column": 23 }, "identifierName": "animationFramesLeft" }, "name": "animationFramesLeft", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 755, "end": 799, "loc": { "start": { "line": 23, "column": 26 }, "end": { "line": 25, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 765, "end": 793, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 36 } }, "argument": { "type": "MemberExpression", "start": 772, "end": 792, "loc": { "start": { "line": 24, "column": 15 }, "end": { "line": 24, "column": 35 } }, "object": { "type": "ThisExpression", "start": 772, "end": 776, "loc": { "start": { "line": 24, "column": 15 }, "end": { "line": 24, "column": 19 } } }, "property": { "type": "Identifier", "start": 777, "end": 792, "loc": { "start": { "line": 24, "column": 20 }, "end": { "line": 24, "column": 35 }, "identifierName": "animationFrames" }, "name": "animationFrames" }, "computed": false } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Returns the frames left until all animations are complete.\n ", "start": 651, "end": 728, "loc": { "start": { "line": 20, "column": 4 }, "end": { "line": 22, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Checks to see if an animation, defined by the interpol animation key, \n * still has frames left to complete the animation.\n * \n * @param {string} interpol Animation interpolation key.\n ", "start": 805, "end": 1019, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 32, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1024, "end": 1214, "loc": { "start": { "line": 33, "column": 4 }, "end": { "line": 37, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1024, "end": 1035, "loc": { "start": { "line": 33, "column": 4 }, "end": { "line": 33, "column": 15 }, "identifierName": "isAnimating" }, "name": "isAnimating", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "AssignmentPattern", "start": 1036, "end": 1051, "loc": { "start": { "line": 33, "column": 16 }, "end": { "line": 33, "column": 31 } }, "left": { "type": "Identifier", "start": 1036, "end": 1044, "loc": { "start": { "line": 33, "column": 16 }, "end": { "line": 33, "column": 24 }, "identifierName": "interpol" }, "name": "interpol" }, "right": { "type": "NullLiteral", "start": 1047, "end": 1051, "loc": { "start": { "line": 33, "column": 27 }, "end": { "line": 33, "column": 31 } } } } ], "body": { "type": "BlockStatement", "start": 1053, "end": 1214, "loc": { "start": { "line": 33, "column": 33 }, "end": { "line": 37, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 1063, "end": 1151, "loc": { "start": { "line": 34, "column": 8 }, "end": { "line": 35, "column": 66 } }, "test": { "type": "BinaryExpression", "start": 1067, "end": 1083, "loc": { "start": { "line": 34, "column": 12 }, "end": { "line": 34, "column": 28 } }, "left": { "type": "Identifier", "start": 1067, "end": 1075, "loc": { "start": { "line": 34, "column": 12 }, "end": { "line": 34, "column": 20 }, "identifierName": "interpol" }, "name": "interpol" }, "operator": "==", "right": { "type": "NullLiteral", "start": 1079, "end": 1083, "loc": { "start": { "line": 34, "column": 24 }, "end": { "line": 34, "column": 28 } } } }, "consequent": { "type": "ReturnStatement", "start": 1097, "end": 1151, "loc": { "start": { "line": 35, "column": 12 }, "end": { "line": 35, "column": 66 } }, "argument": { "type": "BinaryExpression", "start": 1104, "end": 1150, "loc": { "start": { "line": 35, "column": 19 }, "end": { "line": 35, "column": 65 } }, "left": { "type": "MemberExpression", "start": 1104, "end": 1146, "loc": { "start": { "line": 35, "column": 19 }, "end": { "line": 35, "column": 61 } }, "object": { "type": "CallExpression", "start": 1104, "end": 1139, "loc": { "start": { "line": 35, "column": 19 }, "end": { "line": 35, "column": 54 } }, "callee": { "type": "MemberExpression", "start": 1104, "end": 1115, "loc": { "start": { "line": 35, "column": 19 }, "end": { "line": 35, "column": 30 } }, "object": { "type": "Identifier", "start": 1104, "end": 1110, "loc": { "start": { "line": 35, "column": 19 }, "end": { "line": 35, "column": 25 }, "identifierName": "Object" }, "name": "Object" }, "property": { "type": "Identifier", "start": 1111, "end": 1115, "loc": { "start": { "line": 35, "column": 26 }, "end": { "line": 35, "column": 30 }, "identifierName": "keys" }, "name": "keys" }, "computed": false }, "arguments": [ { "type": "MemberExpression", "start": 1116, "end": 1138, "loc": { "start": { "line": 35, "column": 31 }, "end": { "line": 35, "column": 53 } }, "object": { "type": "ThisExpression", "start": 1116, "end": 1120, "loc": { "start": { "line": 35, "column": 31 }, "end": { "line": 35, "column": 35 } } }, "property": { "type": "Identifier", "start": 1121, "end": 1138, "loc": { "start": { "line": 35, "column": 36 }, "end": { "line": 35, "column": 53 }, "identifierName": "interpolationData" }, "name": "interpolationData" }, "computed": false } ] }, "property": { "type": "Identifier", "start": 1140, "end": 1146, "loc": { "start": { "line": 35, "column": 55 }, "end": { "line": 35, "column": 61 }, "identifierName": "length" }, "name": "length" }, "computed": false }, "operator": ">", "right": { "type": "NumericLiteral", "start": 1149, "end": 1150, "loc": { "start": { "line": 35, "column": 64 }, "end": { "line": 35, "column": 65 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 } } }, "alternate": null }, { "type": "ReturnStatement", "start": 1160, "end": 1208, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 36, "column": 56 } }, "argument": { "type": "BinaryExpression", "start": 1167, "end": 1207, "loc": { "start": { "line": 36, "column": 15 }, "end": { "line": 36, "column": 55 } }, "left": { "type": "MemberExpression", "start": 1167, "end": 1199, "loc": { "start": { "line": 36, "column": 15 }, "end": { "line": 36, "column": 47 } }, "object": { "type": "MemberExpression", "start": 1167, "end": 1189, "loc": { "start": { "line": 36, "column": 15 }, "end": { "line": 36, "column": 37 } }, "object": { "type": "ThisExpression", "start": 1167, "end": 1171, "loc": { "start": { "line": 36, "column": 15 }, "end": { "line": 36, "column": 19 } } }, "property": { "type": "Identifier", "start": 1172, "end": 1189, "loc": { "start": { "line": 36, "column": 20 }, "end": { "line": 36, "column": 37 }, "identifierName": "interpolationData" }, "name": "interpolationData" }, "computed": false }, "property": { "type": "Identifier", "start": 1190, "end": 1198, "loc": { "start": { "line": 36, "column": 38 }, "end": { "line": 36, "column": 46 }, "identifierName": "interpol" }, "name": "interpol" }, "computed": true }, "operator": "!=", "right": { "type": "NullLiteral", "start": 1203, "end": 1207, "loc": { "start": { "line": 36, "column": 51 }, "end": { "line": 36, "column": 55 } } } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Checks to see if an animation, defined by the interpol animation key, \n * still has frames left to complete the animation.\n * \n * @param {string} interpol Animation interpolation key.\n ", "start": 805, "end": 1019, "loc": { "start": { "line": 27, "column": 4 }, "end": { "line": 32, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Adds an animation to the Animation component. The animation component will keep track\n * and trigger the animation frames once per game tick until there are no more frames left.\n * On the final frame, the finalFrame callback will be called instead.\n * \n * @param {string} key Animation interpolation key.\n * @param {number} frames How many game ticks will this animation run.\n * @param {function} frameChange Callback function executed once per animation frame.\n * @param {function} finalFrame Callback function execured as the last frame. Defaults to frameChange.\n ", "start": 1220, "end": 1831, "loc": { "start": { "line": 39, "column": 4 }, "end": { "line": 48, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1836, "end": 2046, "loc": { "start": { "line": 49, "column": 4 }, "end": { "line": 55, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 1836, "end": 1854, "loc": { "start": { "line": 49, "column": 4 }, "end": { "line": 49, "column": 22 }, "identifierName": "buildInterpolation" }, "name": "buildInterpolation", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1855, "end": 1858, "loc": { "start": { "line": 49, "column": 23 }, "end": { "line": 49, "column": 26 }, "identifierName": "key" }, "name": "key" }, { "type": "Identifier", "start": 1860, "end": 1866, "loc": { "start": { "line": 49, "column": 28 }, "end": { "line": 49, "column": 34 }, "identifierName