A lightweight JavaScript game engine
git clone git://soophie.de/game-engine
60
{61
"id": "js.surface",62
"name": "Surface",63
"syntax": "Surface(x, y, width, height)",63
"syntax": "Surface(x, y, shape)",64
"description": "Represents a rectangular surface with its own update and render method.",65
"import": "import { Surface } from 'https://git.typable.dev/std/js/game.js';",66
"code": [67
"class Player extends Surface {",68
"\tconstructor(x, y) {",69
"\t\tsuper(x, y, 50, 50);",69
"\t\tsuper(x, y, new Shape.Rect(50, 50));",70
"\t}",71
"\tupdate() {",72
"\t\tthis.rect.x += 1;",72
"\t\tthis.x += 1;",73
"\t}",74
"\trender(g) {",75
"\t\tconst {x, y, width, height} = this.rect;",75
"\t\tconst {x, y, shape: {width, height}} = this;",76
"\t\tg.fillRect(x, y, width, height);",77
"\t}",78
"}"78
"}",79
"",80
"// Collision (in combination with a Group):",81
"this.collided // if surface collides with another",82
"this.items // all colliding surfaces"83
]84
},85
{
92
"const group = new Group();",93
"group.add(...);",94
"",95
"group.collide(); // call in update method for collision",96
"group.update();",97
"group.render(g);"98
]99
},100
{96
"id": "js.rect",97
"name": "Rect",98
"syntax": "Rect(x, y, width, height)",101
"id": "js.shape.rect",102
"name": "Shape.Rect",103
"syntax": "Shape.Rect(width, height)",104
"description": "Represents a rectangular hitbox.",100
"import": "import { Rect } from 'https://git.typable.dev/std/js/game.js';"105
"import": "import { Shape } from 'https://git.typable.dev/std/js/game.js';"106
},107
{108
"id": "js.shape.circle",109
"name": "Shape.Circle",110
"syntax": "Shape.Circle(radius)",111
"description": "Represents a circular hitbox.",112
"import": "import { Shape } from 'https://git.typable.dev/std/js/game.js';"113
},114
{115
"id": "js.scalecanvas",