TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: A Terminal Tetris Game

52 点作者 adder46大约 4 年前

9 条评论

herodotus大约 4 年前
I successfully used Tetris to teach a first course in programming. What I did was provide a module I called &quot;Gridworld&quot;. This provided a simple way for the students to create an N * N grid of cells where the cell size was fixed. The only other thing that could be done with Gridworld was to fill or clear the cells. After presenting Gridworld, I then asked the students how we might make an animation of a single square moving down the screen. This was in the very first class!<p>So instead of talking about semi-colons, syntax, types and so on, we thought about timing, animation, and how to make the animation uniform regardless of the speed of the computer.<p>After that, the students were given a series of staged assignments, finally ending up with the complete game by the end of the term.
评论 #26448807 未加载
adder46大约 4 年前
I wanted to share my attempt at implementing the classic tetris game. It works in the terminal and uses the ncurses-rs bindings for the UI part. For me, the coolest part about it is that the tetrominos and their rotations are encoded as 16-bit unsigned integers. For example, to represent a square, we want 51! Why 51? Because 51 decimal is `0b0000000000110011`. We can make 4x4 Vec from that, and we get:<p>``` [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]] ```<p>Notice how the 1s form a square?<p>As I&#x27;m still learning Rust, any suggestions regarding the architecture, overall design of the game, more idiomatic code, etc., are very welcome.<p>If you want to play or just see how it turned out, check out:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;adder46&#x2F;tetris.rs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;adder46&#x2F;tetris.rs</a>
评论 #26444703 未加载
评论 #26448056 未加载
caterama大约 4 年前
In no way detracting from your awesome toy project, intrigued people might also want to check out vitetris. Very similar tetris in the terminal with ncruses, but also supports network play! <a href="https:&#x2F;&#x2F;github.com&#x2F;vicgeralds&#x2F;vitetris" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;vicgeralds&#x2F;vitetris</a>
taviso大约 4 年前
What is the greatest terminal game ever written?<p>I guess rogue, adom, nethack would be popular answers; probably the entire infocom catalog?<p>They&#x27;re not really my cup of tea, the game I&#x27;ve enjoyed the most is probably asciiportal.
评论 #26446521 未加载
评论 #26447392 未加载
评论 #26445346 未加载
lucy_gatenby大约 4 年前
I got this:<p><pre><code> thread &#x27;main&#x27; panicked at &#x27;index out of bounds: the len is 10 but the index is 18446744073709551615&#x27;, src&#x2F;core.rs:182:24</code></pre>
评论 #26445871 未加载
elkos大约 4 年前
I have to admit that I have a soft-spot for the ncurses based bastet: a tetris clone that will give you the least useful tetrimo block.
gabrielsroka大约 4 年前
Does it run on an Elektronika?<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;O0gAgQQHFcQ" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;O0gAgQQHFcQ</a>
评论 #26444698 未加载
nevezen大约 4 年前
I miss playing.netris with other users SDF.org..
mulcahey大约 4 年前
But doesn&#x27;t emacs come with this built in? It&#x27;s practically pre-installed on most of the unix machines I&#x27;ve used. I&#x27;ve even played it at the Apple Store.
评论 #26446819 未加载
评论 #26445913 未加载