Show summary Hide summary
Creating a video game with ChatGPT
Table of Contents
I’m going to tell you how I managed to create a video game using ChatGPT, without having to write a single line of JavaScript code. Even though I am not a developer and I know nothing about this programming language, I was able to achieve this feat thanks to ChatGPT’s AI.
The stages of creation
It all started when I asked ChatGPT to code a Tetris game in JavaScript. He provided me with a simplified example of Tetris using canvas elements. I then copied this code into two files, an index.html file and a tetris.js file.
With this code base, I already had a good foundation for developing the game. However, I needed to add additional features to make the game more complete and interesting.
Added features
To manage coin rotation, collision detection, coin movement, scoring system, etc., I asked ChatGPT to help me. It provided me with a more complete version of the JavaScript file that included all of these features.
To read Discover the incredible unique capabilities of these mind-blowing comparisons!
I ran into a few issues along the way, particularly because I worked on this project during times when ChatGPT was underperforming. So I decided to resume the next morning and asked ChatGPT to continue coding while I took care of other tasks. Despite some minor errors, ChatGPT managed to fix these issues and provide me with working code.
Test the game online
Once I got the final code, I decided to test it by putting it on one of my servers. I used my CPanel, but it is also possible to test the game locally by installing a WAMP or XAMPP server on your computer.
I simply copied my HTML file and JavaScript file to the server, and I was able to play the game online.
Improve and customize the game
I then asked ChatGPT to help me improve and customize the game. I requested features such as displaying keyboard commands, adding a title, being able to choose a background image, and even find a domain name.
I also asked ChatGPT to optimize the game for mobile devices. He fixed the errors and adjusted the CSS so that the game displays correctly on a mobile screen. It also added the JavaScript features needed to allow the game to be played in touch mode on a mobile device.
Added mouse support
On top of all that, I asked ChatGPT to add mouse support to play the game. They provided me with the necessary code and even suggested improvements, like handling vertical movement and optimization of rotation sensitivity.
Creating a real site with a real domain name
Once the game was playable and optimized, I decided to create a real website with a real domain name. I asked ChatGPT how to add Google Analytics to track the number of visitors to my site. He also helped me optimize the site for SEO by giving me the meta tags to add to my HTML code.
To read GPT-4 revolutionizes website position tracking: find out how I created the ultimate tool!
Finally, I asked ChatGPT to help me integrate my social networks (YouTube, Facebook, TikTok and Instagram) with icons under the site title. He explained to me how to carry out these different steps.
The final result
The result is a beautiful website that includes a background video taken from Canva, a title, my social media and of course, the Tetris game. The game is fully playable with keyboard and mouse, and also works on mobile devices.
I managed to create this game without having to write a single line of code, and it only took me two and a half hours of work. The potential of ChatGPT is incredible, and there are many other possible applications.
Don’t hesitate to try the game by clicking on this link. Have fun and share your scores!