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,519 lines • 664 kB
JSON
{
"type": "File",
"start": 0,
"end": 6478,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 172,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 6478,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 172,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 38
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 7,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 17
}
},
"local": {
"type": "Identifier",
"start": 7,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "Renderable"
},
"name": "Renderable"
}
}
],
"source": {
"type": "StringLiteral",
"start": 23,
"end": 37,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 37
}
},
"extra": {
"rawValue": "./Renderable",
"raw": "'./Renderable'"
},
"value": "./Renderable"
}
},
{
"type": "ImportDeclaration",
"start": 39,
"end": 85,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 46
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 46,
"end": 53,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 14
}
},
"local": {
"type": "Identifier",
"start": 46,
"end": 53,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 14
},
"identifierName": "Matrix3"
},
"name": "Matrix3"
}
}
],
"source": {
"type": "StringLiteral",
"start": 59,
"end": 84,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 45
}
},
"extra": {
"rawValue": "../render/WebGL/Matrix3",
"raw": "'../render/WebGL/Matrix3'"
},
"value": "../render/WebGL/Matrix3"
}
},
{
"type": "ImportDeclaration",
"start": 86,
"end": 141,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 55
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 93,
"end": 107,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 21
}
},
"local": {
"type": "Identifier",
"start": 93,
"end": 107,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 21
},
"identifierName": "ProgramManager"
},
"name": "ProgramManager"
}
}
],
"source": {
"type": "StringLiteral",
"start": 113,
"end": 140,
"loc": {
"start": {
"line": 3,
"column": 27
},
"end": {
"line": 3,
"column": 54
}
},
"extra": {
"rawValue": "../manager/ProgramManager",
"raw": "'../manager/ProgramManager'"
},
"value": "../manager/ProgramManager"
}
},
{
"type": "ImportDeclaration",
"start": 142,
"end": 197,
"loc": {
"start": {
"line": 4,
"column": 0
},
"end": {
"line": 4,
"column": 55
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 149,
"end": 163,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 21
}
},
"local": {
"type": "Identifier",
"start": 149,
"end": 163,
"loc": {
"start": {
"line": 4,
"column": 7
},
"end": {
"line": 4,
"column": 21
},
"identifierName": "TextureManager"
},
"name": "TextureManager"
}
}
],
"source": {
"type": "StringLiteral",
"start": 169,
"end": 196,
"loc": {
"start": {
"line": 4,
"column": 27
},
"end": {
"line": 4,
"column": 54
}
},
"extra": {
"rawValue": "../manager/TextureManager",
"raw": "'../manager/TextureManager'"
},
"value": "../manager/TextureManager"
}
},
{
"type": "ImportDeclaration",
"start": 198,
"end": 251,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 5,
"column": 53
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 205,
"end": 218,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 20
}
},
"local": {
"type": "Identifier",
"start": 205,
"end": 218,
"loc": {
"start": {
"line": 5,
"column": 7
},
"end": {
"line": 5,
"column": 20
},
"identifierName": "RenderManager"
},
"name": "RenderManager"
}
}
],
"source": {
"type": "StringLiteral",
"start": 224,
"end": 250,
"loc": {
"start": {
"line": 5,
"column": 26
},
"end": {
"line": 5,
"column": 52
}
},
"extra": {
"rawValue": "../manager/RenderManager",
"raw": "'../manager/RenderManager'"
},
"value": "../manager/RenderManager"
}
},
{
"type": "ImportDeclaration",
"start": 252,
"end": 310,
"loc": {
"start": {
"line": 6,
"column": 0
},
"end": {
"line": 6,
"column": 58
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 259,
"end": 279,
"loc": {
"start": {
"line": 6,
"column": 7
},
"end": {
"line": 6,
"column": 27
}
},
"local": {
"type": "Identifier",
"start": 259,
"end": 279,
"loc": {
"start": {
"line": 6,
"column": 7
},
"end": {
"line": 6,
"column": 27
},
"identifierName": "Renderable2DMultitex"
},
"name": "Renderable2DMultitex"
}
}
],
"source": {
"type": "StringLiteral",
"start": 285,
"end": 309,
"loc": {
"start": {
"line": 6,
"column": 33
},
"end": {
"line": 6,
"column": 57
}
},
"extra": {
"rawValue": "./Renderable2DMultitex",
"raw": "'./Renderable2DMultitex'"
},
"value": "./Renderable2DMultitex"
}
},
{
"type": "VariableDeclaration",
"start": 312,
"end": 335,
"loc": {
"start": {
"line": 8,
"column": 0
},
"end": {
"line": 8,
"column": 23
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 316,
"end": 334,
"loc": {
"start": {
"line": 8,
"column": 4
},
"end": {
"line": 8,
"column": 22
}
},
"id": {
"type": "Identifier",
"start": 316,
"end": 330,
"loc": {
"start": {
"line": 8,
"column": 4
},
"end": {
"line": 8,
"column": 18
},
"identifierName": "dataTexCounter"
},
"name": "dataTexCounter"
},
"init": {
"type": "NumericLiteral",
"start": 333,
"end": 334,
"loc": {
"start": {
"line": 8,
"column": 21
},
"end": {
"line": 8,
"column": 22
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
],
"kind": "var",
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Renderable2DGrid is a renderable component which uses two textures to draw\n * tilemaps using the GPU, and just one renderable. Renderable2DGrid will expect one\n * texture for sprites, and another containing the data for which tile goes where.\n * Additionaly, viewport support is added to make large maps require one time loads into self\n * managed data textures.\n ",
"start": 337,
"end": 710,
"loc": {
"start": {
"line": 10,
"column": 0
},
"end": {
"line": 16,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 711,
"end": 6478,
"loc": {
"start": {
"line": 17,
"column": 0
},
"end": {
"line": 172,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 726,
"end": 6478,
"loc": {
"start": {
"line": 17,
"column": 15
},
"end": {
"line": 172,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 732,
"end": 748,
"loc": {
"start": {
"line": 17,
"column": 21
},
"end": {
"line": 17,
"column": 37
},
"identifierName": "Renderable2DGrid"
},
"name": "Renderable2DGrid",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 757,
"end": 777,
"loc": {
"start": {
"line": 17,
"column": 46
},
"end": {
"line": 17,
"column": 66
},
"identifierName": "Renderable2DMultitex"
},
"name": "Renderable2DMultitex"
},
"body": {
"type": "ClassBody",
"start": 778,
"end": 6478,
"loc": {
"start": {
"line": 17,
"column": 67
},
"end": {
"line": 172,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 1260,
"end": 2327,
"loc": {
"start": {
"line": 28,
"column": 4
},
"end": {
"line": 62,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 1260,
"end": 1271,
"loc": {
"start": {
"line": 28,
"column": 4
},
"end": {
"line": 28,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor",
"leadingComments": null
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1272,
"end": 1291,
"loc": {
"start": {
"line": 28,
"column": 16
},
"end": {
"line": 28,
"column": 35
},
"identifierName": "mapTilesTextureName"
},
"name": "mapTilesTextureName"
},
{
"type": "Identifier",
"start": 1293,
"end": 1301,
"loc": {
"start": {
"line": 28,
"column": 37
},
"end": {
"line": 28,
"column": 45
},
"identifierName": "gridData"
},
"name": "gridData"
},
{
"type": "Identifier",
"start": 1303,
"end": 1308,
"loc": {
"start": {
"line": 28,
"column": 47
},
"end": {
"line": 28,
"column": 52
},
"identifierName": "width"
},
"name": "width"
},
{
"type": "Identifier",
"start": 1310,
"end": 1316,
"loc": {
"start": {
"line": 28,
"column": 54
},
"end": {
"line": 28,
"column": 60
},
"identifierName": "height"
},
"name": "height"
},
{
"type": "Identifier",
"start": 1318,
"end": 1331,
"loc": {
"start": {
"line": 28,
"column": 62
},
"end": {
"line": 28,
"column": 75
},
"identifierName": "tileViewWidth"
},
"name": "tileViewWidth"
},
{
"type": "Identifier",
"start": 1333,
"end": 1347,
"loc": {
"start": {
"line": 28,
"column": 77
},
"end": {
"line": 28,
"column": 91
},
"identifierName": "tileViewHeight"
},
"name": "tileViewHeight"
}
],
"body": {
"type": "BlockStatement",
"start": 1349,
"end": 2327,
"loc": {
"start": {
"line": 28,
"column": 93
},
"end": {
"line": 62,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 1359,
"end": 1402,
"loc": {
"start": {
"line": 29,
"column": 8
},
"end": {
"line": 29,
"column": 51
}
},
"expression": {
"type": "CallExpression",
"start": 1359,
"end": 1401,
"loc": {
"start": {
"line": 29,
"column": 8
},
"end": {
"line": 29,
"column": 50
}
},
"callee": {
"type": "Super",
"start": 1359,
"end": 1364,
"loc": {
"start": {
"line": 29,
"column": 8
},
"end": {
"line": 29,
"column": 13
}
}
},
"arguments": [
{
"type": "CallExpression",
"start": 1365,
"end": 1400,
"loc": {
"start": {
"line": 29,
"column": 14
},
"end": {
"line": 29,
"column": 49
}
},
"callee": {
"type": "MemberExpression",
"start": 1365,
"end": 1390,
"loc": {
"start": {
"line": 29,
"column": 14
},
"end": {
"line": 29,
"column": 39
}
},
"object": {
"type": "Identifier",
"start": 1365,
"end": 1379,
"loc": {
"start": {
"line": 29,
"column": 14
},
"end": {
"line": 29,
"column": 28
},
"identifierName": "ProgramManager"
},
"name": "ProgramManager"
},
"property": {
"type": "Identifier",
"start": 1380,
"end": 1390,
"loc": {
"start": {
"line": 29,
"column": 29
},
"end": {
"line": 29,
"column": 39
},
"identifierName": "getProgram"
},
"name": "getProgram"
},
"computed": false
},
"arguments": [
{
"type": "StringLiteral",
"start": 1391,
"end": 1399,
"loc": {
"start": {
"line": 29,
"column": 40
},
"end": {
"line": 29,
"column": 48
}
},
"extra": {
"rawValue": "2DGrid",
"raw": "'2DGrid'"
},
"value": "2DGrid"
}
]
}
]
}
},
{
"type": "ExpressionStatement",
"start": 1411,
"end": 1447,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 44
}
},
"expression": {
"type": "AssignmentExpression",
"start": 1411,
"end": 1446,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 43
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 1411,
"end": 1425,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 1411,
"end": 1415,
"loc": {
"start": {
"line": 30,
"column": 8
},
"end": {
"line": 30,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1416,
"end": 1425,
"loc": {
"start": {
"line": 30,
"column": 13
},
"end": {
"line": 30,
"column": 22
},
"identifierName": "className"
},
"name": "className"
},
"computed": false
},
"right": {
"type": "StringLiteral",
"start": 1428,
"end": 1446,
"loc": {
"start": {
"line": 30,
"column": 25
},
"end": {
"line": 30,
"column": 43
}
},
"extra": {
"rawValue": "Renderable2DGrid",
"raw": "'Renderable2DGrid'"
},
"value": "Renderable2DGrid"
}
}
},
{
"type": "ExpressionStatement",
"start": 1457,
"end": 1506,
"loc": {
"start": {
"line": 32,
"column": 8
},
"end": {
"line": 32,
"column": 57
}
},
"expression": {
"type": "AssignmentExpression",
"start": 1457,
"end": 1505,
"loc": {
"start": {
"line": 32,
"column": 8
},
"end": {
"line": 32,
"column": 56
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 1457,
"end": 1471,
"loc": {
"start": {
"line": 32,
"column": 8
},
"end": {
"line": 32,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 1457,
"end": 1461,
"loc": {
"start": {
"line": 32,
"column": 8
},
"end": {
"line": 32,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1462,
"end": 1471,
"loc": {
"start": {
"line": 32,
"column": 13
},
"end": {
"line": 32,
"column": 22
},
"identifierName": "dataArray"
},
"name": "dataArray"
},
"computed": false
},
"right": {
"type": "NewExpression",
"start": 1474,
"end": 1505,
"loc": {
"start": {
"line": 32,
"column": 25
},
"end": {
"line": 32,
"column": 56
}
},
"callee": {
"type": "Identifier",
"start": 1478,
"end": 1489,
"loc": {
"start": {
"line": 32,
"column": 29
},
"end": {
"line": 32,
"column": 40
},
"identifierName": "Uint16Array"
},
"name": "Uint16Array"
},
"arguments": [
{
"type": "BinaryExpression",
"start": 1490,
"end": 1504,
"loc": {
"start": {
"line": 32,
"column": 41
},
"end": {
"line": 32,
"column": 55
}
},
"left": {
"type": "Identifier",
"start": 1490,
"end": 1495,
"loc": {
"start": {
"line": 32,
"column": 41
},
"end": {
"line": 32,
"column": 46
},
"identifierName": "width"
},
"name": "width"
},
"operator": "*",
"right": {
"type": "Identifier",
"start": 1498,
"end": 1504,
"loc": {
"start": {
"line": 32,
"column": 49
},
"end": {
"line": 32,
"column": 55
},
"identifierName": "height"
},
"name": "height"
}
}
]
}
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "\n [0][0] = 0 = Map data tiles width.\n\n [0][1] = 1 = Map data tiles height.\n\n [0][2] = 2 = Map tiles in the texture width.\n\n [0][3] = 3 = Map tiles in the texture height.\n\n\n [1][0] = 4 = Map viewport width.\n\n [1][1] = 5 = Map viewport height.\n\n [1][2] = 6 = Map viewport x1.\n\n [1][3] = 7 = Map viewport y1.\n\n\n [2][0] = 8 = TileSize width normalized.\n\n [2][1] = 9 = TileSize height normalized. \n ",
"start": 1516,
"end": 1991,
"loc": {
"start": {
"line": 34,
"column": 8
},
"end": {
"line": 56,
"column": 10
}
}
}
]
},
{
"type": "ExpressionStatement",
"start": 2000,
"end": 2025,
"loc": {
"start": {
"line": 57,
"column": 8
},
"end": {
"line": 57,
"column": 33
}
},
"expression": {
"type": "AssignmentExpression",
"start": 2000,
"end": 2024,
"loc": {
"start": {
"line": 57,
"column": 8
},
"end": {
"line": 57,
"column": 32
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 2000,
"end": 2019,
"loc": {
"start": {
"line": 57,
"column": 8
},
"end": {
"line": 57,
"column": 27
}
},
"object": {
"type": "ThisExpression",
"start": 2000,
"end": 2004,
"loc": {
"start": {
"line": 57,
"column": 8
},
"end": {
"line": 57,
"column": 12
}
},
"leadingComments": null
},
"property": {
"type": "Identifier",
"start": 2005,
"end": 2019,
"loc": {
"start": {
"line": 57,
"column": 13
},
"end": {
"line": 57,
"column": 27
},
"identifierName": "shaderTileData"
},
"name": "shaderTileData"
},
"computed": false,
"leadingComments": null
},
"right": {
"type": "ArrayExpression",
"start": 2022,
"end": 2024,
"loc": {
"start": {
"line": 57,
"column": 30
},
"end": {
"line": 57,
"column": 32
}
},
"elements": []
},
"leadingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "\n [0][0] = 0 = Map data tiles width.\n\n [0][1] = 1 = Map data tiles height.\n\n [0][2] = 2 = Map tiles in the texture width.\n\n [0][3] = 3 = Map tiles in the texture height.\n\n\n [1][0] = 4 = Map viewport width.\n\n [1][1] = 5 = Map viewport height.\n\n [1][2] = 6 = Map viewport x1.\n\n [1][3] = 7 = Map viewport y1.\n\n\n [2][0] = 8 = TileSize width normalized.\n\n [2][1] = 9 = TileSize height normalized. \n ",
"start": 1516,
"end": 1991,
"loc": {
"start": {
"line": 34,
"column": 8
},
"end": {
"line": 56,
"column": 10
}
}
}
]
},
{
"type": "ExpressionStatement",
"start": 2034,
"end": 2104,
"loc": {
"start": {
"line": 58,
"column": 8
},
"end": {
"line": 58,
"column": 78
}
},
"expression": {
"type": "AssignmentExpression",
"start": 2034,
"end": 2103,
"loc": {
"start": {
"line": 58,
"column": 8
},
"end": {
"line": 58,
"column": 77
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 2034,
"end": 2054,
"loc": {
"start": {
"line": 58,
"column": 8
},
"end": {
"line": 58,
"column": 28
}
},
"object": {
"type": "ThisExpression",
"start": 2034,
"end": 2038,
"loc": {
"start": {
"line": 58,
"column": 8
},
"end": {
"line": 58,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 2039,
"end": 2054,
"loc": {
"start": {
"line": 58,
"column": 13
},
"end": {
"line": 58,
"column": 28
},
"identifierName": "mapTilesTexture"
},
"name": "mapTilesTexture"
},
"computed": false
},
"right": {
"type": "CallExpression",
"start": 2057,
"end": 2103,
"loc": {
"start": {
"line": 58,
"column": 31
},
"end": {
"line": 58,
"column": 77
}
},
"callee": {
"type": "MemberExpression",
"start": 2057,
"end": 2082,
"loc": {
"start": {
"line": 58,
"column": 31
},
"end": {
"line": 58,
"column": 56
}
},
"object": {
"type": "Identifier",
"start": 2057,
"end": 2071,
"loc": {
"start": {
"line": 58,
"column": 31
},
"end": {
"line": 58,
"column": 45
},
"identifierName": "TextureManager"
},
"name": "TextureManager"
},
"property": {
"type": "Identifier",
"start": 2072,
"end": 2082,
"loc": {
"start": {
"line": 58,
"column": 46
},
"end": {
"line": 58,
"column": 56
},
"identifierName": "getTexture"
},
"name": "getTexture"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"start": 2083,
"end": 2102,
"loc": {
"start": {
"line": 58,
"column": 57
},
"end": {
"line": 58,
"column": 76
},
"identifierName": "mapTilesTextureName"
},
"name": "mapTilesTextureName"
}
]
}
}
},
{
"type": "ExpressionStatement",
"start": 2113,
"end": 2151,
"loc": {
"start": {
"line": 59,
"column": 8
},
"end": {
"line": 59,
"column": 46
}
},
"expression": {
"type": "CallExpression",
"start": 2113,
"end": 2150,
"loc": {
"start": {
"line": 59,
"column": 8
},
"end": {
"line": 59,
"column": 45
}
},
"callee": {
"type": "MemberExpression",
"start": 2113,
"end": 2128,
"loc": {
"start": {
"line": 59,
"column": 8
},
"end": {
"line": 59,
"column": 23
}
},
"object": {
"type": "ThisExpression",
"start": 2113,
"end": 2117,
"loc": {
"start": {
"line": 59,
"column": 8
},
"end": {
"line": 59,
"column": 12
}
}
},
"property": {