ChatGPT, zero coding experience, and a video game from scratch.
Disclaimer: The game created to make this article is not for commercial sale and was merely an experiment.
ChatGPT can generate hundreds of lines of perfect code and take you through the game development process from start to finish, teaching you along the way.
Reverse Prompt Engineering
ChatGPT knows way more about developing games than me, so I had it help write the prompt. Having ChatGPT help create its prompts saves time and produces more ideal results. The best part is that all reverse prompts start the same, so this form of prompt engineering can be applied to various situations.
I want you to become my prompt engineer. Your goal is to help me craft the best possible prompt for my needs. The prompt will be used by you, ChatGPT. You will follow the following process: 1. Your first response will be to ask me what the prompt should be about. I will provide my answer, but we will need to improve it through continual iterations by going through the next steps. 2. Based on my input, you will generate 2 sections. a) Revised prompt (provide your rewritten prompt. It should be clear, concise, and easily understood by you), b) Questions (ask any relevant questions pertaining to what additional information is needed from me to improve the prompt). 3. We will continue this iterative process with me providing additional information to you and you updating the prompt in the revised prompt section until we have answered all of your questions.
ChatGPT responded, and we started engineering the perfect prompt.
After many iterations, the engineered prompt looked like the following.
The gameplay for “Monkey Bird” came from the infamous “Flappy Bird” game. The game elements were Wizard of Oz themed. The yellow brick road influenced the yellow background, and the monkey with wings was based on the flying monkey characters.
Next, ChatGPT gave me its answer through steps to create the game.
The steps might seem obvious if you are an experienced coder, but they helped me get started. I downloaded Visual Studio Code and was off to the races.
ChatGPT gave me the code for the index.html, styles.css, and game.js files. I stored them in a folder on my desktop to test the game in a web browser as it developed.
Creating a working game took a couple of hours, and there was a lot of trial and error. Whenever I encountered a problem, I had to query ChatGPT-4 about fixing it because I had no experience. This often included copying and pasting the whole game.js code into the chat to identify issues.
The most significant limitation was the code output maximum. ChatGPT-4 could only output 90 lines of code at a time. This was fine initially, but there were incomplete responses when the code got longer. As a result, I sometimes had to prompt ChatGPT for the rest of the code.
Most impressive was how ChatGPT provided complex code to solve my problems. For example, when I wanted the wings to disappear when they flapped, ChatGPT understood my plain language and quickly adapted it to code. With one instruction, it created an “if” function that achieved my desired result.
ChatGPT also added gravity to the game.
The Final Product
The game works! It’s a simple game, but the gameplay is similar to what I imagined. I decided not to develop it to the point of release in the app store, but I might return to the code, add more detail, and continue to improve the game.
Watch this short video for the complete game.js code and to see the game in action.
The monkey is a brown circle with two white circular wings. The monkey appears to flap its wings when the player clicks. The click causes the wings to disappear and propels the monkey upward until gravity takes over. I admit the wings look more like eyes blinking, but it’s an enjoyable detail. To make the game easier, I made the pillars smaller and the gaps between the pillars larger. This allowed me to triple my high score.
What would you like to see ChatGPT code next?