ClojureScript snake game with p5.js

#clojurescript#p5js

I made a simple snake game using ClojureScript and p5.js, with scaffolding courtesy of shadow-cljs.

gameplay

The inspiration came from an old YouTube video by The Coding Train, which shows how to implement the snake game with JavaScript and the library p5.js.

My first attempt was almost a direct mapping of their JavaScript code to ClojureScript. It worked but the code got messy and had to be cleaned up.

The code is on GitHub, to run the snake demo, make sure the src/main/core.cljs file “requires” main.snake like this:

(ns main.core
  (:require [main.snake :as demo]))