[λ] thegeez blog index

Pinball with Scittle/ClojureScript

01 Mar 2023

The past few months I have been on some longer train rides. These rides had plenty of time to look outside the window to the nice scenery between Dresden and Prague. Other routes were more suitable for programming.

To program on my Android phone I installed the UserLAnd app, which can run a full Ubuntu environment (or other Linux variants), without special permissions or special hacks to the phone or Android system. In this Ubuntu installation I run Emacs for coding with Paredit on Clojure code. The UserLAnd app adds the "Ctrl" and "Alt"/"Meta" key to the Android touchscreen keyboard. Together with some custom configuration in Emacs this makes nice Paredit editing available on my phone.

By far the easiest way of programming and running Clojure code on a phone I have found is with babashka/Scittle. This is Borkdude's Small Clojure Interpreter as a single Javascript file, which runs ClojureScript code within script tags on a webpage. This means you can edit a single file and run Clojure code in a browser, without needing to run a separate webserver or compiler.

The program I have been writing on my phone is a pinball simulator. This is based on the code and YouTube video explanations from Ten Minute Physics. This site has many nice tutorials about programming physics, such as what happens when two balls with a velocity collide. This accumulates into a pinball game.

My version of the pinball game is available here: Pinball game with Scittle. It is playable on touchscreen phones and in desktop browsers. The Clojure code is available in the html file via 'view source'!