This is super condensed but still very readable if you know Reagent and Hiccup.
It's interesting to compare this to a lot of tetris clones written in TypeScript. There are a few that take enormous pleasure in defining a type hierarchy and what not.
Contrasting that to the very compact representation of tetrominos
Thanks! I really enjoyed the data modeling aspect of this project. I also ended up modeling the board as a mapping of [row, column] -> color which might be different from the traditional 2D array representation.
Why pick Typescript instead of Javascript as a comparison? there's really not that much difference in your example if plain javascript objects/arrays/functions was used.
Clojure has better and more map handling functions in the std lib for sure, but I find that with the help of some libs you can write lots of Javascript in a Clojury way without too much hassle.
to create obfuscated and undocumented code? That's known already.
The goal actually is this: being able to write descriptive and understandable code for others and oneself.
Come back to the code a year later and is it still understandable? Lot's of cute character-level operators and fancy control flow is maybe not the way to go.
A few years ago some friends and I wrote a tetris clone to celebrate the 30th anniversary of tetris and learn ClojureScript in the process. Really fun group project.
Sweet! Thanks for sharing. I see you're using pure-store to manage your game state. My implementation also uses a redux pattern for state management :)
[+] [-] beders|7 years ago|reply
It's interesting to compare this to a lot of tetris clones written in TypeScript. There are a few that take enormous pleasure in defining a type hierarchy and what not.
Contrasting that to the very compact representation of tetrominos
and the very cute rotate function: gives you a good idea what a Lisp is about.[+] [-] djblue|7 years ago|reply
[+] [-] Scarbutt|7 years ago|reply
Clojure has better and more map handling functions in the std lib for sure, but I find that with the help of some libs you can write lots of Javascript in a Clojury way without too much hassle.
[+] [-] lispm|7 years ago|reply
The goal actually is this: being able to write descriptive and understandable code for others and oneself.
Come back to the code a year later and is it still understandable? Lot's of cute character-level operators and fancy control flow is maybe not the way to go.
[+] [-] hota_mazi|7 years ago|reply
Except that with static types, you'd gain a lot of clarity, efficiency, and future maintenance, one of the downfalls of Lisp.
[+] [-] chrisoakman|7 years ago|reply
A few years ago some friends and I wrote a tetris clone to celebrate the 30th anniversary of tetris and learn ClojureScript in the process. Really fun group project.
Playable here: http://t3tr0s.com/
Repo: https://github.com/imalooney/t3tr0s
[+] [-] djblue|7 years ago|reply
[+] [-] gunn|7 years ago|reply
Both the game and the source are much more minimal, it's very easy to customise the rules. You can see the source here: https://github.com/gunn/tetris/blob/master/src/store.js
[+] [-] djblue|7 years ago|reply
[+] [-] yogthos|7 years ago|reply
[1] https://github.com/yogthos/clj-tetris/blob/master/src/tetris...
[+] [-] rschachte|7 years ago|reply
[+] [-] djblue|7 years ago|reply
[+] [-] city41|7 years ago|reply
[+] [-] soup10|7 years ago|reply
[+] [-] brabel|7 years ago|reply
[+] [-] a_t48|7 years ago|reply
[+] [-] djblue|7 years ago|reply
[+] [-] djblue|7 years ago|reply