Image from pngitem
OpenAI just released ChatGPT , a new language model that can chat with you, give you detailed answers to inquiries, and even help with programming.
I wanted to test the limits of this new AI bot and see if chatGPT could be a good pair programmer for designing video games. I wondered how well the AI bot can help game design learners build their own video game, I believe that with some help, anyone can build their own games.
Pygame
is an open source Python
programming language library for making video games. It's not a game development platform like Unity or Unreal Engine which are very popular among game designers. Pygame is easy to install lightweight, but has a lot of limitations and is better suited for light video games such as a 2D platformer.
Unlike the popular game engines, when using Pygame, every aspect of the game needs to be written in a line of code, which can quickly become tedious. That's why I wanted chatGPT
to provide some help.
Video of the current progress:
Screen.Recording.2023-03-17.at.17.32.37.mp4
First of all, I checked if ChatGPT can help:
That's a good start. I then asked the bot to create the basic structure of code for the game. He gave me a few lines of code, importing the pygame library, setting up the game window, the game loop that starts the game; fill the screen with a colour and stops the game when you quit.
I used the code from ChatGPT with a few modifications and continued with the background. I wanted a depth effect, so I chose a parallax background (it has 4 layers that moves at different speed depending on how far they are from the player). I had to learn from Coding With Russ on YouTube.
Then I incorporated the player that I wanted to animate, for this I used a sprite sheet. ChatGPT helped with the event handling of the game, to associate the animation frames to actual keys pressed by the player. I gradually added some of ChatGPT lines of code, then made some changes, and he helped with fixing bugs.
When the code got a bit messy, I asked ChatGPT how to optimise it.
The libraries used
Pygame
Game assets and graphic content
- Parallax background from
Luis Zuno
on itch.io - The player sprite sheet from
Elthen
on itch.io - Font from
- Yonah Bôle
- ChatGPT by OpenAI