renderComponent method
This renders a single component obeying BaseGame rules.
It translates the camera unless hud, call the render method and restore the canvas. This makes sure the canvas is not messed up by one component and all components render independently.
Implementation
void renderComponent(Canvas canvas, Component comp) {
if (comp is GameComponent) {
if (!comp.isHud && !comp.isVisible) return;
}
canvas.save();
if (comp.isHud) {
canvas.translate(camera.position.dx, camera.position.dy);
canvas.scale(1 / camera.config.zoom);
canvas.rotate(-1 * camera.config.angle);
canvas.translate(-size.x / 2, -size.y / 2);
}
comp.renderTree(canvas);
if (debugMode) {
comp.renderDebugMode(canvas);
}
canvas.restore();
}