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,493 lines • 182 kB
JSON
{
"type": "File",
"start": 0,
"end": 1625,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 54,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1625,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 54,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 51
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 19
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 19
},
"identifierName": "SceneManager"
},
"name": "SceneManager"
}
}
],
"source": {
"type": "StringLiteral",
"start": 25,
"end": 50,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 50
}
},
"extra": {
"rawValue": "../manager/SceneManager",
"raw": "'../manager/SceneManager'"
},
"value": "../manager/SceneManager"
}
},
{
"type": "ImportDeclaration",
"start": 52,
"end": 99,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 47
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 59,
"end": 69,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 17
}
},
"local": {
"type": "Identifier",
"start": 59,
"end": 69,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 17
},
"identifierName": "DOMManager"
},
"name": "DOMManager"
}
}
],
"source": {
"type": "StringLiteral",
"start": 75,
"end": 98,
"loc": {
"start": {
"line": 2,
"column": 23
},
"end": {
"line": 2,
"column": 46
}
},
"extra": {
"rawValue": "../manager/DOMManager",
"raw": "'../manager/DOMManager'"
},
"value": "../manager/DOMManager"
}
},
{
"type": "ImportDeclaration",
"start": 100,
"end": 144,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 44
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 107,
"end": 117,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 17
}
},
"local": {
"type": "Identifier",
"start": 107,
"end": 117,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 17
},
"identifierName": "Updateable"
},
"name": "Updateable"
}
}
],
"source": {
"type": "StringLiteral",
"start": 123,
"end": 143,
"loc": {
"start": {
"line": 3,
"column": 23
},
"end": {
"line": 3,
"column": 43
}
},
"extra": {
"rawValue": "../base/Updateable",
"raw": "'../base/Updateable'"
},
"value": "../base/Updateable"
}
},
{
"type": "ImportDeclaration",
"start": 145,
"end": 185,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 40
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 152,
"end": 158,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 13
}
},
"local": {
"type": "Identifier",
"start": 152,
"end": 158,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 13
},
"identifierName": "Bounds"
},
"name": "Bounds"
}
}
],
"source": {
"type": "StringLiteral",
"start": 164,
"end": 184,
"loc": {
"start": {
"line": 4,
"column": 19
},
"end": {
"line": 4,
"column": 39
}
},
"extra": {
"rawValue": "../internal/Bounds",
"raw": "'../internal/Bounds'"
},
"value": "../internal/Bounds"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * A viewport is a display port on the game canvas. Each scene can have multiple\n * viewports and renderable objects are assigned to the ones they want to be drawn on.\n * \n * Viewports contain lighting and cameras.\n * \n * GameObjects and their components exist across all viewports, it is up to the programmer\n * to specify the viewports to render to.\n * \n * Examples on when to use viewports: \n * - UI\n * - Minimaps\n * - Different views\n * \n * TODO: An object of keys represented by 'z' indexes to store all \n * renderable objects in render order.\n ",
"start": 187,
"end": 743,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 22,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 744,
"end": 1625,
"loc": {
"start": {
"line": 23,
"column": 0
},
"end": {
"line": 54,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 759,
"end": 1625,
"loc": {
"start": {
"line": 23,
"column": 15
},
"end": {
"line": 54,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 765,
"end": 773,
"loc": {
"start": {
"line": 23,
"column": 21
},
"end": {
"line": 23,
"column": 29
},
"identifierName": "Viewport"
},
"name": "Viewport",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 782,
"end": 792,
"loc": {
"start": {
"line": 23,
"column": 38
},
"end": {
"line": 23,
"column": 48
},
"identifierName": "Updateable"
},
"name": "Updateable"
},
"body": {
"type": "ClassBody",
"start": 793,
"end": 1625,
"loc": {
"start": {
"line": 23,
"column": 49
},
"end": {
"line": 54,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 799,
"end": 981,
"loc": {
"start": {
"line": 24,
"column": 4
},
"end": {
"line": 31,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 799,
"end": 810,
"loc": {
"start": {
"line": 24,
"column": 4
},
"end": {
"line": 24,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor"
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 811,
"end": 812,
"loc": {
"start": {
"line": 24,
"column": 16
},
"end": {
"line": 24,
"column": 17
},
"identifierName": "x"
},
"name": "x"
},
{
"type": "Identifier",
"start": 814,
"end": 815,
"loc": {
"start": {
"line": 24,
"column": 19
},
"end": {
"line": 24,
"column": 20
},
"identifierName": "y"
},
"name": "y"
},
{
"type": "Identifier",
"start": 817,
"end": 818,
"loc": {
"start": {
"line": 24,
"column": 22
},
"end": {
"line": 24,
"column": 23
},
"identifierName": "w"
},
"name": "w"
},
{
"type": "Identifier",
"start": 820,
"end": 821,
"loc": {
"start": {
"line": 24,
"column": 25
},
"end": {
"line": 24,
"column": 26
},
"identifierName": "h"
},
"name": "h"
}
],
"body": {
"type": "BlockStatement",
"start": 823,
"end": 981,
"loc": {
"start": {
"line": 24,
"column": 28
},
"end": {
"line": 31,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 833,
"end": 841,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 16
}
},
"expression": {
"type": "CallExpression",
"start": 833,
"end": 840,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 15
}
},
"callee": {
"type": "Super",
"start": 833,
"end": 838,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 13
}
}
},
"arguments": []
}
},
{
"type": "ExpressionStatement",
"start": 850,
"end": 870,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 28
}
},
"expression": {
"type": "AssignmentExpression",
"start": 850,
"end": 869,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 27
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 850,
"end": 862,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 20
}
},
"object": {
"type": "ThisExpression",
"start": 850,
"end": 854,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 855,
"end": 862,
"loc": {
"start": {
"line": 26,
"column": 13
},
"end": {
"line": 26,
"column": 20
},
"identifierName": "_bounds"
},
"name": "_bounds"
},
"computed": false
},
"right": {
"type": "NullLiteral",
"start": 865,
"end": 869,
"loc": {
"start": {
"line": 26,
"column": 23
},
"end": {
"line": 26,
"column": 27
}
}
}
}
},
{
"type": "ExpressionStatement",
"start": 879,
"end": 907,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 36
}
},
"expression": {
"type": "AssignmentExpression",
"start": 879,
"end": 906,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 35
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 879,
"end": 899,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 28
}
},
"object": {
"type": "ThisExpression",
"start": 879,
"end": 883,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 884,
"end": 899,
"loc": {
"start": {
"line": 27,
"column": 13
},
"end": {
"line": 27,
"column": 28
},
"identifierName": "_rendererBounds"
},
"name": "_rendererBounds"
},
"computed": false
},
"right": {
"type": "NullLiteral",
"start": 902,
"end": 906,
"loc": {
"start": {
"line": 27,
"column": 31
},
"end": {
"line": 27,
"column": 35
}
}
}
}
},
{
"type": "ExpressionStatement",
"start": 916,
"end": 943,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 35
}
},
"expression": {
"type": "CallExpression",
"start": 916,
"end": 942,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 34
}
},
"callee": {
"type": "MemberExpression",
"start": 916,
"end": 930,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 916,
"end": 920,
"loc": {
"start": {
"line": 28,
"column": 8
},
"end": {
"line": 28,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 921,
"end": 930,
"loc": {
"start": {
"line": 28,
"column": 13
},
"end": {
"line": 28,
"column": 22
},
"identifierName": "setBounds"
},
"name": "setBounds"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 931,
"end": 932,
"loc": {
"start": {
"line": 28,
"column": 23
},
"end": {
"line": 28,
"column": 24
},
"identifierName": "x"
},
"name": "x"
},
{
"type": "Identifier",
"start": 934,
"end": 935,
"loc": {
"start": {
"line": 28,
"column": 26
},
"end": {
"line": 28,
"column": 27
},
"identifierName": "y"
},
"name": "y"
},
{
"type": "Identifier",
"start": 937,
"end": 938,
"loc": {
"start": {
"line": 28,
"column": 29
},
"end": {
"line": 28,
"column": 30
},
"identifierName": "w"
},
"name": "w"
},
{
"type": "Identifier",
"start": 940,
"end": 941,
"loc": {
"start": {
"line": 28,
"column": 32
},
"end": {
"line": 28,
"column": 33
},
"identifierName": "h"
},
"name": "h"
}
]
}
},
{
"type": "ExpressionStatement",
"start": 953,
"end": 975,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 30
}
},
"expression": {
"type": "AssignmentExpression",
"start": 953,
"end": 974,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 29
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 953,
"end": 969,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 24
}
},
"object": {
"type": "ThisExpression",
"start": 953,
"end": 957,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 958,
"end": 969,
"loc": {
"start": {
"line": 30,
"column": 13
},
"end": {
"line": 30,
"column": 24
},
"identifierName": "renderables"
},
"name": "renderables"
},
"computed": false
},
"right": {
"type": "ObjectExpression",
"start": 972,
"end": 974,
"loc": {
"start": {
"line": 30,
"column": 27
},
"end": {
"line": 30,
"column": 29
}
},
"properties": []
}
}
}
],
"directives": []
}
},
{
"type": "ClassMethod",
"start": 987,
"end": 1156,
"loc": {
"start": {
"line": 33,
"column": 4
},
"end": {
"line": 36,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 987,
"end": 996,
"loc": {
"start": {
"line": 33,
"column": 4
},
"end": {
"line": 33,
"column": 13
},
"identifierName": "setBounds"
},
"name": "setBounds"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 997,
"end": 998,
"loc": {
"start": {
"line": 33,
"column": 14
},
"end": {
"line": 33,
"column": 15
},
"identifierName": "x"
},
"name": "x"
},
{
"type": "Identifier",
"start": 1000,
"end": 1001,
"loc": {
"start": {
"line": 33,
"column": 17
},
"end": {
"line": 33,
"column": 18
},
"identifierName": "y"
},
"name": "y"
},
{
"type": "Identifier",
"start": 1003,
"end": 1004,
"loc": {
"start": {
"line": 33,
"column": 20
},
"end": {
"line": 33,
"column": 21
},
"identifierName": "w"
},
"name": "w"
},
{
"type": "Identifier",
"start": 1006,
"end": 1007,
"loc": {
"start": {
"line": 33,
"column": 23
},
"end": {
"line": 33,
"column": 24
},
"identifierName": "h"
},
"name": "h"
}
],
"body": {
"type": "BlockStatement",
"start": 1009,
"end": 1156,
"loc": {
"start": {
"line": 33,
"column": 26
},
"end": {
"line": 36,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 1019,
"end": 1065,
"loc": {
"start": {
"line": 34,
"column": 8
},
"end": {
"line": 34,
"column": 54
}
},
"expression": {
"type": "AssignmentExpression",
"start": 1019,
"end": 1064,
"loc": {
"start": {
"line": 34,
"column": 8
},
"end": {
"line": 34,
"column": 53
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 1019,
"end": 1031,
"loc": {
"start": {
"line": 34,
"column": 8
},
"end": {
"line": 34,
"column": 20
}
},
"object": {
"type": "ThisExpression",
"start": 1019,
"end": 1023,
"loc": {
"start": {
"line": 34,
"column": 8
},
"end": {
"line": 34,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1024,
"end": 1031,
"loc": {
"start": {
"line": 34,
"column": 13
},
"end": {
"line": 34,
"column": 20
},
"identifierName": "_bounds"
},
"name": "_bounds"
},
"computed": false
},
"right": {
"type": "NewExpression",
"start": 1034,
"end": 1064,
"loc": {
"start": {
"line": 34,
"column": 23
},
"end": {
"line": 34,
"column": 53
}
},
"callee": {
"type": "Identifier",
"start": 1038,
"end": 1044,
"loc": {
"start": {
"line": 34,
"column": 27
},
"end": {
"line": 34,
"column": 33
},
"identifierName": "Bounds"
},
"name": "Bounds"
},
"arguments": [
{
"type": "Identifier",
"start": 1045,
"end": 1046,
"loc": {
"start": {
"line": 34,
"column": 34
},
"end": {
"line": 34,
"column": 35
},
"identifierName": "x"
},
"name": "x"
},
{
"type": "Identifier",
"start": 1048,
"end": 1049,
"loc": {
"start": {
"line": 34,
"column": 37
},
"end": {
"line": 34,
"column": 38
},
"identifierName": "y"
},
"name": "y"
},
{
"type": "BinaryExpression",
"start": 1051,
"end": 1056,
"loc": {
"start": {
"line": 34,
"column": 40
},
"end": {
"line": 34,
"column": 45
}
},
"left": {
"type": "Identifier",
"start": 1051,
"end": 1052,
"loc": {
"start": {
"line": 34,
"column": 40
},
"end": {
"line": 34,
"column": 41
},
"identifierName": "x"
},
"name": "x"
},
"operator": "+",
"right": {
"type": "Identifier",
"start": 1055,
"end": 1056,
"loc": {
"start": {
"line": 34,
"column": 44
},
"end": {
"line": 34,
"column": 45
},
"identifierName": "w"
},
"name": "w"
}
},
{
"type": "BinaryExpression",
"start": 1058,
"end": 1063,
"loc": {
"start": {
"line": 34,
"column": 47
},
"end": {
"line": 34,
"column": 52
}
},
"left": {
"type": "Identifier",
"start": 1058,
"end": 1059,
"loc": {
"start": {
"line": 34,
"column": 47
},
"end": {
"line": 34,
"column": 48
},
"identifierName": "y"
},
"name": "y"
},
"operator": "+",
"right": {
"type": "Identifier",
"start": 1062,
"end": 1063,
"loc": {
"start": {
"line": 34,
"column": 51
},
"end": {
"line": 34,
"column": 52
},
"identifierName": "h"
},
"name": "h"
}
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 1074,
"end": 1150,
"loc": {
"start": {
"line": 35,
"column": 8
},
"end": {
"line": 35,
"column": 84
}
},
"expression": {
"type": "AssignmentExpression",
"start": 1074,
"end": 1149,
"loc": {
"start": {
"line": 35,
"column": 8
},
"end": {
"line": 35,
"column": 83
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 1074,
"end": 1094,
"loc": {
"start": {
"line": 35,
"column": 8
},
"end": {
"line": 35,
"column": 28
}
},
"object": {
"type": "ThisExpression",
"start": 1074,
"end": 1078,
"loc": {
"start": {
"line": 35,
"column": 8
},
"end": {
"line": 35,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1079,
"end": 1094,
"loc": {
"start": {
"line": 35,
"column": 13
},
"end": {
"line": 35,
"column": 28
},
"identifierName": "_rendererBounds"
},
"name": "_rendererBounds"
},
"computed": false
},
"right": {
"type": "NewExpression",
"start": 1097,
"end": 1149,
"loc": {
"start": {
"line": 35,
"column": 31
},
"end": {
"line": 35,
"column": 83
}
},
"callee": {
"type": "Identifier",
"start": 1101,
"end": 1107,
"loc": {
"start": {
"line": 35,
"column": 35
},
"end": {
"line": 35,
"column": 41
},
"identifierName": "Bounds"
},
"name": "Bounds"
},
"arguments": [
{
"type": "Identifier",
"start": 1108,
"end": 1109,
"loc": {
"start": {
"line": 35,
"column"