Live data from Hacker News

Show HN: A Terminal Tetris Game

github.com

21–22 of 22 posts

Re: Show HN: A Terminal Tetris Game

#21
post #2

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: ``` [[0, 0, 0,…

Does representing tetrominos that way make hit detection or anything like that easier? My gut says the only thing they add is slightly smaller memory usage, but maybe i'm missing some sort of elegant bit trick.

Re: Show HN: A Terminal Tetris Game

#22

I successfully used Tetris to teach a first course in programming. What I did was provide a module I called "Gridworld". 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…

Sorry that should of course been N by M
Post reply on HN