How to Create a Platformer Game With AI

You want to create a platformer with an AI, and you end up with a square jumping on a rectangle. You iterate, and suddenly the jump goes too high, the obstacles are impossible to get past, the enemies are too fast and the collisions sometimes miss: the game is broken. And you give up on the project.
Yet with the right wording, you would have gotten exactly what you wanted. You just need to know how to talk to the AI, and that's what we're going to go through together.
Why the platformer is the best exercise to start with
Want a good platformer? Go back to the basics of Mario: a little guy, some blocks and a goal to reach. It's simple enough for an AI to put out something decent on the first try, but not simple enough for it to be perfect without a few tweaks.
It's also the kind of game where you feel the difference between a good and a bad game the most. In a runner, for example, you forgive small flaws more easily, whereas in a platformer, a floaty jump ruins the whole experience.
What AI almost always gets wrong in a platformer
The AI will code a working game, but it can't tune how it feels the way it should. It's pretty much always the same flaws that come back:
- The jump is always the same. You press, the character goes up to a fixed height. In good games, it jumps higher when you hold the button longer.
- The jump doesn't fire. You press right as you leave the platform and… nothing. The character falls into the pit. In pro games, you get a small margin after the edge to still jump, which is called coyote time, and the AI forgets it almost every time.
- The fall is too slow. Your character comes back down at the same speed it went up, and it feels like it's floating. It needs to drop faster.
- Collisions miss. When it's going too fast, it goes through thin platforms, or it sticks to the walls for no reason.
All of this can be fixed by simply asking the AI in plain English, without touching the code.
The method to create a platformer with AI
Step 1: the starting prompt
Don't settle for "make me a platformer". Copy this prompt instead, which already fixes a good chunk of the usual problems:
Create a complete platformer game in a SINGLE standalone HTML file.
Mandatory technical constraints:
- all the HTML, CSS and JavaScript in the same file
- no external resources (no images, no fonts, no libraries)
- colored geometric shapes drawn in canvas, no images to load
- portrait 9:16 format
- playable with the keyboard on desktop AND with touch on mobile
The game:
- a character who runs and jumps, side view
- platforms to cross, deadly pits, coins to collect
- a clear goal to reach to finish the level
- 3 levels of increasing difficulty
Game feel (important):
- variable jump height depending on how long the key is held
- a few frames of tolerance after leaving a platform (coyote time)
- falling faster than rising
- slight acceleration when starting and a small slide when stopping
Display: coins collected and level at the top, game over screen with a "Play Again" button.
Style: [colors, mood in two words]
Give me the complete file, ready to open in a browser.
Sure, it's long, but it's the details that get you what you want, because the AI doesn't have to interpret or guess the result. If you want to understand the logic behind this kind of prompt, our article on the best prompts to create an html5 game explains it all.
Step 2: get the HTML file
Copy the code, paste it into a text editor and save it as .html. You'll need this single file to put your game online, and we explain everything in our guide to turning an html file into a playable online game.
Step 3: the first test
Open the file in your browser and check these three things, in order:
- Does the jump respond right away? If there's the slightest delay, that's the first thing to fix.
- Can you finish the first level? A level that's impossible to beat is the most common bug.
- Does it work with a finger on a phone? Test on a real phone, not just by shrinking the window. Our guide to testing an html5 game on mobile gives you the full checklist.
The tweaks that change everything in a platformer
Stay in the same conversation and send these requests depending on what's not working:
- A floaty jump. "The jump is too floaty. Make the jump height proportional to how long the button is held, and make the character fall faster than it rises."
- A jump that doesn't fire. "Add a 100 ms tolerance: if I press right after leaving a platform, the jump should still go off." You can also add: "If I press jump just before landing, remember the press and trigger the jump on landing."
- The character falls through the floor. "The character goes through platforms when it falls fast. Fix the collision detection by splitting the movement into several small steps."
- The character sticks to walls. "The character sticks to walls. Handle horizontal and vertical collisions separately."
- The camera. "The camera jumps abruptly. Make it follow the character smoothly, with a slight delay."
- Difficulty. "The first level is too hard. Make it a tutorial level with no deadly hazards, and keep the difficulty for the following ones." AIs tend to make the start too hard, so this one comes up a lot.
After two or three rounds, you have a game that really holds up. If you'd rather start with a simpler genre, see our guide to creating a snake game with ai.
Customizing your platformer
Once the mechanic works, it's time to give it an identity. That's often what makes people want to share a game.
Swap the character for someone you know, turn the coins into a funny item and pick the background you want.
A few variants that work well:
- A time-trial mode, with a timer on screen.
- A hidden level, reachable from a spot nobody thinks to check.
- A two-player mode on the same keyboard, each with their own character.
Publishing your platformer
Your game is ready, but for now it's on your computer and you're the only one who can play it. To share it with your friends, or better yet with strangers, it has to go online. That's where Hoora comes in: it's a platform that hosts indie mini games like yours and shows them to players.
Go to the website and click the purple "Import" button in the left-hand menu.

- Drop in your HTML file, and a playable preview appears right away.
- Add a title and a description.
- Publish, or keep the game as a draft while you tune the difficulty.
It's free, and the only limit is a maximum file size of 100 KB.

Your game then shows up in the feed, and players can check out your profile to discover your other creations. It works on the website as well as in the app, available on Android and iOS, which also has its own page in Gizmodo's download section. You also get access to your game's stats: views, likes, shares, comments. For a platformer, that's really useful, since you quickly see whether people like your game or whether the difficulty needs tweaking.
Frequently asked questions
- Which AI is best for a platformer? The big three all do well. The difference mostly shows when you chain lots of fixes on the same file. Our comparison chatgpt vs claude vs gemini goes into it.
- How many levels can you ask for? Three to five short levels. Beyond that, the AI tends to get tangled up, so it's better to add levels one at a time.
- Can you have real graphics instead of rectangles? Yes, but stick to shapes drawn in code. If you add external images, you no longer have a single file, and publishing gets complicated.
- My character jitters when it runs, why? It's often a position rounding issue. Ask: "round the positions when drawing to get rid of the jitter".
- Do you need to know how to code to apply these fixes? No, all the requests in this article are in plain English. If you're starting from scratch, begin with our guide to creating a video game without coding.
- Will the game be playable on mobile? Only if you ask for it, and you need to check on a real phone.
- How long does a decent platformer take? One to two hours with the tweaks. You'll spend most of that time tuning the jump, but it's really worth it.
- Can you add sound? Yes, ask for sounds generated in code rather than audio files, so you keep a single file.
Now it's your turn to play! Run the prompt, tune your jump until it feels good, and publish your game to see how far players can get.