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,441 lines • 292 kB
JSON
{
"type": "File",
"start": 0,
"end": 2163,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 69,
"column": 26
}
},
"program": {
"type": "Program",
"start": 0,
"end": 2163,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 69,
"column": 26
}
},
"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"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Manages the connection between the DOM and the Game & Engine.\n * \n * The DOMManager sets up and holds reference to the DOM elements required to display the game.\n ",
"start": 34,
"end": 206,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 7,
"column": 3
}
}
}
]
},
{
"type": "ExportNamedDeclaration",
"start": 207,
"end": 2046,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 63,
"column": 1
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "ClassDeclaration",
"start": 214,
"end": 2046,
"loc": {
"start": {
"line": 8,
"column": 7
},
"end": {
"line": 63,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 220,
"end": 231,
"loc": {
"start": {
"line": 8,
"column": 13
},
"end": {
"line": 8,
"column": 24
},
"identifierName": "_DOMManager"
},
"name": "_DOMManager",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 240,
"end": 247,
"loc": {
"start": {
"line": 8,
"column": 33
},
"end": {
"line": 8,
"column": 40
},
"identifierName": "Manager"
},
"name": "Manager"
},
"body": {
"type": "ClassBody",
"start": 248,
"end": 2046,
"loc": {
"start": {
"line": 8,
"column": 41
},
"end": {
"line": 63,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 339,
"end": 558,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 21,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 339,
"end": 350,
"loc": {
"start": {
"line": 12,
"column": 4
},
"end": {
"line": 12,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor",
"leadingComments": null
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 353,
"end": 558,
"loc": {
"start": {
"line": 12,
"column": 18
},
"end": {
"line": 21,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 363,
"end": 371,
"loc": {
"start": {
"line": 13,
"column": 8
},
"end": {
"line": 13,
"column": 16
}
},
"expression": {
"type": "CallExpression",
"start": 363,
"end": 370,
"loc": {
"start": {
"line": 13,
"column": 8
},
"end": {
"line": 13,
"column": 15
}
},
"callee": {
"type": "Super",
"start": 363,
"end": 368,
"loc": {
"start": {
"line": 13,
"column": 8
},
"end": {
"line": 13,
"column": 13
}
}
},
"arguments": []
}
},
{
"type": "ExpressionStatement",
"start": 380,
"end": 399,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 27
}
},
"expression": {
"type": "AssignmentExpression",
"start": 380,
"end": 398,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 26
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 380,
"end": 391,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 380,
"end": 384,
"loc": {
"start": {
"line": 14,
"column": 8
},
"end": {
"line": 14,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 385,
"end": 391,
"loc": {
"start": {
"line": 14,
"column": 13
},
"end": {
"line": 14,
"column": 19
},
"identifierName": "canvas"
},
"name": "canvas"
},
"computed": false
},
"right": {
"type": "NullLiteral",
"start": 394,
"end": 398,
"loc": {
"start": {
"line": 14,
"column": 22
},
"end": {
"line": 14,
"column": 26
}
}
}
}
},
{
"type": "ExpressionStatement",
"start": 408,
"end": 423,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 23
}
},
"expression": {
"type": "AssignmentExpression",
"start": 408,
"end": 422,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 22
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 408,
"end": 415,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 15
}
},
"object": {
"type": "ThisExpression",
"start": 408,
"end": 412,
"loc": {
"start": {
"line": 15,
"column": 8
},
"end": {
"line": 15,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 413,
"end": 415,
"loc": {
"start": {
"line": 15,
"column": 13
},
"end": {
"line": 15,
"column": 15
},
"identifierName": "GL"
},
"name": "GL"
},
"computed": false
},
"right": {
"type": "NullLiteral",
"start": 418,
"end": 422,
"loc": {
"start": {
"line": 15,
"column": 18
},
"end": {
"line": 15,
"column": 22
}
}
}
}
},
{
"type": "ExpressionStatement",
"start": 433,
"end": 454,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 29
}
},
"expression": {
"type": "AssignmentExpression",
"start": 433,
"end": 453,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 28
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 433,
"end": 449,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 24
}
},
"object": {
"type": "ThisExpression",
"start": 433,
"end": 437,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 438,
"end": 449,
"loc": {
"start": {
"line": 17,
"column": 13
},
"end": {
"line": 17,
"column": 24
},
"identifierName": "canvasWidth"
},
"name": "canvasWidth"
},
"computed": false
},
"right": {
"type": "NumericLiteral",
"start": 452,
"end": 453,
"loc": {
"start": {
"line": 17,
"column": 27
},
"end": {
"line": 17,
"column": 28
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
},
{
"type": "ExpressionStatement",
"start": 463,
"end": 485,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 30
}
},
"expression": {
"type": "AssignmentExpression",
"start": 463,
"end": 484,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 29
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 463,
"end": 480,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 25
}
},
"object": {
"type": "ThisExpression",
"start": 463,
"end": 467,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 468,
"end": 480,
"loc": {
"start": {
"line": 18,
"column": 13
},
"end": {
"line": 18,
"column": 25
},
"identifierName": "canvasHeight"
},
"name": "canvasHeight"
},
"computed": false
},
"right": {
"type": "NumericLiteral",
"start": 483,
"end": 484,
"loc": {
"start": {
"line": 18,
"column": 28
},
"end": {
"line": 18,
"column": 29
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
},
{
"type": "ExpressionStatement",
"start": 494,
"end": 518,
"loc": {
"start": {
"line": 19,
"column": 8
},
"end": {
"line": 19,
"column": 32
}
},
"expression": {
"type": "AssignmentExpression",
"start": 494,
"end": 517,
"loc": {
"start": {
"line": 19,
"column": 8
},
"end": {
"line": 19,
"column": 31
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 494,
"end": 513,
"loc": {
"start": {
"line": 19,
"column": 8
},
"end": {
"line": 19,
"column": 27
}
},
"object": {
"type": "ThisExpression",
"start": 494,
"end": 498,
"loc": {
"start": {
"line": 19,
"column": 8
},
"end": {
"line": 19,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 499,
"end": 513,
"loc": {
"start": {
"line": 19,
"column": 13
},
"end": {
"line": 19,
"column": 27
},
"identifierName": "canvasDPIWidth"
},
"name": "canvasDPIWidth"
},
"computed": false
},
"right": {
"type": "NumericLiteral",
"start": 516,
"end": 517,
"loc": {
"start": {
"line": 19,
"column": 30
},
"end": {
"line": 19,
"column": 31
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
},
{
"type": "ExpressionStatement",
"start": 527,
"end": 552,
"loc": {
"start": {
"line": 20,
"column": 8
},
"end": {
"line": 20,
"column": 33
}
},
"expression": {
"type": "AssignmentExpression",
"start": 527,
"end": 551,
"loc": {
"start": {
"line": 20,
"column": 8
},
"end": {
"line": 20,
"column": 32
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 527,
"end": 547,
"loc": {
"start": {
"line": 20,
"column": 8
},
"end": {
"line": 20,
"column": 28
}
},
"object": {
"type": "ThisExpression",
"start": 527,
"end": 531,
"loc": {
"start": {
"line": 20,
"column": 8
},
"end": {
"line": 20,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 532,
"end": 547,
"loc": {
"start": {
"line": 20,
"column": 13
},
"end": {
"line": 20,
"column": 28
},
"identifierName": "canvasDPIHeight"
},
"name": "canvasDPIHeight"
},
"computed": false
},
"right": {
"type": "NumericLiteral",
"start": 550,
"end": 551,
"loc": {
"start": {
"line": 20,
"column": 31
},
"end": {
"line": 20,
"column": 32
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Initializes defaults for the DOMManager to hold once started.\n ",
"start": 254,
"end": 334,
"loc": {
"start": {
"line": 9,
"column": 4
},
"end": {
"line": 11,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Loads the canvas & setup for WebGL.\n ",
"start": 564,
"end": 618,
"loc": {
"start": {
"line": 23,
"column": 4
},
"end": {
"line": 25,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 623,
"end": 688,
"loc": {
"start": {
"line": 26,
"column": 4
},
"end": {
"line": 29,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 623,
"end": 628,
"loc": {
"start": {
"line": 26,
"column": 4
},
"end": {
"line": 26,
"column": 9
},
"identifierName": "start"
},
"name": "start",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 631,
"end": 688,
"loc": {
"start": {
"line": 26,
"column": 12
},
"end": {
"line": 29,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 641,
"end": 659,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 26
}
},
"expression": {
"type": "CallExpression",
"start": 641,
"end": 658,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 25
}
},
"callee": {
"type": "MemberExpression",
"start": 641,
"end": 656,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 23
}
},
"object": {
"type": "ThisExpression",
"start": 641,
"end": 645,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 646,
"end": 656,
"loc": {
"start": {
"line": 27,
"column": 13
},
"end": {
"line": 27,
"column": 23
},
"identifierName": "loadCanvas"
},
"name": "loadCanvas"
},
"computed": false
},
"arguments": []
}
},
{
"type": "ExpressionStatement",
"start": 668,
"end": 682,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 22
}
},
"expression": {
"type": "CallExpression",
"start": 668,
"end": 681,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 21
}
},
"callee": {
"type": "MemberExpression",
"start": 668,
"end": 679,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 668,
"end": 672,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 673,
"end": 679,
"loc": {
"start": {
"line": 28,
"column": 13
},
"end": {
"line": 28,
"column": 19
},
"identifierName": "adjust"
},
"name": "adjust"
},
"computed": false
},
"arguments": []
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Loads the canvas & setup for WebGL.\n ",
"start": 564,
"end": 618,
"loc": {
"start": {
"line": 23,
"column": 4
},
"end": {
"line": 25,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Loads the canvas & sets up a WebGL2 context to be used by the engine by the id 'game'. If nothing is happening on screen,\n * ensure that the canvas you are using has this id in its HTML tag.\n ",
"start": 698,
"end": 911,
"loc": {
"start": {
"line": 31,
"column": 4
},
"end": {
"line": 34,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 916,
"end": 1498,
"loc": {
"start": {
"line": 35,
"column": 4
},
"end": {
"line": 46,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 916,
"end": 926,
"loc": {
"start": {
"line": 35,
"column": 4
},
"end": {
"line": 35,
"column": 14
},
"identifierName": "loadCanvas"
},
"name": "loadCanvas",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 929,
"end": 1498,
"loc": {
"start": {
"line": 35,
"column": 17
},
"end": {
"line": 46,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 939,
"end": 985,
"loc": {
"start": {
"line": 36,
"column": 8
},
"end": {
"line": 36,
"column": 54
}
},
"expression": {
"type": "AssignmentExpression",
"start": 939,
"end": 984,
"loc": {
"start": {
"line": 36,
"column": 8
},
"end": {
"line": 36,
"column": 53
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 939,
"end": 950,
"loc": {
"start": {
"line": 36,
"column": 8
},
"end": {
"line": 36,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 939,
"end": 943,
"loc": {
"start": {
"line": 36,
"column": 8
},
"end": {
"line": 36,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 944,
"end": 950,
"loc": {
"start": {
"line": 36,
"column": 13
},
"end": {
"line": 36,
"column": 19
},
"identifierName": "canvas"
},
"name": "canvas"
},
"computed": false
},
"right": {
"type": "CallExpression",
"start": 953,
"end": 984,
"loc": {
"start": {
"line": 36,
"column": 22
},
"end": {
"line": 36,
"column": 53
}
},
"callee": {
"type": "MemberExpression",
"start": 953,
"end": 976,
"loc": {
"start": {
"line": 36,
"column": 22
},
"end": {
"line": 36,
"column": 45
}
},
"object": {
"type": "Identifier",
"start": 953,
"end": 961,
"loc": {
"start": {
"line": 36,
"column": 22
},
"end": {
"line": 36,
"column": 30
},
"identifierName": "document"
},
"name": "document"
},
"property": {
"type": "Identifier",
"start": 962,
"end": 976,
"loc": {
"start": {
"line": 36,
"column": 31
},
"end": {
"line": 36,
"column": 45
},
"identifierName": "getElementById"
},
"name": "getElementById"
},
"computed": false
},
"arguments": [
{
"type": "StringLiteral",
"start": 977,
"end": 983,
"loc": {
"start": {
"line": 36,
"column": 46
},
"end": {
"line": 36,
"column": 52
}
},
"extra": {
"rawValue": "game",
"raw": "'game'"
},
"value": "game"
}
]
}
}
},
{
"type": "IfStatement",
"start": 994,
"end": 1107,
"loc": {
"start": {
"line": 37,
"column": 8
},
"end": {
"line": 38,
"column": 88
}
},
"test": {
"type": "BinaryExpression",
"start": 998,
"end": 1017,
"loc": {
"start": {
"line": 37,
"column": 12
},
"end": {
"line": 37,
"column": 31
}
},
"left": {
"type": "MemberExpression",
"start": 998,
"end": 1009,
"loc": {
"start": {
"line": 37,
"column": 12
},
"end": {
"line": 37,
"column": 23
}
},
"object"