TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Termtris: A Game Like Tetris in Ten Functions

144 pointsby tylerneylonover 10 years ago

14 comments

adamesqueover 10 years ago
Whoa! Love the idea of a hybrid lua&#x2F;markdown file; I didn&#x27;t realize that the readme for the Github project WAS the source code till I noticed it was just a symlink to the .lua file.<p>Very cool.
评论 #8435025 未加载
jewelover 10 years ago
The more flexibility a language gives you in the order you place your code, the better it is for literate programming. If you haven&#x27;t seen it yet, check out the source code to coffeescript.<p>Here is the source file: <a href="https://github.com/jashkenas/coffeescript/blob/master/src/grammar.coffee" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jashkenas&#x2F;coffeescript&#x2F;blob&#x2F;master&#x2F;src&#x2F;gr...</a><p>Here is a nicely rendered version of the same file: <a href="http://coffeescript.org/documentation/docs/grammar.html" rel="nofollow">http:&#x2F;&#x2F;coffeescript.org&#x2F;documentation&#x2F;docs&#x2F;grammar.html</a><p>Also see literate coffeescript, a mode that seamlessly integrates markdown. I&#x27;d give up vim for a environment that lets me embed images, embed SVG diagrams, use those SVG diagrams at compile time to generate code, etc.
评论 #8435581 未加载
评论 #8435616 未加载
taericover 10 years ago
So, I am definitely a fan of literate programming. I&#x27;m not sure I am a fan of what I will call the polyglot method, though.<p>Specifically, I don&#x27;t think I fully grok&#x2F;agree with the utility of having a single file that is both a markdown file and a lua file through commenting. In the end, it means you are still greatly limited to the ordering semantics of the main language.<p>Which is <i>not</i> to say some folk won&#x27;t do an amazing job writing a program. They clearly will. However, I think the macro approach of CWEB (or noweb, even) still has a lot of mileage that is overlooked nowdays.
评论 #8437061 未加载
cpayneover 10 years ago
As a Microsoft developer who has never looked at a terminal before, I find these projects amazing. The OP wrote a tertis clone in terminal - clever &#x2F; cool<p>THEN its well documented!<p>THEN its in one file - wtf?<p>Well done!
评论 #8435382 未加载
advocaat23over 10 years ago
Pretty nice. Writing a tetris clone targeting terminals is a fun endeavor and the easiest way to produce some moving graphics (besides Conway&#x27;s Game of Life). It&#x27;s also interesting to ignore curses and read and write plain bytes to the terminal and see what happens. I learned lots of nifty details about terminals there and you find pages like this:<p><a href="http://www.ibb.net/~anne/keyboard/keyboard.html" rel="nofollow">http:&#x2F;&#x2F;www.ibb.net&#x2F;~anne&#x2F;keyboard&#x2F;keyboard.html</a>
kazinatorover 10 years ago
Original Tetris for Terminals: 1989!<p><a href="http://www.miketaylor.org.uk/tech/tt/" rel="nofollow">http:&#x2F;&#x2F;www.miketaylor.org.uk&#x2F;tech&#x2F;tt&#x2F;</a><p>Not done in 10 functions though! C on Unix.<p>However, IOCCC entry in the same year:<p><a href="http://homepages.cwi.nl/~tromp/tetris.html" rel="nofollow">http:&#x2F;&#x2F;homepages.cwi.nl&#x2F;~tromp&#x2F;tetris.html</a>
sebnukem2over 10 years ago
Best documented little project ever.
laluniaover 10 years ago
Like the example ~300 line tetris implementation for tinygame: <a href="https://github.com/nmillerns/tinygame" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nmillerns&#x2F;tinygame</a> Except that uses raw prints and termios in python instead of curses
liadmatover 10 years ago
Cool project. It reminded me of the &quot;Tetris in 140 bytes&quot; project, worth a look: <a href="https://gist.github.com/aemkei/1672254" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;aemkei&#x2F;1672254</a>
dimitarover 10 years ago
Tetris implementation for emacs: <a href="http://home.pipeline.com/~hbaker1/emacs/tetris.el" rel="nofollow">http:&#x2F;&#x2F;home.pipeline.com&#x2F;~hbaker1&#x2F;emacs&#x2F;tetris.el</a>
nebyoolaeover 10 years ago
This is a great little game and the documentation is amazing.
sungeunsover 10 years ago
Wow, the document is awesome and code is really understandable though I haven&#x27;t used lua before. It&#x27;s pretty nice work! thanks for sharing :)
dmritard96over 10 years ago
The elegance of the block descriptions made me blush, haha. Very nice.
chrisweeklyover 10 years ago
This gives &quot;self-documenting code&quot; a whole new meaning. ;b