Conquer Space with ChatGPT: My Journey Developing a Space Invaders Game

244 0

Writing a Space Invaders-like game using ChatGPT is the idea for this article. So begins how to Conquer Space with ChatGPT: My Journey Developing a Space Invaders Game.  As a 12-year-old I vividly remember walking into my first arcade game room in my local mall and walking up to a crowd of other kids playing a game. It was almost as if the game was radiating this green light all around them. (It is my story so I can remember it that way if I want). Prior to this, all I had seen was pinball machines, Breakout and Pong. I was immediately hooked like every other kid in that place. This was the beginning of my interest in games and the reason for this project.

The Idea

In another article/project I did recently I started to play around with ChatGPT. You can read about that here > https://notposted.com/unlocking-the-power-of-coding-my-journey-with-chat-openai-com/ From that sprang the idea to see if I could create a Space Invaders game using ChatGPT solely. Now that would be amazing since it took Tomohiro Nishikado a year. Admittedly, he was also making the hardware for this as well and my only need was for the software. I have completed this task in about 8 days of using my spare time to work on it. It ended up not being solely ChatGPT with my prompts. I had to jump in and figure some things out on my own, as ChatGPT struggled a few times to get what I wanted. To be fair, it may have been that I failed to communicate it to where it understood. But most of it was ChatGPT writing the code.

The Journey

The end product was just shy of 1,000 lines of python code. And this was the biggest issue I had in dealing with ChatGPT. In the beginning I was starting a chat by pasting the code I had to that point and then asking it to add or modify what I wanted. It has a limit on the number of characters you can submit, so after that limit was reached, I had to start working in sections. This slowed the process. I tried several ways to get around this. My first attempt was to divide the code in sections and tell it I was giving it 3 sections of the whole code. This works ok but sometimes from responses it gave I suspect that it either did not get all of it or forgot part of it. Unsure. It always wants to respond about each section of code, so I tried telling it to only respond with “OK” after each section and after the last section I would then ask it about the code. It might make it 1 or sometimes 2 sections doing this and eventually just started telling me what it thought about the section I entered. So ultimately, I just entered sections and then clicked on stop generating. Then once all sections were added I would ask away.

Better approach

The better approach was to just paste in the sections that mattered. For example, if I was working on changing the game over screen then I would only upload small sections related to that and ask it to do something. This made the process faster and more effective.

Features

Here are the features that I decided to include in this version:

  • High score
  • Sound effects for weapons, collisions, explosions, mother ship
  • Music for Main Menu and Game Over screen
  • Levels become progressively harder by adding a new row every other level. Every level becomes faster
  • Main Menu Play and Exit buttons to look similar to buttons in an arcade
  • Each alien to have a score value assigned
  • Mother ship that has the highest score and randomly moves across the top
  • Shields that show damage when hit by alien projectiles
  • Game over screen to show Game Over in 8 bit type lettering
    • Your score and High Score
    • Credits
    • Play Again and Exit buttons that look like an arcade button
  • An Easter Egg for those that can find it

Finished product

Here is a video of what the game looks like currently and I will make a link below for anyone wanting to download for free. I put an easter egg in this game. If you find it, please send me an email with the details of how you found it at [email protected].

Here is a link to download the finished Space Invaders game. Please tell me what you think about it.

Space Invaders Game
Space Invaders Game
Size: 37.37 MB
Version: 1.0
Published: March 25, 2023

Final Thoughts

This was a lot of fun and I am happy with the end results. I might go on to add more to it later. Maybe a player initials screen? Yes, that will definitely be on my radar for a future release. But for now, I just want to take a break from it. This is not exactly like the original, but I hope I still paid tribute to the original game. Here is a link to ChatGPT if you want to give it a try >> https://chat.openai.com/chat Please let me know your thoughts on how it turned out in the comments below.

Find more on https://notposted.com

Total 0 Votes
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

About The Author

Coolest hedgehog in town!

No Comments on "Conquer Space with ChatGPT: My Journey Developing a Space Invaders Game"

Leave a Comment

Your email address will not be published. Required fields are marked *