-
Notifications
You must be signed in to change notification settings - Fork 0
Camera
Harsh Singh edited this page Jul 22, 2022
·
6 revisions
Camera is a simple implementation of a 2D Game Camera using the Canvas API.
Params
- ctx - CanvasRenderingContext2D
- x - initial point to look at (x)
- y - initial point to look at (y)
- dx - offset from screen center (x)
- dy - offset from screen center (y)
const camera = new Bottlecap.Camera(ctx);
// -- following code goes in update()
camera.update(dt);
camera.lookAt(0, 0);
// -- following code goes in render()
camera.attach();
// draw stuff here
camera.detach();