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,393 lines (1,392 loc) • 142 kB
JSON
{
"type": "File",
"start": 0,
"end": 1332,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 43,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1332,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 43,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "Point"
},
"name": "Point"
}
}
],
"source": {
"type": "StringLiteral",
"start": 18,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 27
}
},
"extra": {
"rawValue": "./Point",
"raw": "'./Point'"
},
"value": "./Point"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Two points which represent a bounding square.\n * \n * TODO: Add z index for 3D.\n ",
"start": 30,
"end": 119,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 7,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 120,
"end": 1332,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 43,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 135,
"end": 1332,
"loc": {
"start": {
"line": 8,
"column": 15
},
"end": {
"line": 43,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 141,
"end": 147,
"loc": {
"start": {
"line": 8,
"column": 21
},
"end": {
"line": 8,
"column": 27
},
"identifierName": "Bounds"
},
"name": "Bounds",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 148,
"end": 1332,
"loc": {
"start": {
"line": 8,
"column": 28
},
"end": {
"line": 43,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 473,
"end": 574,
"loc": {
"start": {
"line": 16,
"column": 4
},
"end": {
"line": 19,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 473,
"end": 484,
"loc": {
"start": {
"line": 16,
"column": 4
},
"end": {
"line": 16,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor",
"leadingComments": null
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 485,
"end": 486,
"loc": {
"start": {
"line": 16,
"column": 16
},
"end": {
"line": 16,
"column": 17
},
"identifierName": "x"
},
"name": "x"
},
{
"type": "Identifier",
"start": 488,
"end": 489,
"loc": {
"start": {
"line": 16,
"column": 19
},
"end": {
"line": 16,
"column": 20
},
"identifierName": "y"
},
"name": "y"
},
{
"type": "Identifier",
"start": 491,
"end": 492,
"loc": {
"start": {
"line": 16,
"column": 22
},
"end": {
"line": 16,
"column": 23
},
"identifierName": "w"
},
"name": "w"
},
{
"type": "Identifier",
"start": 494,
"end": 495,
"loc": {
"start": {
"line": 16,
"column": 25
},
"end": {
"line": 16,
"column": 26
},
"identifierName": "h"
},
"name": "h"
}
],
"body": {
"type": "BlockStatement",
"start": 497,
"end": 574,
"loc": {
"start": {
"line": 16,
"column": 28
},
"end": {
"line": 19,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 507,
"end": 533,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 34
}
},
"expression": {
"type": "AssignmentExpression",
"start": 507,
"end": 532,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 33
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 507,
"end": 514,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 15
}
},
"object": {
"type": "ThisExpression",
"start": 507,
"end": 511,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 512,
"end": 514,
"loc": {
"start": {
"line": 17,
"column": 13
},
"end": {
"line": 17,
"column": 15
},
"identifierName": "p1"
},
"name": "p1"
},
"computed": false
},
"right": {
"type": "NewExpression",
"start": 517,
"end": 532,
"loc": {
"start": {
"line": 17,
"column": 18
},
"end": {
"line": 17,
"column": 33
}
},
"callee": {
"type": "Identifier",
"start": 521,
"end": 526,
"loc": {
"start": {
"line": 17,
"column": 22
},
"end": {
"line": 17,
"column": 27
},
"identifierName": "Point"
},
"name": "Point"
},
"arguments": [
{
"type": "Identifier",
"start": 527,
"end": 528,
"loc": {
"start": {
"line": 17,
"column": 28
},
"end": {
"line": 17,
"column": 29
},
"identifierName": "x"
},
"name": "x"
},
{
"type": "Identifier",
"start": 530,
"end": 531,
"loc": {
"start": {
"line": 17,
"column": 31
},
"end": {
"line": 17,
"column": 32
},
"identifierName": "y"
},
"name": "y"
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 542,
"end": 568,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 34
}
},
"expression": {
"type": "AssignmentExpression",
"start": 542,
"end": 567,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 33
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 542,
"end": 549,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 15
}
},
"object": {
"type": "ThisExpression",
"start": 542,
"end": 546,
"loc": {
"start": {
"line": 18,
"column": 8
},
"end": {
"line": 18,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 547,
"end": 549,
"loc": {
"start": {
"line": 18,
"column": 13
},
"end": {
"line": 18,
"column": 15
},
"identifierName": "p2"
},
"name": "p2"
},
"computed": false
},
"right": {
"type": "NewExpression",
"start": 552,
"end": 567,
"loc": {
"start": {
"line": 18,
"column": 18
},
"end": {
"line": 18,
"column": 33
}
},
"callee": {
"type": "Identifier",
"start": 556,
"end": 561,
"loc": {
"start": {
"line": 18,
"column": 22
},
"end": {
"line": 18,
"column": 27
},
"identifierName": "Point"
},
"name": "Point"
},
"arguments": [
{
"type": "Identifier",
"start": 562,
"end": 563,
"loc": {
"start": {
"line": 18,
"column": 28
},
"end": {
"line": 18,
"column": 29
},
"identifierName": "w"
},
"name": "w"
},
{
"type": "Identifier",
"start": 565,
"end": 566,
"loc": {
"start": {
"line": 18,
"column": 31
},
"end": {
"line": 18,
"column": 32
},
"identifierName": "h"
},
"name": "h"
}
]
}
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * \n * @param {number} x The x position of the bounding box. (x1)\n * @param {number} y The y position of the bounding box. (y1)\n * @param {number} w The end x position, or width, of the bounding box. (x2)\n * @param {number} h The end x position, or height, of the bounding box. (y2)\n ",
"start": 154,
"end": 468,
"loc": {
"start": {
"line": 9,
"column": 4
},
"end": {
"line": 15,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Sets the bounding box to a new position.\n * \n * @param {number} x The x position of the bounding box. (x1)\n * @param {number} y The y position of the bounding box. (y1)\n * @param {number} w The end x position, or width, of the bounding box. (x2)\n * @param {number} h The end x position, or height, of the bounding box. (y2)\n ",
"start": 580,
"end": 942,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 28,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 947,
"end": 1024,
"loc": {
"start": {
"line": 29,
"column": 4
},
"end": {
"line": 32,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 947,
"end": 950,
"loc": {
"start": {
"line": 29,
"column": 4
},
"end": {
"line": 29,
"column": 7
},
"identifierName": "set"
},
"name": "set",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 951,
"end": 952,
"loc": {
"start": {
"line": 29,
"column": 8
},
"end": {
"line": 29,
"column": 9
},
"identifierName": "x"
},
"name": "x"
},
{
"type": "Identifier",
"start": 954,
"end": 955,
"loc": {
"start": {
"line": 29,
"column": 11
},
"end": {
"line": 29,
"column": 12
},
"identifierName": "y"
},
"name": "y"
},
{
"type": "Identifier",
"start": 957,
"end": 958,
"loc": {
"start": {
"line": 29,
"column": 14
},
"end": {
"line": 29,
"column": 15
},
"identifierName": "w"
},
"name": "w"
},
{
"type": "Identifier",
"start": 960,
"end": 961,
"loc": {
"start": {
"line": 29,
"column": 17
},
"end": {
"line": 29,
"column": 18
},
"identifierName": "h"
},
"name": "h"
}
],
"body": {
"type": "BlockStatement",
"start": 963,
"end": 1024,
"loc": {
"start": {
"line": 29,
"column": 20
},
"end": {
"line": 32,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 973,
"end": 991,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 26
}
},
"expression": {
"type": "CallExpression",
"start": 973,
"end": 990,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 25
}
},
"callee": {
"type": "MemberExpression",
"start": 973,
"end": 984,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 19
}
},
"object": {
"type": "MemberExpression",
"start": 973,
"end": 980,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 15
}
},
"object": {
"type": "ThisExpression",
"start": 973,
"end": 977,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 978,
"end": 980,
"loc": {
"start": {
"line": 30,
"column": 13
},
"end": {
"line": 30,
"column": 15
},
"identifierName": "p1"
},
"name": "p1"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 981,
"end": 984,
"loc": {
"start": {
"line": 30,
"column": 16
},
"end": {
"line": 30,
"column": 19
},
"identifierName": "set"
},
"name": "set"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 985,
"end": 986,
"loc": {
"start": {
"line": 30,
"column": 20
},
"end": {
"line": 30,
"column": 21
},
"identifierName": "x"
},
"name": "x"
},
{
"type": "Identifier",
"start": 988,
"end": 989,
"loc": {
"start": {
"line": 30,
"column": 23
},
"end": {
"line": 30,
"column": 24
},
"identifierName": "y"
},
"name": "y"
}
]
}
},
{
"type": "ExpressionStatement",
"start": 1000,
"end": 1018,
"loc": {
"start": {
"line": 31,
"column": 8
},
"end": {
"line": 31,
"column": 26
}
},
"expression": {
"type": "CallExpression",
"start": 1000,
"end": 1017,
"loc": {
"start": {
"line": 31,
"column": 8
},
"end": {
"line": 31,
"column": 25
}
},
"callee": {
"type": "MemberExpression",
"start": 1000,
"end": 1011,
"loc": {
"start": {
"line": 31,
"column": 8
},
"end": {
"line": 31,
"column": 19
}
},
"object": {
"type": "MemberExpression",
"start": 1000,
"end": 1007,
"loc": {
"start": {
"line": 31,
"column": 8
},
"end": {
"line": 31,
"column": 15
}
},
"object": {
"type": "ThisExpression",
"start": 1000,
"end": 1004,
"loc": {
"start": {
"line": 31,
"column": 8
},
"end": {
"line": 31,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1005,
"end": 1007,
"loc": {
"start": {
"line": 31,
"column": 13
},
"end": {
"line": 31,
"column": 15
},
"identifierName": "p2"
},
"name": "p2"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 1008,
"end": 1011,
"loc": {
"start": {
"line": 31,
"column": 16
},
"end": {
"line": 31,
"column": 19
},
"identifierName": "set"
},
"name": "set"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 1012,
"end": 1013,
"loc": {
"start": {
"line": 31,
"column": 20
},
"end": {
"line": 31,
"column": 21
},
"identifierName": "w"
},
"name": "w"
},
{
"type": "Identifier",
"start": 1015,
"end": 1016,
"loc": {
"start": {
"line": 31,
"column": 23
},
"end": {
"line": 31,
"column": 24
},
"identifierName": "h"
},
"name": "h"
}
]
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Sets the bounding box to a new position.\n * \n * @param {number} x The x position of the bounding box. (x1)\n * @param {number} y The y position of the bounding box. (y1)\n * @param {number} w The end x position, or width, of the bounding box. (x2)\n * @param {number} h The end x position, or height, of the bounding box. (y2)\n ",
"start": 580,
"end": 942,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 28,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Checks to see if the point [parameter 0] is within bounds.\n * \n * @param {Point} point Point to check within bounds.\n ",
"start": 1030,
"end": 1173,
"loc": {
"start": {
"line": 34,
"column": 4
},
"end": {
"line": 38,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 1178,
"end": 1330,
"loc": {
"start": {
"line": 39,
"column": 4
},
"end": {
"line": 42,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 1178,
"end": 1188,
"loc": {
"start": {
"line": 39,
"column": 4
},
"end": {
"line": 39,
"column": 14
},
"identifierName": "isInBounds"
},
"name": "isInBounds",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1189,
"end": 1194,
"loc": {
"start": {
"line": 39,
"column": 15
},
"end": {
"line": 39,
"column": 20
},
"identifierName": "point"
},
"name": "point"
}
],
"body": {
"type": "BlockStatement",
"start": 1196,
"end": 1330,
"loc": {
"start": {
"line": 39,
"column": 22
},
"end": {
"line": 42,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 1206,
"end": 1324,
"loc": {
"start": {
"line": 40,
"column": 8
},
"end": {
"line": 41,
"column": 65
}
},
"argument": {
"type": "LogicalExpression",
"start": 1214,
"end": 1322,
"loc": {
"start": {
"line": 40,
"column": 16
},
"end": {
"line": 41,
"column": 63
}
},
"left": {
"type": "LogicalExpression",
"start": 1214,
"end": 1298,
"loc": {
"start": {
"line": 40,
"column": 16
},
"end": {
"line": 41,
"column": 39
}
},
"left": {
"type": "LogicalExpression",
"start": 1214,
"end": 1258,
"loc": {
"start": {
"line": 40,
"column": 16
},
"end": {
"line": 40,
"column": 60
}
},
"left": {
"type": "BinaryExpression",
"start": 1214,
"end": 1234,
"loc": {
"start": {
"line": 40,
"column": 16
},
"end": {
"line": 40,
"column": 36
}
},
"left": {
"type": "MemberExpression",
"start": 1214,
"end": 1221,
"loc": {
"start": {
"line": 40,
"column": 16
},
"end": {
"line": 40,
"column": 23
}
},
"object": {
"type": "Identifier",
"start": 1214,
"end": 1219,
"loc": {
"start": {
"line": 40,
"column": 16
},
"end": {
"line": 40,
"column": 21
},
"identifierName": "point"
},
"name": "point"
},
"property": {
"type": "Identifier",
"start": 1220,
"end": 1221,
"loc": {
"start": {
"line": 40,
"column": 22
},
"end": {
"line": 40,
"column": 23
},
"identifierName": "x"
},
"name": "x"
},
"computed": false
},
"operator": ">=",
"right": {
"type": "MemberExpression",
"start": 1225,
"end": 1234,
"loc": {
"start": {
"line": 40,
"column": 27
},
"end": {
"line": 40,
"column": 36
}
},
"object": {
"type": "MemberExpression",
"start": 1225,
"end": 1232,
"loc": {
"start": {
"line": 40,
"column": 27
},
"end": {
"line": 40,
"column": 34
}
},
"object": {
"type": "ThisExpression",
"start": 1225,
"end": 1229,
"loc": {
"start": {
"line": 40,
"column": 27
},
"end": {
"line": 40,
"column": 31
}
}
},
"property": {
"type": "Identifier",
"start": 1230,
"end": 1232,
"loc": {
"start": {
"line": 40,
"column": 32
},
"end": {
"line": 40,
"column": 34
},
"identifierName": "p1"
},
"name": "p1"
},
"computed": false
},
"property": {
"type": "Identifier",
"start": 1233,
"end": 1234,
"loc": {
"start": {
"line": 40,
"column": 35
},
"end": {
"line": 40,
"column": 36
},
"identifierName": "x"
},
"name": "x"
},
"computed": false
}
},
"operator": "&&",
"right": {
"type": "BinaryExpression",
"start": 1238,
"end": 1258,
"loc": {
"start": {
"line": 40,
"column": 40
},
"end": {
"line": 40,
"column": 60
}
},
"left": {
"type": "MemberExpression",
"start": 1238,
"end": 1245,