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,353 lines (1,352 loc) 489 kB
{ "type": "File", "start": 0, "end": 2809, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 99, "column": 28 } }, "program": { "type": "Program", "start": 0, "end": 2809, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 99, "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": "ExportNamedDeclaration", "start": 34, "end": 2684, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 93, "column": 1 } }, "specifiers": [], "source": null, "declaration": { "type": "ClassDeclaration", "start": 41, "end": 2684, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 93, "column": 1 } }, "id": { "type": "Identifier", "start": 47, "end": 60, "loc": { "start": { "line": 3, "column": 13 }, "end": { "line": 3, "column": 26 }, "identifierName": "_AudioManager" }, "name": "_AudioManager" }, "superClass": { "type": "Identifier", "start": 69, "end": 76, "loc": { "start": { "line": 3, "column": 35 }, "end": { "line": 3, "column": 42 }, "identifierName": "Manager" }, "name": "Manager" }, "body": { "type": "ClassBody", "start": 77, "end": 2684, "loc": { "start": { "line": 3, "column": 43 }, "end": { "line": 93, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 83, "end": 209, "loc": { "start": { "line": 4, "column": 4 }, "end": { "line": 10, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 83, "end": 94, "loc": { "start": { "line": 4, "column": 4 }, "end": { "line": 4, "column": 15 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 97, "end": 209, "loc": { "start": { "line": 4, "column": 18 }, "end": { "line": 10, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 107, "end": 115, "loc": { "start": { "line": 5, "column": 8 }, "end": { "line": 5, "column": 16 } }, "expression": { "type": "CallExpression", "start": 107, "end": 114, "loc": { "start": { "line": 5, "column": 8 }, "end": { "line": 5, "column": 15 } }, "callee": { "type": "Super", "start": 107, "end": 112, "loc": { "start": { "line": 5, "column": 8 }, "end": { "line": 5, "column": 13 } } }, "arguments": [] } }, { "type": "ExpressionStatement", "start": 124, "end": 146, "loc": { "start": { "line": 6, "column": 8 }, "end": { "line": 6, "column": 30 } }, "expression": { "type": "AssignmentExpression", "start": 124, "end": 145, "loc": { "start": { "line": 6, "column": 8 }, "end": { "line": 6, "column": 29 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 124, "end": 141, "loc": { "start": { "line": 6, "column": 8 }, "end": { "line": 6, "column": 25 } }, "object": { "type": "ThisExpression", "start": 124, "end": 128, "loc": { "start": { "line": 6, "column": 8 }, "end": { "line": 6, "column": 12 } } }, "property": { "type": "Identifier", "start": 129, "end": 141, "loc": { "start": { "line": 6, "column": 13 }, "end": { "line": 6, "column": 25 }, "identifierName": "masterVolume" }, "name": "masterVolume" }, "computed": false }, "right": { "type": "NumericLiteral", "start": 144, "end": 145, "loc": { "start": { "line": 6, "column": 28 }, "end": { "line": 6, "column": 29 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 } } }, { "type": "ExpressionStatement", "start": 155, "end": 176, "loc": { "start": { "line": 7, "column": 8 }, "end": { "line": 7, "column": 29 } }, "expression": { "type": "AssignmentExpression", "start": 155, "end": 175, "loc": { "start": { "line": 7, "column": 8 }, "end": { "line": 7, "column": 28 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 155, "end": 168, "loc": { "start": { "line": 7, "column": 8 }, "end": { "line": 7, "column": 21 } }, "object": { "type": "ThisExpression", "start": 155, "end": 159, "loc": { "start": { "line": 7, "column": 8 }, "end": { "line": 7, "column": 12 } } }, "property": { "type": "Identifier", "start": 160, "end": 168, "loc": { "start": { "line": 7, "column": 13 }, "end": { "line": 7, "column": 21 }, "identifierName": "audioCtx" }, "name": "audioCtx" }, "computed": false }, "right": { "type": "NullLiteral", "start": 171, "end": 175, "loc": { "start": { "line": 7, "column": 24 }, "end": { "line": 7, "column": 28 } } } } }, { "type": "ExpressionStatement", "start": 186, "end": 203, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 25 } }, "expression": { "type": "AssignmentExpression", "start": 186, "end": 202, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 24 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 186, "end": 197, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 19 } }, "object": { "type": "ThisExpression", "start": 186, "end": 190, "loc": { "start": { "line": 9, "column": 8 }, "end": { "line": 9, "column": 12 } } }, "property": { "type": "Identifier", "start": 191, "end": 197, "loc": { "start": { "line": 9, "column": 13 }, "end": { "line": 9, "column": 19 }, "identifierName": "sounds" }, "name": "sounds" }, "computed": false }, "right": { "type": "ObjectExpression", "start": 200, "end": 202, "loc": { "start": { "line": 9, "column": 22 }, "end": { "line": 9, "column": 24 } }, "properties": [] } } } ], "directives": [] } }, { "type": "ClassMethod", "start": 215, "end": 308, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 14, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 215, "end": 230, "loc": { "start": { "line": 12, "column": 4 }, "end": { "line": 12, "column": 19 }, "identifierName": "setMasterVolume" }, "name": "setMasterVolume" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 231, "end": 237, "loc": { "start": { "line": 12, "column": 20 }, "end": { "line": 12, "column": 26 }, "identifierName": "volume" }, "name": "volume" } ], "body": { "type": "BlockStatement", "start": 239, "end": 308, "loc": { "start": { "line": 12, "column": 28 }, "end": { "line": 14, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 249, "end": 302, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 61 } }, "expression": { "type": "AssignmentExpression", "start": 249, "end": 301, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 60 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 249, "end": 266, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 25 } }, "object": { "type": "ThisExpression", "start": 249, "end": 253, "loc": { "start": { "line": 13, "column": 8 }, "end": { "line": 13, "column": 12 } } }, "property": { "type": "Identifier", "start": 254, "end": 266, "loc": { "start": { "line": 13, "column": 13 }, "end": { "line": 13, "column": 25 }, "identifierName": "masterVolume" }, "name": "masterVolume" }, "computed": false }, "right": { "type": "CallExpression", "start": 269, "end": 301, "loc": { "start": { "line": 13, "column": 28 }, "end": { "line": 13, "column": 60 } }, "callee": { "type": "MemberExpression", "start": 269, "end": 277, "loc": { "start": { "line": 13, "column": 28 }, "end": { "line": 13, "column": 36 } }, "object": { "type": "Identifier", "start": 269, "end": 273, "loc": { "start": { "line": 13, "column": 28 }, "end": { "line": 13, "column": 32 }, "identifierName": "Math" }, "name": "Math" }, "property": { "type": "Identifier", "start": 274, "end": 277, "loc": { "start": { "line": 13, "column": 33 }, "end": { "line": 13, "column": 36 }, "identifierName": "max" }, "name": "max" }, "computed": false }, "arguments": [ { "type": "NumericLiteral", "start": 278, "end": 279, "loc": { "start": { "line": 13, "column": 37 }, "end": { "line": 13, "column": 38 } }, "extra": { "rawValue": 0, "raw": "0" }, "value": 0 }, { "type": "CallExpression", "start": 281, "end": 300, "loc": { "start": { "line": 13, "column": 40 }, "end": { "line": 13, "column": 59 } }, "callee": { "type": "MemberExpression", "start": 281, "end": 289, "loc": { "start": { "line": 13, "column": 40 }, "end": { "line": 13, "column": 48 } }, "object": { "type": "Identifier", "start": 281, "end": 285, "loc": { "start": { "line": 13, "column": 40 }, "end": { "line": 13, "column": 44 }, "identifierName": "Math" }, "name": "Math" }, "property": { "type": "Identifier", "start": 286, "end": 289, "loc": { "start": { "line": 13, "column": 45 }, "end": { "line": 13, "column": 48 }, "identifierName": "min" }, "name": "min" }, "computed": false }, "arguments": [ { "type": "NumericLiteral", "start": 290, "end": 291, "loc": { "start": { "line": 13, "column": 49 }, "end": { "line": 13, "column": 50 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 }, { "type": "Identifier", "start": 293, "end": 299, "loc": { "start": { "line": 13, "column": 52 }, "end": { "line": 13, "column": 58 }, "identifierName": "volume" }, "name": "volume" } ] } ] } } } ], "directives": [] } }, { "type": "ClassMethod", "start": 314, "end": 546, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 21, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 314, "end": 322, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 16, "column": 12 }, "identifierName": "addSound" }, "name": "addSound" }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 323, "end": 332, "loc": { "start": { "line": 16, "column": 13 }, "end": { "line": 16, "column": 22 }, "identifierName": "soundName" }, "name": "soundName" }, { "type": "Identifier", "start": 334, "end": 348, "loc": { "start": { "line": 16, "column": 24 }, "end": { "line": 16, "column": 38 }, "identifierName": "soundAssetPath" }, "name": "soundAssetPath" } ], "body": { "type": "BlockStatement", "start": 350, "end": 546, "loc": { "start": { "line": 16, "column": 40 }, "end": { "line": 21, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 360, "end": 540, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 20, "column": 11 } }, "argument": { "type": "CallExpression", "start": 367, "end": 539, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 20, "column": 10 } }, "callee": { "type": "MemberExpression", "start": 367, "end": 420, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 17, "column": 68 } }, "object": { "type": "CallExpression", "start": 367, "end": 415, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 17, "column": 63 } }, "callee": { "type": "MemberExpression", "start": 367, "end": 399, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 17, "column": 47 } }, "object": { "type": "ThisExpression", "start": 367, "end": 371, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 17, "column": 19 } } }, "property": { "type": "Identifier", "start": 372, "end": 399, "loc": { "start": { "line": 17, "column": 20 }, "end": { "line": 17, "column": 47 }, "identifierName": "_createSoundBufferFromAsset" }, "name": "_createSoundBufferFromAsset" }, "computed": false }, "arguments": [ { "type": "Identifier", "start": 400, "end": 414, "loc": { "start": { "line": 17, "column": 48 }, "end": { "line": 17, "column": 62 }, "identifierName": "soundAssetPath" }, "name": "soundAssetPath" } ] }, "property": { "type": "Identifier", "start": 416, "end": 420, "loc": { "start": { "line": 17, "column": 64 }, "end": { "line": 17, "column": 68 }, "identifierName": "then" }, "name": "then" }, "computed": false }, "arguments": [ { "type": "ArrowFunctionExpression", "start": 421, "end": 538, "loc": { "start": { "line": 17, "column": 69 }, "end": { "line": 20, "column": 9 } }, "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 422, "end": 431, "loc": { "start": { "line": 17, "column": 70 }, "end": { "line": 17, "column": 79 }, "identifierName": "soundInfo" }, "name": "soundInfo" } ], "body": { "type": "BlockStatement", "start": 436, "end": 538, "loc": { "start": { "line": 17, "column": 84 }, "end": { "line": 20, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 450, "end": 485, "loc": { "start": { "line": 18, "column": 12 }, "end": { "line": 18, "column": 47 } }, "expression": { "type": "AssignmentExpression", "start": 450, "end": 484, "loc": { "start": { "line": 18, "column": 12 }, "end": { "line": 18, "column": 46 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 450, "end": 472, "loc": { "start": { "line": 18, "column": 12 }, "end": { "line": 18, "column": 34 } }, "object": { "type": "MemberExpression", "start": 450, "end": 461, "loc": { "start": { "line": 18, "column": 12 }, "end": { "line": 18, "column": 23 } }, "object": { "type": "ThisExpression", "start": 450, "end": 454, "loc": { "start": { "line": 18, "column": 12 }, "end": { "line": 18, "column": 16 } } }, "property": { "type": "Identifier", "start": 455, "end": 461, "loc": { "start": { "line": 18, "column": 17 }, "end": { "line": 18, "column": 23 }, "identifierName": "sounds" }, "name": "sounds" }, "computed": false }, "property": { "type": "Identifier", "start": 462, "end": 471, "loc": { "start": { "line": 18, "column": 24 }, "end": { "line": 18, "column": 33 }, "identifierName": "soundName" }, "name": "soundName" }, "computed": true }, "right": { "type": "Identifier", "start": 475, "end": 484, "loc": { "start": { "line": 18, "column": 37 }, "end": { "line": 18, "column": 46 }, "identifierName": "soundInfo" }, "name": "soundInfo" } } }, { "type": "ReturnStatement", "start": 498, "end": 528, "loc": { "start": { "line": 19, "column": 12 }, "end": { "line": 19, "column": 42 } }, "argument": { "type": "MemberExpression", "start": 505, "end": 527, "loc": { "start": { "line": 19, "column": 19