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,468 lines (1,467 loc) • 939 kB
JSON
{
"type": "File",
"start": 0,
"end": 6969,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 208,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 6969,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 208,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "ImportDeclaration",
"start": 0,
"end": 44,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 44
}
},
"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": "Updateable"
},
"name": "Updateable"
}
}
],
"source": {
"type": "StringLiteral",
"start": 23,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 43
}
},
"extra": {
"rawValue": "../base/Updateable",
"raw": "'../base/Updateable'"
},
"value": "../base/Updateable"
}
},
{
"type": "ImportDeclaration",
"start": 45,
"end": 92,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 47
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 52,
"end": 61,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 16
}
},
"local": {
"type": "Identifier",
"start": 52,
"end": 61,
"loc": {
"start": {
"line": 2,
"column": 7
},
"end": {
"line": 2,
"column": 16
},
"identifierName": "Component"
},
"name": "Component"
}
}
],
"source": {
"type": "StringLiteral",
"start": 67,
"end": 91,
"loc": {
"start": {
"line": 2,
"column": 22
},
"end": {
"line": 2,
"column": 46
}
},
"extra": {
"rawValue": "../component/Component",
"raw": "'../component/Component'"
},
"value": "../component/Component"
}
},
{
"type": "ImportDeclaration",
"start": 93,
"end": 140,
"loc": {
"start": {
"line": 3,
"column": 0
},
"end": {
"line": 3,
"column": 47
}
},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start": 100,
"end": 109,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 16
}
},
"local": {
"type": "Identifier",
"start": 100,
"end": 109,
"loc": {
"start": {
"line": 3,
"column": 7
},
"end": {
"line": 3,
"column": 16
},
"identifierName": "Transform"
},
"name": "Transform"
}
}
],
"source": {
"type": "StringLiteral",
"start": 115,
"end": 139,
"loc": {
"start": {
"line": 3,
"column": 22
},
"end": {
"line": 3,
"column": 46
}
},
"extra": {
"rawValue": "../component/Transform",
"raw": "'../component/Transform'"
},
"value": "../component/Transform"
},
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Baseclass GameObject which derives from Updateable.\n * \n * Do not derive this class directly! GameObjects are not managed until they are assigned to a manager.\n * Instead, derive SceneObject or PersistentObject to create objects that exist the scope of a scene, or the scope of the game.\n * \n * All objects that should exist in the game screen should derive this. \n ",
"start": 142,
"end": 517,
"loc": {
"start": {
"line": 5,
"column": 0
},
"end": {
"line": 12,
"column": 3
}
}
}
]
},
{
"type": "ExportDefaultDeclaration",
"start": 518,
"end": 6969,
"loc": {
"start": {
"line": 13,
"column": 0
},
"end": {
"line": 208,
"column": 1
}
},
"declaration": {
"type": "ClassDeclaration",
"start": 533,
"end": 6969,
"loc": {
"start": {
"line": 13,
"column": 15
},
"end": {
"line": 208,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 539,
"end": 549,
"loc": {
"start": {
"line": 13,
"column": 21
},
"end": {
"line": 13,
"column": 31
},
"identifierName": "GameObject"
},
"name": "GameObject",
"leadingComments": null
},
"superClass": {
"type": "Identifier",
"start": 558,
"end": 568,
"loc": {
"start": {
"line": 13,
"column": 40
},
"end": {
"line": 13,
"column": 50
},
"identifierName": "Updateable"
},
"name": "Updateable"
},
"body": {
"type": "ClassBody",
"start": 569,
"end": 6969,
"loc": {
"start": {
"line": 13,
"column": 51
},
"end": {
"line": 208,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 876,
"end": 1181,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 28,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 876,
"end": 887,
"loc": {
"start": {
"line": 21,
"column": 4
},
"end": {
"line": 21,
"column": 15
},
"identifierName": "constructor"
},
"name": "constructor",
"leadingComments": null
},
"kind": "constructor",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 888,
"end": 917,
"loc": {
"start": {
"line": 21,
"column": 16
},
"end": {
"line": 21,
"column": 45
}
},
"left": {
"type": "Identifier",
"start": 888,
"end": 896,
"loc": {
"start": {
"line": 21,
"column": 16
},
"end": {
"line": 21,
"column": 24
},
"identifierName": "position"
},
"name": "position"
},
"right": {
"type": "NewExpression",
"start": 899,
"end": 917,
"loc": {
"start": {
"line": 21,
"column": 27
},
"end": {
"line": 21,
"column": 45
}
},
"callee": {
"type": "Identifier",
"start": 903,
"end": 908,
"loc": {
"start": {
"line": 21,
"column": 31
},
"end": {
"line": 21,
"column": 36
},
"identifierName": "Point"
},
"name": "Point"
},
"arguments": [
{
"type": "NumericLiteral",
"start": 909,
"end": 910,
"loc": {
"start": {
"line": 21,
"column": 37
},
"end": {
"line": 21,
"column": 38
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
},
{
"type": "NumericLiteral",
"start": 912,
"end": 913,
"loc": {
"start": {
"line": 21,
"column": 40
},
"end": {
"line": 21,
"column": 41
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
},
{
"type": "NumericLiteral",
"start": 915,
"end": 916,
"loc": {
"start": {
"line": 21,
"column": 43
},
"end": {
"line": 21,
"column": 44
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
]
}
},
{
"type": "AssignmentPattern",
"start": 919,
"end": 946,
"loc": {
"start": {
"line": 21,
"column": 47
},
"end": {
"line": 21,
"column": 74
}
},
"left": {
"type": "Identifier",
"start": 919,
"end": 923,
"loc": {
"start": {
"line": 21,
"column": 47
},
"end": {
"line": 21,
"column": 51
},
"identifierName": "size"
},
"name": "size"
},
"right": {
"type": "NewExpression",
"start": 926,
"end": 946,
"loc": {
"start": {
"line": 21,
"column": 54
},
"end": {
"line": 21,
"column": 74
}
},
"callee": {
"type": "Identifier",
"start": 930,
"end": 935,
"loc": {
"start": {
"line": 21,
"column": 58
},
"end": {
"line": 21,
"column": 63
},
"identifierName": "Point"
},
"name": "Point"
},
"arguments": [
{
"type": "NumericLiteral",
"start": 936,
"end": 938,
"loc": {
"start": {
"line": 21,
"column": 64
},
"end": {
"line": 21,
"column": 66
}
},
"extra": {
"rawValue": 32,
"raw": "32"
},
"value": 32
},
{
"type": "NumericLiteral",
"start": 940,
"end": 942,
"loc": {
"start": {
"line": 21,
"column": 68
},
"end": {
"line": 21,
"column": 70
}
},
"extra": {
"rawValue": 32,
"raw": "32"
},
"value": 32
},
{
"type": "NumericLiteral",
"start": 944,
"end": 945,
"loc": {
"start": {
"line": 21,
"column": 72
},
"end": {
"line": 21,
"column": 73
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
}
]
}
},
{
"type": "AssignmentPattern",
"start": 948,
"end": 960,
"loc": {
"start": {
"line": 21,
"column": 76
},
"end": {
"line": 21,
"column": 88
}
},
"left": {
"type": "Identifier",
"start": 948,
"end": 956,
"loc": {
"start": {
"line": 21,
"column": 76
},
"end": {
"line": 21,
"column": 84
},
"identifierName": "rotation"
},
"name": "rotation"
},
"right": {
"type": "NumericLiteral",
"start": 959,
"end": 960,
"loc": {
"start": {
"line": 21,
"column": 87
},
"end": {
"line": 21,
"column": 88
}
},
"extra": {
"rawValue": 0,
"raw": "0"
},
"value": 0
}
}
],
"body": {
"type": "BlockStatement",
"start": 962,
"end": 1181,
"loc": {
"start": {
"line": 21,
"column": 90
},
"end": {
"line": 28,
"column": 5
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 972,
"end": 980,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 16
}
},
"expression": {
"type": "CallExpression",
"start": 972,
"end": 979,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 15
}
},
"callee": {
"type": "Super",
"start": 972,
"end": 977,
"loc": {
"start": {
"line": 22,
"column": 8
},
"end": {
"line": 22,
"column": 13
}
}
},
"arguments": []
}
},
{
"type": "ExpressionStatement",
"start": 989,
"end": 1019,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 23,
"column": 38
}
},
"expression": {
"type": "AssignmentExpression",
"start": 989,
"end": 1018,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 23,
"column": 37
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 989,
"end": 1003,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 23,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 989,
"end": 993,
"loc": {
"start": {
"line": 23,
"column": 8
},
"end": {
"line": 23,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 994,
"end": 1003,
"loc": {
"start": {
"line": 23,
"column": 13
},
"end": {
"line": 23,
"column": 22
},
"identifierName": "className"
},
"name": "className"
},
"computed": false
},
"right": {
"type": "StringLiteral",
"start": 1006,
"end": 1018,
"loc": {
"start": {
"line": 23,
"column": 25
},
"end": {
"line": 23,
"column": 37
}
},
"extra": {
"rawValue": "GameObject",
"raw": "'GameObject'"
},
"value": "GameObject"
}
}
},
{
"type": "ExpressionStatement",
"start": 1029,
"end": 1050,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 29
}
},
"expression": {
"type": "AssignmentExpression",
"start": 1029,
"end": 1049,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 28
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 1029,
"end": 1044,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 23
}
},
"object": {
"type": "ThisExpression",
"start": 1029,
"end": 1033,
"loc": {
"start": {
"line": 25,
"column": 8
},
"end": {
"line": 25,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1034,
"end": 1044,
"loc": {
"start": {
"line": 25,
"column": 13
},
"end": {
"line": 25,
"column": 23
},
"identifierName": "components"
},
"name": "components"
},
"computed": false
},
"right": {
"type": "ObjectExpression",
"start": 1047,
"end": 1049,
"loc": {
"start": {
"line": 25,
"column": 26
},
"end": {
"line": 25,
"column": 28
}
},
"properties": []
}
}
},
{
"type": "ExpressionStatement",
"start": 1059,
"end": 1118,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 67
}
},
"expression": {
"type": "CallExpression",
"start": 1059,
"end": 1117,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 66
}
},
"callee": {
"type": "MemberExpression",
"start": 1059,
"end": 1076,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 25
}
},
"object": {
"type": "ThisExpression",
"start": 1059,
"end": 1063,
"loc": {
"start": {
"line": 26,
"column": 8
},
"end": {
"line": 26,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1064,
"end": 1076,
"loc": {
"start": {
"line": 26,
"column": 13
},
"end": {
"line": 26,
"column": 25
},
"identifierName": "addComponent"
},
"name": "addComponent"
},
"computed": false
},
"arguments": [
{
"type": "NewExpression",
"start": 1077,
"end": 1116,
"loc": {
"start": {
"line": 26,
"column": 26
},
"end": {
"line": 26,
"column": 65
}
},
"callee": {
"type": "Identifier",
"start": 1081,
"end": 1090,
"loc": {
"start": {
"line": 26,
"column": 30
},
"end": {
"line": 26,
"column": 39
},
"identifierName": "Transform"
},
"name": "Transform"
},
"arguments": [
{
"type": "Identifier",
"start": 1091,
"end": 1099,
"loc": {
"start": {
"line": 26,
"column": 40
},
"end": {
"line": 26,
"column": 48
},
"identifierName": "position"
},
"name": "position"
},
{
"type": "Identifier",
"start": 1101,
"end": 1105,
"loc": {
"start": {
"line": 26,
"column": 50
},
"end": {
"line": 26,
"column": 54
},
"identifierName": "size"
},
"name": "size"
},
{
"type": "Identifier",
"start": 1107,
"end": 1115,
"loc": {
"start": {
"line": 26,
"column": 56
},
"end": {
"line": 26,
"column": 64
},
"identifierName": "rotation"
},
"name": "rotation"
}
]
}
]
}
},
{
"type": "ExpressionStatement",
"start": 1127,
"end": 1175,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 56
}
},
"expression": {
"type": "AssignmentExpression",
"start": 1127,
"end": 1174,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 55
}
},
"operator": "=",
"left": {
"type": "MemberExpression",
"start": 1127,
"end": 1141,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 22
}
},
"object": {
"type": "ThisExpression",
"start": 1127,
"end": 1131,
"loc": {
"start": {
"line": 27,
"column": 8
},
"end": {
"line": 27,
"column": 12
}
}
},
"property": {
"type": "Identifier",
"start": 1132,
"end": 1141,
"loc": {
"start": {
"line": 27,
"column": 13
},
"end": {
"line": 27,
"column": 22
},
"identifierName": "transform"
},
"name": "transform"
},
"computed": false
},
"right": {
"type": "CallExpression",
"start": 1144,
"end": 1174,
"loc": {
"start": {
"line": 27,
"column": 25
},
"end": {
"line": 27,
"column": 55
}
},
"callee": {
"type": "MemberExpression",
"start": 1144,
"end": 1161,
"loc": {
"start": {
"line": 27,
"column": 25
},
"end": {
"line": 27,
"column": 42
}
},
"object": {
"type": "ThisExpression",
"start": 1144,
"end": 1148,
"loc": {
"start": {
"line": 27,
"column": 25
},
"end": {
"line": 27,
"column": 29
}
}
},
"property": {
"type": "Identifier",
"start": 1149,
"end": 1161,
"loc": {
"start": {
"line": 27,
"column": 30
},
"end": {
"line": 27,
"column": 42
},
"identifierName": "getComponent"
},
"name": "getComponent"
},
"computed": false
},
"arguments": [
{
"type": "StringLiteral",
"start": 1162,
"end": 1173,
"loc": {
"start": {
"line": 27,
"column": 43
},
"end": {
"line": 27,
"column": 54
}
},
"extra": {
"rawValue": "Transform",
"raw": "\"Transform\""
},
"value": "Transform"
}
]
}
}
}
],
"directives": [],
"trailingComments": null
},
"leadingComments": [
{
"type": "CommentBlock",
"value": "*\n * Default position, size and rotation of the Object.\n * \n * @param {Point} position A point of creation in the world.\n * @param {Point} size A point representing scale of the object.\n * @param {number} rotation A number representing angular rotation (in degrees).\n ",
"start": 575,
"end": 871,
"loc": {
"start": {
"line": 14,
"column": 4
},
"end": {
"line": 20,
"column": 7
}
}
}
],
"trailingComments": [
{
"type": "CommentBlock",
"value": "*\n * Adds a component to this game object, and keeps reference to it.\n * GameObjects will handle their components as they are added to the object.\n * \n * @param {Component} component The component assigned to this object.\n ",
"start": 1187,
"end": 1434,
"loc": {
"start": {
"line": 30,
"column": 4
},
"end": {
"line": 35,
"column": 7
}
}
}
]
},
{
"type": "ClassMethod",
"start": 1439,
"end": 1985,
"loc": {
"start": {
"line": 36,
"column": 4
},
"end": {
"line": 48,
"column": 5
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 1439,
"end": 1451,
"loc": {
"start": {
"line": 36,
"column": 4
},
"end": {
"line": 36,
"column": 16
},
"identifierName": "addComponent"
},
"name": "addComponent",
"leadingComments": null
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1452,
"end": 1461,
"loc": {
"start": {
"line": 36,
"column": 17
},
"end": {
"line": 36,
"column": 26
},
"identifierName": "component"
},
"name": "component"
}
],
"body": {
"type": "BlockStatement",
"start": 1463,
"end": 1985,
"loc": {
"start": {
"line": 36,
"column": 28
},
"end": {
"line": 48,
"column": 5
}
},
"body": [
{
"type": "IfStatement",
"start": 1473,
"end": 1589,
"loc": {
"start": {
"line": 37,
"column": 8
},
"end": {
"line": 39,
"column": 9
}
},
"test": {
"type": "BinaryExpression",
"start": 1477,
"end": 1521,
"loc": {
"start": {
"line": 37,
"column": 12
},
"end": {
"line": 37,
"column": 56
}
},
"left": {
"type": "MemberExpression",
"start": 1477,
"end": 1513,
"loc": {
"start": {
"line": 37,
"column": 12
},
"end": {
"line": 37,
"column": 48
}
},
"object": {
"type": "MemberExpression",
"start": 1477,
"end": 1492,
"loc": {
"start": {
"line": 37,
"column": 12
},
"end": {
"line": 37,
"column": 27
}
},
"object": {
"type": "ThisExpression",
"start": 1477,
"end": 1481,
"loc": {
"start": {
"line": 37,
"column": 12
},
"end": {
"line": 37,
"column": 16
}
}
},
"property": {
"type": "Identifier",
"start": 1482,
"end": 1492,
"loc": {
"start": {
"line": 37,
"column": 17
},
"end": {
"line": 37,
"column": 27
},
"identifierName": "components"
},
"name": "components"
},
"computed": false
},
"property": {