Game Palette: Mouse and touch demo

This browser does not support HTML5 canvas; it is required to use the Game Palette library

Click or tap anywhere to walk there. Q/E turn the camera; the walker still goes where you point.

Game Palette doesn't handle the mouse itself yet, so this demo listens for the canvas's pointerdown event, which comes from a mouse, a finger, or a pen alike. The position the browser gives is in the page's pixels, so it's first scaled to the canvas's own pixels (the canvas here is shown smaller than 1000 pixels wide when the window is narrow), and then the engine's canvasToWorld turns it into a point in the game world, allowing for wherever the camera is and however it's turned. The event only notes the point; the logic function does the walking.

See Mouse and touch and From the world to the canvas and back in the manual.

All demos