Show HN: A Terminal Tetris Game
github.comI 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 moving down the screen. This was in the very first class!
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.
After that, the students were given a series of staged assignments, finally ending up with the complete game by the end of the term.
Sorry that should of course been N by M
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, 0], [0, 0, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]] ```
Notice how the 1s form a square?
As I'm still learning Rust, any suggestions regarding the architecture, overall design of the game, more idiomatic code, etc., are very welcome.
If you want to play or just see how it turned out, check out:
Look up for tetrisconcept.net and theabsolute.plus discord ( https://discord.gg/6Gf2awJ ). Several people have made attempts to recreate sophisticated clones of Tetris, and the absolute plus leader board is written in rust.
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.
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! https://github.com/vicgeralds/vitetris
What is the greatest terminal game ever written?
I guess rogue, adom, nethack would be popular answers; probably the entire infocom catalog?
They're not really my cup of tea, the game I've enjoyed the most is probably asciiportal.
ascii-patrol is impressive. https://github.com/msokalski/ascii-patrol
Hello Tavis. On global IF:
Most Infocom games, plus Adventure.
From IF archive (amateur games, but these are anything but amateur).
Curses.
Jigsaw.
Anchorhead.
Spider and Web.
On roguelikes:
Nethack/Slashem.
Dungeon Crawl SS.
Cataclysm DDA.
Game pack: BSD games.
4x strategy/tactics:
VMS-Empire.
Note that VMS-Empire has a Unix port since forever.
Weird strategy/sim:
Liberal Crime Squad.
gcc
I got this:
thread 'main' panicked at 'index out of bounds: the len is 10 but the index is 18446744073709551615', src/core.rs:182:24I thought rust was meant to prevent this stuff?
And it did, panicking instead of letting you access something out of bounds is what bounds checking is about.
Pascal had that. Awesome stuff.
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.
Does it run on an Elektronika?
Nice. Never seen the original before.
The drop-and-slide of a square around 1:26 leaves behind some filled cells! I wonder if that's a bug or was it a part of the original gameplay.
I miss playing.netris with other users SDF.org..
But doesn't emacs come with this built in? It's practically pre-installed on most of the unix machines I've used. I've even played it at the Apple Store.
One can never have too many Tetris options. Shame on you.
So what? Not everything needs to be done revolutionary new idea.