Here's an example of a simple 2D action game implemented as a single HTML file, using JavaScript and enclosed in script tags. It is designed for smartphone operation and uses pictograms to represent game elements.
This code sets up a canvas element where the game is rendered. The blue cube represents the player, and the black cubes are the ones to be eaten. The player can move using arrow keys or on-screen touch controls. Colliding with black cubes increases the player's size and speed. Colliding with red cubes results in game over. The game continues until all the black cubes are eaten, or the player collides with a red cube.