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,453 lines • 702 kB
JSON
{
"type": "File",
"start": 0,
"end": 6344,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 197,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 6344,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 197,
"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"
}
},
{
"type": "ImportDeclaration",
"start": 37,
"end": 75,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 38
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 44,
"end": 49,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
}
},
"local": {
"type": "Identifier",
"start": 44,
"end": 49,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 12
},
"identifierName": "Point"
},
"name": "Point"
}
}
],
"source": {
"type": "StringLiteral",
"start": 55,
"end": 74,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 37
}
},
"extra": {
"rawValue": "../internal/Point",
"raw": "'../internal/Point'"
},
"value": "../internal/Point"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * A component all GameObjects are given by default on instantiation.\n * \n * Transform components are unique to the object, meaning there cannot be more than\n * one Transform on a GameObject.\n * \n * Transforms keep track of GameObject position, scale (size), rotation, and \n * origin offset. These should be changes with their respective setters, and not directly,\n * to ensure the correct components are notified of these changes.\n * \n * TODO: Make rotation work on 3 axis like position and scale.\n * TODO: Change the updates and setters of the position/scale/rotation to use funcions in their base\n * definitions and remove the wrappers here to reduce code.\n ",
"start": 77,
"end": 744,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 17,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 745,
"end": 6344,
"loc": {
"start": {
"line": 18,
"column": 0
},
"end": {
"line": 197,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 760,
"end": 6344,
"loc": {
"start": {
"line": 18,
"column": 15
},
"end": {
"line": 197,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 766,
"end": 775,
"loc": {
"start": {
"line": 18,
"column": 21
},
"end": {
"line": 18,
"column": 30
},
"identifierName": "Transform"
},
"name": "Transform",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 784,
"end": 793,
"loc": {
"start": {
"line": 18,
"column": 39
},
"end": {
"line": 18,
"column": 48
},
"identifierName": "Component"
},
"name": "Component"
},
"body": {
"type": "ClassBody",
"start": 794,
"end": 6344,
"loc": {
"start": {
"line": 18,
"column": 49
},
"end": {
"line": 197,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 800,
"end": 1129,
"loc": {
"start": {
"line": 19,
"column": 4
},
"end": {
"line": 27,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 800,
"end": 811,
"loc": {
"start": {
"line": 19,
"column": 4
},
"end": {
"line": 19,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor"
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 812,
"end": 841,
"loc": {
"start": {
"line": 19,
"column": 16
},
"end": {
"line": 19,
"column": 45
}
},
"left": {
"type": "Identifier",
"start": 812,
"end": 820,
"loc": {
"start": {
"line": 19,
"column": 16
},
"end": {
"line": 19,
"column": 24
},
"identifierName": "position"
},
"name": "position"
},
"right": {
"type": "NewExpression",
"start": 823,
"end": 841,
"loc": {
"start": {
"line": 19,
"column": 27
},
"end": {
"line": 19,
"column": 45
}
},
"callee": {
"type": "Identifier",
"start": 827,
"end": 832,
"loc": {
"start": {
"line": 19,
"column": 31
},
"end": {
"line": 19,
"column": 36
},
"identifierName": "Point"
},
"name": "Point"
},
"arguments": [
{
"type": "NumericLiteral",
"start": 833,
"end": 834,
"loc": {
"start": {
"line": 19,
"column": 37
},
"end": {
"line": 19,
"column": 38
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
},
{
"type": "NumericLiteral",
"start": 836,
"end": 837,
"loc": {
"start": {
"line": 19,
"column": 40
},
"end": {
"line": 19,
"column": 41
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
},
{
"type": "NumericLiteral",
"start": 839,
"end": 840,
"loc": {
"start": {
"line": 19,
"column": 43
},
"end": {
"line": 19,
"column": 44
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
]
}
},
{
"type": "AssignmentPattern",
"start": 843,
"end": 869,
"loc": {
"start": {
"line": 19,
"column": 47
},
"end": {
"line": 19,
"column": 73
}
},
"left": {
"type": "Identifier",
"start": 843,
"end": 848,
"loc": {
"start": {
"line": 19,
"column": 47
},
"end": {
"line": 19,
"column": 52
},
"identifierName": "scale"
},
"name": "scale"
},
"right": {
"type": "NewExpression",
"start": 851,
"end": 869,
"loc": {
"start": {
"line": 19,
"column": 55
},
"end": {
"line": 19,
"column": 73
}
},
"callee": {
"type": "Identifier",
"start": 855,
"end": 860,
"loc": {
"start": {
"line": 19,
"column": 59
},
"end": {
"line": 19,
"column": 64
},
"identifierName": "Point"
},
"name": "Point"
},
"arguments": [
{
"type": "NumericLiteral",
"start": 861,
"end": 862,
"loc": {
"start": {
"line": 19,
"column": 65
},
"end": {
"line": 19,
"column": 66
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
{
"type": "NumericLiteral",
"start": 864,
"end": 865,
"loc": {
"start": {
"line": 19,
"column": 68
},
"end": {
"line": 19,
"column": 69
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
{
"type": "NumericLiteral",
"start": 867,
"end": 868,
"loc": {
"start": {
"line": 19,
"column": 71
},
"end": {
"line": 19,
"column": 72
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
]
}
},
{
"type": "AssignmentPattern",
"start": 871,
"end": 883,
"loc": {
"start": {
"line": 19,
"column": 75
},
"end": {
"line": 19,
"column": 87
}
},
"left": {
"type": "Identifier",
"start": 871,
"end": 879,
"loc": {
"start": {
"line": 19,
"column": 75
},
"end": {
"line": 19,
"column": 83
},
"identifierName": "rotation"
},
"name": "rotation"
},
"right": {
"type": "NumericLiteral",
"start": 882,
"end": 883,
"loc": {
"start": {
"line": 19,
"column": 86
},
"end": {
"line": 19,
"column": 87
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
],
"body": {
"type": "BlockStatement",
"start": 885,
"end": 1129,
"loc": {
"start": {
"line": 19,
"column": 89
},
"end": {
"line": 27,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 895,
"end": 907,
"loc": {
"start": {
"line": 20,
"column": 8
},
"end": {
"line": 20,
"column": 20
}
},
"expression": {
"type": "CallExpression",
"start": 895,
"end": 906,
"loc": {
"start": {
"line": 20,
"column": 8
},
"end": {
"line": 20,
"column": 19
}
},
"callee": {
"type": "Super",
"start": 895,
"end": 900,
"loc": {
"start": {
"line": 20,
"column": 8
},
"end": {
"line": 20,
"column": 13
}
}
},
"arguments": [
{
"type": "BooleanLiteral",
"start": 901,
"end": 905,
"loc": {
"start": {
"line": 20,
"column": 14
},
"end": {
"line": 20,
"column": 18
}
},
"value": true
}
]
}
},
{
"type": "ExpressionStatement",
"start": 916,
"end": 943,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 35
}
},
"expression": {
"type": "AssignmentExpression",
"start": 916,
"end": 942,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 34
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 916,
"end": 930,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 916,
"end": 920,
"loc": {
"start": {
"line": 21,
"column": 8
},
"end": {
"line": 21,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 921,
"end": 930,
"loc": {
"start": {
"line": 21,
"column": 13
},
"end": {
"line": 21,
"column": 22
},
"identifierName": "className"
},
"name": "className"
},
"computed": false
},
"right": {
"type": "StringLiteral",
"start": 931,
"end": 942,
"loc": {
"start": {
"line": 21,
"column": 23
},
"end": {
"line": 21,
"column": 34
}
},
"extra": {
"rawValue": "Transform",
"raw": "'Transform'"
},
"value": "Transform"
}
}
},
{
"type": "ExpressionStatement",
"start": 952,
"end": 978,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 34
}
},
"expression": {
"type": "AssignmentExpression",
"start": 952,
"end": 977,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 33
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 952,
"end": 966,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 952,
"end": 956,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 957,
"end": 966,
"loc": {
"start": {
"line": 22,
"column": 13
},
"end": {
"line": 22,
"column": 22
},
"identifierName": "_position"
},
"name": "_position"
},
"computed": false
},
"right": {
"type": "Identifier",
"start": 969,
"end": 977,
"loc": {
"start": {
"line": 22,
"column": 25
},
"end": {
"line": 22,
"column": 33
},
"identifierName": "position"
},
"name": "position"
}
}
},
{
"type": "ExpressionStatement",
"start": 987,
"end": 1013,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 23,
"column": 34
}
},
"expression": {
"type": "AssignmentExpression",
"start": 987,
"end": 1012,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 23,
"column": 33
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 987,
"end": 1001,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 23,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 987,
"end": 991,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 23,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 992,
"end": 1001,
"loc": {
"start": {
"line": 23,
"column": 13
},
"end": {
"line": 23,
"column": 22
},
"identifierName": "_rotation"
},
"name": "_rotation"
},
"computed": false
},
"right": {
"type": "Identifier",
"start": 1004,
"end": 1012,
"loc": {
"start": {
"line": 23,
"column": 25
},
"end": {
"line": 23,
"column": 33
},
"identifierName": "rotation"
},
"name": "rotation"
}
}
},
{
"type": "ExpressionStatement",
"start": 1022,
"end": 1042,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 28
}
},
"expression": {
"type": "AssignmentExpression",
"start": 1022,
"end": 1041,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 27
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 1022,
"end": 1033,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 19
}
},
"object": {
"type": "ThisExpression",
"start": 1022,
"end": 1026,
"loc": {
"start": {
"line": 24,
"column": 8
},
"end": {
"line": 24,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1027,
"end": 1033,
"loc": {
"start": {
"line": 24,
"column": 13
},
"end": {
"line": 24,
"column": 19
},
"identifierName": "_scale"
},
"name": "_scale"
},
"computed": false
},
"right": {
"type": "Identifier",
"start": 1036,
"end": 1041,
"loc": {
"start": {
"line": 24,
"column": 22
},
"end": {
"line": 24,
"column": 27
},
"identifierName": "scale"
},
"name": "scale"
}
}
},
{
"type": "ExpressionStatement",
"start": 1051,
"end": 1091,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 48
}
},
"expression": {
"type": "AssignmentExpression",
"start": 1051,
"end": 1090,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 47
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 1051,
"end": 1069,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 26
}
},
"object": {
"type": "ThisExpression",
"start": 1051,
"end": 1055,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1056,
"end": 1069,
"loc": {
"start": {
"line": 25,
"column": 13
},
"end": {
"line": 25,
"column": 26
},
"identifierName": "_originOffset"
},
"name": "_originOffset"
},
"computed": false
},
"right": {
"type": "NewExpression",
"start": 1072,
"end": 1090,
"loc": {
"start": {
"line": 25,
"column": 29
},
"end": {
"line": 25,
"column": 47
}
},
"callee": {
"type": "Identifier",
"start": 1076,
"end": 1081,
"loc": {
"start": {
"line": 25,
"column": 33
},
"end": {
"line": 25,
"column": 38
},
"identifierName": "Point"
},
"name": "Point"
},
"arguments": [
{
"type": "NumericLiteral",
"start": 1082,
"end": 1083,
"loc": {
"start": {
"line": 25,
"column": 39
},
"end": {
"line": 25,
"column": 40
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
},
{
"type": "NumericLiteral",
"start": 1085,
"end": 1086,
"loc": {
"start": {
"line": 25,
"column": 42
},
"end": {
"line": 25,
"column": 43
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
},
{
"type": "NumericLiteral",
"start": 1088,
"end": 1089,
"loc": {
"start": {
"line": 25,
"column": 45
},
"end": {
"line": 25,
"column": 46
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 1100,
"end": 1123,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 31
}
},
"expression": {
"type": "AssignmentExpression",
"start": 1100,
"end": 1122,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 30
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 1100,
"end": 1115,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 23
}
},
"object": {
"type": "ThisExpression",
"start": 1100,
"end": 1104,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1105,
"end": 1115,
"loc": {
"start": {
"line": 26,
"column": 13
},
"end": {
"line": 26,
"column": 23
},
"identifierName": "renderable"
},
"name": "renderable"
},
"computed": false
},
"right": {
"type": "NullLiteral",
"start": 1118,
"end": 1122,
"loc": {
"start": {
"line": 26,
"column": 26
},
"end": {
"line": 26,
"column": 30
}
}
}
}
}
],
"directives": [],
"trailingComments": null
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Sets the Transforms position.\n * \n * @param {number} x X position. Defaults to current X position.\n * @param {number} y Y position. Defaults to current Y position.\n * @param {number} z Z position. Defaults to current Z position.\n ",
"start": 1135,
"end": 1398,
"loc": {
"start": {
"line": 29,
"column": 4
},
"end": {
"line": 35,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 1403,
"end": 1631,
"loc": {
"start": {
"line": 36,
"column": 4
},
"end": {
"line": 41,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 1403,
"end": 1414,
"loc": {
"start": {
"line": 36,
"column": 4
},
"end": {
"line": 36,
"column": 15
},
"identifierName": "setPosition"
},
"name": "setPosition",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 1415,
"end": 1435,
"loc": {
"start": {
"line": 36,
"column": 16
},
"end": {
"line": 36,
"column": 36
}
},
"left": {
"type": "Identifier",
"start": 1415,
"end": 1416,
"loc": {
"start": {
"line": 36,
"column": 16
},
"end": {
"line": 36,
"column": 17
},
"identifierName": "x"
},
"name": "x"
},
"right": {
"type": "MemberExpression",
"start": 1419,
"end": 1435,
"loc": {
"start": {
"line": 36,
"column": 20
},
"end": {
"line": 36,
"column": 36
}
},
"object": {
"type": "MemberExpression",
"start": 1419,
"end": 1433,
"lo