Terminal Parallax Vibes

2025-05-21

It still feels alien that you can vibe code stuff like this in 20 minutes:

CleanShot 2025-05-21 at 22.52.45.gif
Look ma! I'm shooting aliens from the terminal!

The best part? You only need the Python standard library to build this!

Instead of just staring at the result you can also take the time to dive deeper and to take notice of some of the techniques that are used. More people should do this! Everything here is written in Python, but there are a few fun things that stand out once you start looking at the generated code.

  1. The code uses curses which takes care of "terminal-independent screen-painting and keyboard-handling". It's part of the standard library!
  2. There is a big while not game_over loop that keeps the game running. To mimic the feeling of framerate we do some calculations after which the script sleeps for 0.016s to make it feel like there are 60 frames per second on display. I've used a similar technique in Javascript before, which relies on an asynchronous timeout instead of sleeping but it seems to work well enough!
  3. There is a parallax effect that makes it look like stars are passing by. These stars are just characters that each have their own speed factor. Some move faster, some move slower, some are lighter, some are darker. It's more random than you might think, but it really does the job in terms of the effect.
  4. Collision detection between enemies/bullets is really just looping over all the "pixels". There's not so many of them, so looping can actually work.
  5. Enemies actually are character sprites that just move downwards. Just like the explosions after you hit an enemy.

Study those vibe coded results people! Or you're totally missing out!