~alefnull | blog

alefnull's periodic musings

i made a flappy bird clone using GitHub Copilot.

September 16, 2021 — ~alefnull

i've been using and abusing GitHub's Copilot VS Code extension ever since getting early access to it several weeks ago. it's been a lot of fun, and also extremely educational for me. i've learned more about programming in general, and about several different languages, over the last few weeks than i have in my entire life up until this point.

when i first heard about Copilot, i was seeing a lot of youtube clickbait titles like "IS GITHUB COPILOT GOING TO REPLACE DEVELOPERS??". but the truth is that it's just another tool. Copilot definitely can't (and likely never will) write an entire piece of software by itself. it still needs something to steer it in the right direction. what it is good at, however, is pretty useful and impressive.

one of my favorite perks of using it so far has been that it has basically forced me to start writing very clear, concise comments, describing in detail what i hope to build. when i do that, at the top of a file, and then i go down and start typing the first line of actual code, that's when Copilot's magic kicks in.

Copilot will read all of those comments, and use them as context for what it produces in the file from then on, making its predictions significantly better than if it was just blindly trying to figure out what you wanted as you were coding.

another neat 'feature' is the fact that Copilot will use your particular code 'style' preferences, as long as you make them clear in the beginning.

for example, if at the beginning of the file, you start using a consistent variable naming convention (i tend to stick with snake_case, personally) then Copilot will notice, and will try to keep future results in the same format. again, this is as long as you have made it a consistent thing throughout the file.

all of that, and i haven't even talked about what i started this post for in the first place: the 'flappy bird' clone i made using Copilot's help.

the code's pretty messy, because i basically laid it out as 3 javascript files (the 'bird' class, the 'pipe' class and then the 'main' game file with all the logic), wrote comments about what i wanted in each file, and then basically let Copilot take me where it thought i should go from there with each file. unfortunately, Copilot doesn't use project-wide context, so each file is an island unto itself as far as Copilot is concerned. but even so, it managed to keep a fairly consistent pace throughout the initial process of building out each file.

all told, it took me a full day to make this by slowly taking what Copilot produced and tweaking and tailoring it to work the way i expected it to.

was it worth it?

i don't know, but i've found myself playing the damn game when i have time to kill, so i guess that's good enough.

tags: github, github-copilot, javascript, vs-code

comments?