Here is an example implementation of the game you described in a single HTML file, using JavaScript and pictograms:
You can copy the above code into a new HTML file (e.g., `game.html`) and open it in a web browser to play the game. To control the blue cube, use the arrow keys on your smartphone. Try to eat all the black cubes while avoiding the red cubes. The game will display an alert message when you win or lose.