Using AI to Completely Code a Snake Game: My Journey from No-Code to Deployment

Creating a game without coding experience is now possible with the aid of Generative AI. Follow the author's journey of using AI-powered tools to learn how to build a Snake game from scratch, and discover how AI assistance can help with learning a new skill.

October 16, 2024
|
By:
Syafiq Rahman

AI Generated Summary:

  • Project Initiation: The author used Generative AI tool Cursor.com to create a fully functional Snake game from scratch, starting with a simple prompt that generated code in Python and HTML.
  • Learning and Deployment: The author learned about Git and GitHub through interactive prompts and explanations from Cursor, and created a repository to host the game's code, deploying it on Render, a cloud platform.
  • Iteration and Customization: The game was iterated upon to make it mobile-friendly and customizable, including adding a D-pad control for mobile users and uploading custom images for the snake's head and food.
  • AI-Assisted Development: Throughout the process, Cursor provided step-by-step instructions and explanations, making it possible for the author to complete the project without prior coding knowledge.

Artificial Intelligence (AI) has revolutionized various fields: its influence in marketing, communications, and even coding is undeniable. One of the most exciting advancements within AI is the rise of Generative AI, which doesn’t just automate tasks but actively helps create new content—whether it’s generating text, images, or even code. With tools like GitHub Copilot, even complete beginners can now tackle tasks that once seemed daunting, as these AI systems generate functional applications with minimal effort.

I’ve always wanted to create games. I remember spending hours and hours playing Snake on the Nokia 3310, and later, Doodle Jump, Temple Run, and Flappy Bird in the heyday of smartphone games. To see if the promise of Generative AI for coding was what it had been hyped up to be, I started toying with the idea of making my own game... with the help of Generative AI.

In this article, I’ll take you through my journey. I pretended to be someone with no coding experience to test how far I could get to a fully functional Snake game.

This is what Generative AI unlocks the ability for generalists to turn their ideas into reality faster than ever before. For marketers and communicators, who are often brimming with creative ideas, Generative AI offers the power to bring those ideas to life quickly and with greater impact. It means transforming concepts into compelling digital experiences with unprecedented speed.

The First Prompt: A Simple Snake Game

First, I had to identify the right Generative AI tools for a novice coder. After researching on Google, I found that Cursor.com was the best for this. Cursor integrates AI capabilities directly into a development environment, while offering intelligent code suggestions through prompts. Its free version allows for a limited number of requests.

The journey then begins with a straightforward prompt: "Make me a snake game. Keep it simple." This was my first interaction with AI-generated code, and I wasn't sure what to expect. The result was a set of instructions for a Snake game using Flask and Render, with code for different types of files such as .py, .html, .txt and .yaml.

Cursor’s first output   showing a Python and HTML scrip for a Snake gam
Cursor’s first output showing Python and HTML script for a Snake game


A lot of these technicalities would not be familliar to the novice code, so I clarify what they were with Cursor. Some of my clarification prompts include:

  1. What are Flask and Render? (a lightweight web framework for Python and a cloud platform used for hosting, respectively)
  1. What is a root directory? (the folder that contains the files of your project)

Cursor explaining via a diagram what a root directory is


As I was coding, or prompting to be exact, this became a 101 Tutorial on the basics of programming, but within the context of making my game. After Cursor helped me figure out all the files that needed to go into my root directory, here’s what my project structure looked like:  

  • app.py – the main Python file that runs the game using Flask  
  • static/ – where images, CSS, and JavaScript live  
  • templates/ – for HTML files  
  • requirements.txt – a list of Python packages the app needs  
  • render.yaml – configuration for hosting on Render

Each file and directory had a specific role, and understanding how they fit together was key. Cursor didn’t just give me the code—it explained why these components mattered, helping me get a grasp on the project as a whole. I felt my first taste of success – this is really coming together!

The key takeaway here is that integrating programming basics into a meaningful project can give the novice code a greater sense of relevance and purpose, making the learning process more engaging than it might be otherwise. When applied to areas like marketing and communications, Generative AI can be a valuable partner in speeding up the path to impact and delivering measurable value.


Learning Git, Render, and the File Structure

After creating my root directory and populating it with the relevant files, I asked Cursor what’s next through the prompt: “Now that I've completed these steps how do I play the game on Render.”

Cursor explaining next steps after creating the root directory


As you can see from the screenshots, Cursor gave me step-by-step instructions on what to do. I was able to navigate GitHub and Render through Cursor’s instructions, and in so doing, understand these platforms more within the context of my Snake game deployment. GitHub is a web-based platform that helps developers collaborate on projects by hosting their code in repositories, and for my use case, this was where I uploaded my root directory.

Through additional prompts, Cursor helped clarify concepts as they came up, furthering my learning process. For example, it first instructed me on creating my Git repository through my terminal. As a no-coder would, I asked the AI “Can I push these files manually to the GitHub website?” and it duly obliged.

Cursor offering an alternative way to create a GitHub repository


Additionally, Cursor helped me gain an understanding of the relationship between files, GitHub, and Render, through additional prompting:

A prompt asking to explain the relationship between the root directory, the GitHub repository and Render

 


At this point, I deployed Snake, and it worked!

Iterating Toward a Mobile-Friendly Game

After having deployed the game, I was on a high, triumphant at my own ability (in partnership with Cursor) to create a game. That was until a friend of mine told me: “It doesn’t work on my phone!”  

Deflation. Ahh... Time to iterate 💪

Once I had the initial game running, it was time to make it more functional and engaging. My goal was to create a version that worked on both desktop and mobile devices. After a few iterations through back-and-forth chats with Cursor, fixing aesthetic and alignment issues, I managed to add a D-pad control for mobile users, while keeping the arrow keys for desktop players. This made the game far more versatile and usable.

New code suggestions for a more responsive design and touch controls

New code suggestions for a D-pad look and feel

 


Customization: Bananas For Food
 

Customizing the appearance was another aspect I wanted to explore. Instead of the default snake blocks, I decided to use custom images for the snake head and the food. After uploading my images and updating my files, I had created a Snake game I was proud of.

New code suggestions for a custom snake head image and food image


Reflections: The Role of AI in the Process

Looking back, what stood out most to me was how AI (through Cursor) simplified the learning curve. It wasn’t about AI doing the work for me; it was more like having a guide that could explain things as I went along. I didn’t feel overwhelmed by jargon or complicated concepts because they were introduced gradually, in a way I could understand.

This also made coding much more approachable, going through the journey hand-in-hand with Generative AI. What seemed like an impossible task at first became manageable by breaking it down into smaller, guided steps. It didn’t just generate code — it helped me understand the broader context of what I was building, from version control to hosting on the web.

If you are someone with a no-code background—this experience shows how accessible coding can be. Here are some links to get you started:

  • Cursor.com: AI-Powered Code Generation for AI coding assistance

With all that said, you don’t need years of experience to create something functional, impactful, or even fun. Armed with a clear vision, I leveraged Generative AI to bring my pet project to life—just like you can, no matter your field. Whether you're crafting compelling marketing campaigns, designing content, or even venturing into coding, AI empowers you to move from concept to execution faster than ever before, unlocking possibilities that were once out of reach.

Screenshot of final iteration of my Snake game on desktop mode