Sure! Here's a basic example of a 2D game featuring Sonic the Hedgehog, implemented in a single HTML file using JavaScript. You can play the game on a smartphone using touch controls.
This code sets up a canvas element where the game's graphics are drawn. Sonic is represented by a blue rectangle, and you can control his movement by touching the left or right side of the canvas on a smartphone. The game continuously updates Sonic's position based on the touch controls and draws the updated scene on the canvas.