Here’s “Snek”. A clone of the classic Snake game, made with Excel VBA.

snek
Snek likes apples.

To play the game: Download Snek and rename the file to “Snek.xlsm”.

WordPress didn’t allow me to upload a workbook with macroes, so I had to rename it to the ordinary format xlsx.

The code is open and it should be easy to see how it works.

Notes on the programming:

  • Excel VBA can’t really handle threads so it’s a poor platform for game making.
  • The snake is really just a head and a tail, no pun intended. No arrays etc.
  • Borders were added to the snake to prevent the tail from eating itself when curled up.
  • GetAsyncKeyState([key]) and DoEvents were used to get input from the user while in the game loop.
  • Sleep API sets the game speed.

Please comment if there’s any questions. Have fun!

Advertisements