Happier AI stories: My son drew a videogame
Here is a nice application of AI coding that makes me feel more positive about it for a change. My son dreams about building video games himself. In the past we’ve been playing around in GameMaker, Roblox Studio and Klokhuis Game Studio. I now had the idea to just let him draw sketches of the game he wants built and let AI turn it into one.
The result can be played at https://boxolino.hacktisch.com/ or in the iframe below; Github repo: github.com/hacktisch/boxolino
So his game idea is about getting your character to become stronger by punching bags, then smash walls to earn coins, to buy boxing gloves and more in the shop, and then challenge bosses that become incrementally harder to beat each time.
There’s different areas you can progress to and your character evolves, but the idea is the same. So it’s a classic level up RPG kind of situation with XP, HP etc. He called it “Boxolino“.
I photographed his drawings and added text annotations for Claude (Fable) to understand what’s supposed to happen. All I then prompted it to do was to generate a canvas + plain ES modules browser based game; desktop (keyboard) and mobile compatible (touch button overlay); summarized the overall point of the game and fed it the input drawings. The result was exactly as I had hoped.
Also I decided to explicitly tell the AI to use the input images literally and not visually enhance them / interpret them. The drawings have to exactly match the game and must be used as sprites to be cut up. This was in the hope of finally getting my kids motivated to put effort in their drawing. I’m not sure if this was accomplished though… haha.
The useful lesson for him was to learn how sprites work in video games, as I told him to draw all moving limbs separately but he didn’t understand that. So Claude cut those up which resulted in a slightly glitchy animation armature… but my son now understands the point I was trying to make.
The sound effects are synthesised with the Web Audio API, generating filtered sine waves from 150 to 60 Hz.
My both sons absolutely loved the result and said it’s their favorite game ever, and played it for a long time. And were making notes what to improve: The first boss went down in six punches once you owned gloves; his health was doubled. Nothing was for sale after the first hour, so the shop got a potion that unlocks at level 15. And the wall was taking far too long. It grew 35% stronger every time it broke, which felt right at wall 3 and is 40,000 hit points at wall 25, against a character hitting for 80. It grows in a straight line now.
Somehow through this entire process I felt a lot more excitement about AI coding than I do normally :)