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,370 lines (1,369 loc) • 248 kB
JSON
{
"type": "File",
"start": 0,
"end": 1883,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 62,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1883,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 62,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "ExportDefaultDeclaration",
"start": 170,
"end": 1883,
"loc": {
"start": {
"line": 7,
"column": 0
},
"end": {
"line": 62,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 185,
"end": 1883,
"loc": {
"start": {
"line": 7,
"column": 15
},
"end": {
"line": 62,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 191,
"end": 196,
"loc": {
"start": {
"line": 7,
"column": 21
},
"end": {
"line": 7,
"column": 26
},
"identifierName": "Color"
},
"name": "Color",
"leadingComments": null
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 197,
"end": 1883,
"loc": {
"start": {
"line": 7,
"column": 27
},
"end": {
"line": 62,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 491,
"end": 625,
"loc": {
"start": {
"line": 16,
"column": 4
},
"end": {
"line": 18,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 491,
"end": 502,
"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": "AssignmentPattern",
"start": 503,
"end": 508,
"loc": {
"start": {
"line": 16,
"column": 16
},
"end": {
"line": 16,
"column": 21
}
},
"left": {
"type": "Identifier",
"start": 503,
"end": 504,
"loc": {
"start": {
"line": 16,
"column": 16
},
"end": {
"line": 16,
"column": 17
},
"identifierName": "r"
},
"name": "r"
},
"right": {
"type": "NumericLiteral",
"start": 507,
"end": 508,
"loc": {
"start": {
"line": 16,
"column": 20
},
"end": {
"line": 16,
"column": 21
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
{
"type": "AssignmentPattern",
"start": 510,
"end": 515,
"loc": {
"start": {
"line": 16,
"column": 23
},
"end": {
"line": 16,
"column": 28
}
},
"left": {
"type": "Identifier",
"start": 510,
"end": 511,
"loc": {
"start": {
"line": 16,
"column": 23
},
"end": {
"line": 16,
"column": 24
},
"identifierName": "g"
},
"name": "g"
},
"right": {
"type": "NumericLiteral",
"start": 514,
"end": 515,
"loc": {
"start": {
"line": 16,
"column": 27
},
"end": {
"line": 16,
"column": 28
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
{
"type": "AssignmentPattern",
"start": 517,
"end": 522,
"loc": {
"start": {
"line": 16,
"column": 30
},
"end": {
"line": 16,
"column": 35
}
},
"left": {
"type": "Identifier",
"start": 517,
"end": 518,
"loc": {
"start": {
"line": 16,
"column": 30
},
"end": {
"line": 16,
"column": 31
},
"identifierName": "b"
},
"name": "b"
},
"right": {
"type": "NumericLiteral",
"start": 521,
"end": 522,
"loc": {
"start": {
"line": 16,
"column": 34
},
"end": {
"line": 16,
"column": 35
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
},
{
"type": "AssignmentPattern",
"start": 524,
"end": 529,
"loc": {
"start": {
"line": 16,
"column": 37
},
"end": {
"line": 16,
"column": 42
}
},
"left": {
"type": "Identifier",
"start": 524,
"end": 525,
"loc": {
"start": {
"line": 16,
"column": 37
},
"end": {
"line": 16,
"column": 38
},
"identifierName": "a"
},
"name": "a"
},
"right": {
"type": "NumericLiteral",
"start": 528,
"end": 529,
"loc": {
"start": {
"line": 16,
"column": 41
},
"end": {
"line": 16,
"column": 42
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
],
"body": {
"type": "BlockStatement",
"start": 531,
"end": 625,
"loc": {
"start": {
"line": 16,
"column": 44
},
"end": {
"line": 18,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 541,
"end": 619,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 86
}
},
"expression": {
"type": "AssignmentExpression",
"start": 541,
"end": 618,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 85
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 541,
"end": 551,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 18
}
},
"object": {
"type": "ThisExpression",
"start": 541,
"end": 545,
"loc": {
"start": {
"line": 17,
"column": 8
},
"end": {
"line": 17,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 546,
"end": 551,
"loc": {
"start": {
"line": 17,
"column": 13
},
"end": {
"line": 17,
"column": 18
},
"identifierName": "color"
},
"name": "color"
},
"computed": false
},
"right": {
"type": "ArrayExpression",
"start": 554,
"end": 618,
"loc": {
"start": {
"line": 17,
"column": 21
},
"end": {
"line": 17,
"column": 85
}
},
"elements": [
{
"type": "CallExpression",
"start": 555,
"end": 569,
"loc": {
"start": {
"line": 17,
"column": 22
},
"end": {
"line": 17,
"column": 36
}
},
"callee": {
"type": "MemberExpression",
"start": 555,
"end": 566,
"loc": {
"start": {
"line": 17,
"column": 22
},
"end": {
"line": 17,
"column": 33
}
},
"object": {
"type": "ThisExpression",
"start": 555,
"end": 559,
"loc": {
"start": {
"line": 17,
"column": 22
},
"end": {
"line": 17,
"column": 26
}
}
},
"property": {
"type": "Identifier",
"start": 560,
"end": 566,
"loc": {
"start": {
"line": 17,
"column": 27
},
"end": {
"line": 17,
"column": 33
},
"identifierName": "minmax"
},
"name": "minmax"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 567,
"end": 568,
"loc": {
"start": {
"line": 17,
"column": 34
},
"end": {
"line": 17,
"column": 35
},
"identifierName": "r"
},
"name": "r"
}
]
},
{
"type": "CallExpression",
"start": 571,
"end": 585,
"loc": {
"start": {
"line": 17,
"column": 38
},
"end": {
"line": 17,
"column": 52
}
},
"callee": {
"type": "MemberExpression",
"start": 571,
"end": 582,
"loc": {
"start": {
"line": 17,
"column": 38
},
"end": {
"line": 17,
"column": 49
}
},
"object": {
"type": "ThisExpression",
"start": 571,
"end": 575,
"loc": {
"start": {
"line": 17,
"column": 38
},
"end": {
"line": 17,
"column": 42
}
}
},
"property": {
"type": "Identifier",
"start": 576,
"end": 582,
"loc": {
"start": {
"line": 17,
"column": 43
},
"end": {
"line": 17,
"column": 49
},
"identifierName": "minmax"
},
"name": "minmax"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 583,
"end": 584,
"loc": {
"start": {
"line": 17,
"column": 50
},
"end": {
"line": 17,
"column": 51
},
"identifierName": "g"
},
"name": "g"
}
]
},
{
"type": "CallExpression",
"start": 587,
"end": 601,
"loc": {
"start": {
"line": 17,
"column": 54
},
"end": {
"line": 17,
"column": 68
}
},
"callee": {
"type": "MemberExpression",
"start": 587,
"end": 598,
"loc": {
"start": {
"line": 17,
"column": 54
},
"end": {
"line": 17,
"column": 65
}
},
"object": {
"type": "ThisExpression",
"start": 587,
"end": 591,
"loc": {
"start": {
"line": 17,
"column": 54
},
"end": {
"line": 17,
"column": 58
}
}
},
"property": {
"type": "Identifier",
"start": 592,
"end": 598,
"loc": {
"start": {
"line": 17,
"column": 59
},
"end": {
"line": 17,
"column": 65
},
"identifierName": "minmax"
},
"name": "minmax"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 599,
"end": 600,
"loc": {
"start": {
"line": 17,
"column": 66
},
"end": {
"line": 17,
"column": 67
},
"identifierName": "b"
},
"name": "b"
}
]
},
{
"type": "CallExpression",
"start": 603,
"end": 617,
"loc": {
"start": {
"line": 17,
"column": 70
},
"end": {
"line": 17,
"column": 84
}
},
"callee": {
"type": "MemberExpression",
"start": 603,
"end": 614,
"loc": {
"start": {
"line": 17,
"column": 70
},
"end": {
"line": 17,
"column": 81
}
},
"object": {
"type": "ThisExpression",
"start": 603,
"end": 607,
"loc": {
"start": {
"line": 17,
"column": 70
},
"end": {
"line": 17,
"column": 74
}
}
},
"property": {
"type": "Identifier",
"start": 608,
"end": 614,
"loc": {
"start": {
"line": 17,
"column": 75
},
"end": {
"line": 17,
"column": 81
},
"identifierName": "minmax"
},
"name": "minmax"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 615,
"end": 616,
"loc": {
"start": {
"line": 17,
"column": 82
},
"end": {
"line": 17,
"column": 83
},
"identifierName": "a"
},
"name": "a"
}
]
}
]
}
}
}
],
"directives": []
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Builds a color into an array for easy access for WebGL.\n * \n * @param {number} r Red value between 0 - 1\n * @param {number} g Green value between 0 - 1\n * @param {number} b Blue value between 0 - 1\n * @param {number} a Alpha value between 0 - 1\n ",
"start": 203,
"end": 486,
"loc": {
"start": {
"line": 8,
"column": 4
},
"end": {
"line": 15,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 631,
"end": 718,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 22,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 631,
"end": 637,
"loc": {
"start": {
"line": 20,
"column": 4
},
"end": {
"line": 20,
"column": 10
},
"identifierName": "minmax"
},
"name": "minmax"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 638,
"end": 641,
"loc": {
"start": {
"line": 20,
"column": 11
},
"end": {
"line": 20,
"column": 14
},
"identifierName": "val"
},
"name": "val"
},
{
"type": "AssignmentPattern",
"start": 643,
"end": 650,
"loc": {
"start": {
"line": 20,
"column": 16
},
"end": {
"line": 20,
"column": 23
}
},
"left": {
"type": "Identifier",
"start": 643,
"end": 646,
"loc": {
"start": {
"line": 20,
"column": 16
},
"end": {
"line": 20,
"column": 19
},
"identifierName": "min"
},
"name": "min"
},
"right": {
"type": "NumericLiteral",
"start": 649,
"end": 650,
"loc": {
"start": {
"line": 20,
"column": 22
},
"end": {
"line": 20,
"column": 23
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
},
{
"type": "AssignmentPattern",
"start": 652,
"end": 659,
"loc": {
"start": {
"line": 20,
"column": 25
},
"end": {
"line": 20,
"column": 32
}
},
"left": {
"type": "Identifier",
"start": 652,
"end": 655,
"loc": {
"start": {
"line": 20,
"column": 25
},
"end": {
"line": 20,
"column": 28
},
"identifierName": "max"
},
"name": "max"
},
"right": {
"type": "NumericLiteral",
"start": 658,
"end": 659,
"loc": {
"start": {
"line": 20,
"column": 31
},
"end": {
"line": 20,
"column": 32
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
}
],
"body": {
"type": "BlockStatement",
"start": 661,
"end": 718,
"loc": {
"start": {
"line": 20,
"column": 34
},
"end": {
"line": 22,
"column": 5
}
},
"body": [
{
"type": "ReturnStatement",
"start": 671,
"end": 712,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 49
}
},
"argument": {
"type": "CallExpression",
"start": 678,
"end": 711,
"loc": {
"start": {
"line": 21,
"column": 15
},
"end": {
"line": 21,
"column": 48
}
},
"callee": {
"type": "MemberExpression",
"start": 678,
"end": 686,
"loc": {
"start": {
"line": 21,
"column": 15
},
"end": {
"line": 21,
"column": 23
}
},
"object": {
"type": "Identifier",
"start": 678,
"end": 682,
"loc": {
"start": {
"line": 21,
"column": 15
},
"end": {
"line": 21,
"column": 19
},
"identifierName": "Math"
},
"name": "Math"
},
"property": {
"type": "Identifier",
"start": 683,
"end": 686,
"loc": {
"start": {
"line": 21,
"column": 20
},
"end": {
"line": 21,
"column": 23
},
"identifierName": "max"
},
"name": "max"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 687,
"end": 690,
"loc": {
"start": {
"line": 21,
"column": 24
},
"end": {
"line": 21,
"column": 27
},
"identifierName": "min"
},
"name": "min"
},
{
"type": "CallExpression",
"start": 692,
"end": 710,
"loc": {
"start": {
"line": 21,
"column": 29
},
"end": {
"line": 21,
"column": 47
}
},
"callee": {
"type": "MemberExpression",
"start": 692,
"end": 700,
"loc": {
"start": {
"line": 21,
"column": 29
},
"end": {
"line": 21,
"column": 37
}
},
"object": {
"type": "Identifier",
"start": 692,
"end": 696,
"loc": {
"start": {
"line": 21,
"column": 29
},
"end": {
"line": 21,
"column": 33
},
"identifierName": "Math"
},
"name": "Math"
},
"property": {
"type": "Identifier",
"start": 697,
"end": 700,
"loc": {
"start": {
"line": 21,
"column": 34
},
"end": {
"line": 21,
"column": 37
},
"identifierName": "min"
},
"name": "min"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 701,
"end": 704,
"loc": {
"start": {
"line": 21,
"column": 38
},
"end": {
"line": 21,
"column": 41
},
"identifierName": "max"
},
"name": "max"
},
{
"type": "Identifier",
"start": 706,
"end": 709,
"loc": {
"start": {
"line": 21,
"column": 43
},
"end": {
"line": 21,
"column": 46
},
"identifierName": "val"
},
"name": "val"
}
]
}
]
}
}
],
"directives": [],
"trailingComments": null
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * \n * @param {number} r Red value between 0 - 1. Defaults to previous value.\n * @param {number} g Green value between 0 - 1. Defaults to previous value.\n * @param {number} b Blue value between 0 - 1. Defaults to previous value.\n * @param {number} a Alpha value between 0 - 1. Defaults to previous value.\n ",
"start": 724,
"end": 1060,
"loc": {
"start": {
"line": 24,
"column": 4
},
"end": {
"line": 30,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 1065,
"end": 1239,
"loc": {
"start": {
"line": 31,
"column": 4
},
"end": {
"line": 33,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 1065,
"end": 1068,
"loc": {
"start": {
"line": 31,
"column": 4
},
"end": {
"line": 31,
"column": 7
},
"identifierName": "set"
},
"name": "set",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 1069,
"end": 1086,
"loc": {
"start": {
"line": 31,
"column": 8
},
"end": {
"line": 31,
"column": 25
}
},
"left": {
"type": "Identifier",
"start": 1069,
"end": 1070,
"loc": {
"start": {
"line": 31,
"column": 8
},
"end": {
"line": 31,
"column": 9
},
"identifierName": "r"
},
"name": "r"
},
"right": {
"type": "MemberExpression",
"start": 1073,
"end": 1086,
"loc": {
"start": {
"line": 31,
"column": 12
},
"end": {
"line": 31,
"column": 25
}
},
"object": {
"type": "MemberExpression",
"start": 1073,
"end": 1083,
"loc": {
"start": {
"line": 31,
"column": 12
},
"end": {
"line": 31,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 1073,
"end": 1077,
"loc": {
"start": {
"line": 31,
"column": 12
},
"end": {
"line": 31,
"column": 16
}
}
},
"property": {
"type": "Identifier",
"start": 1078,
"end": 1083,
"loc": {
"start": {
"line": 31,
"column": 17
},
"end": {
"line": 31,
"column": 22
},
"identifierName": "color"
},
"name": "color"
},
"computed": false
},
"property": {
"type": "NumericLiteral",
"start": 1084,
"end": 1085,
"loc": {
"start": {
"line": 31,
"column": 23
},
"end": {
"line": 31,
"column": 24
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
},
"computed": true
}
},
{
"type": "AssignmentPattern",
"start": 1088,
"end": 1105,
"loc": {
"start": {
"line": 31,
"column": 27
},
"end": {
"line": 31,
"column": 44