Sure! Here's an example of a simple 2D action game implemented as a single HTML file with JavaScript:
This code sets up a canvas and implements the game logic for a 2D action game where the player (represented by a blue cube) needs to eat all the black cubes to win. The player can move left, right, up, and down using the arrow keys. Red cubes are obstacles, and the player can only eat them if they are larger in size.
The game ends when either all the black cubes are eaten, in which case the player wins, or if the player collides with a red cube while the red cube is larger, in which case the player loses.
I hope you enjoy playing the game!