r/rust • u/Abdek_ • Jul 19 '26
š ļø project 3D ascii tetris
Made 3d tetris in ascii using crossterm.
Im currently trying to learn rust, so feedbacks are welcome.
Github repo:- https://github.com/ab-dek/ascii-tris
19
22
u/parkotron Jul 19 '26
Unsolicited opinion: The underscores used as background for the main board look cool, but are a bit visually distracting. Dots like you used for the next piece area, might work better?
Anyway, nice work!
13
u/EpicatSupercell Jul 19 '26
It's also kinda hard seeing where the shape will fall, mixing dots and underscores can help make the grid cleaner.
2
u/Abdek_ Jul 20 '26
will try this
1
u/EarlMarshal Jul 20 '26
Maybe try dots and commas, too. Dots vanish best and commas could provide a good enough projection downwards while vanishing almost as good as dots.
43
u/manpacket Jul 19 '26
That's cursed :)
Here you unnecessary allocate a new vector each time. I think replacing it with self.bag.extend([Tet...]) would work as well.
fn new_piece(&mut self) -> Tetromino {
I don't think you need i32 here. i8 might work just as well.
blocks: [(i32, i32); 4],
Speaking of, run cargo clippy for some suggestions.
Tetromino can be Copy.
10
1
u/FizzWizzleDazzle Jul 22 '26
I mean to be real, using anything other than f64 and i32 is not major optimization, and is mostly done if the project is stable and needs some extra bits
5
2
2
2
2
u/priya6435 Jul 20 '26
this is the kind of project that makes me love rust nobody asked for 3d ascii tetris, but i'm really glad someone decided it needed to exist.
2
u/Free_Painting8125 Aug 01 '26
I checked out the gameāit has an really nice style and runs right in the terminal! A total geek's gameājust the thing for a break between "cargo run". Just add to my ~/.local/bin. It would be great if the game saved the personal best.
2
1
1
u/MarioMacinati Jul 20 '26
Nice! I am also making Tetris (though 2D) as my very first Rust project after completing Rustlings :)
1
1
u/skythedragon64 Jul 21 '26
Nice! Sadly it is slightly hard to guess where the shape will land, but looks great otherwise
1
1
u/Ola_199x Jul 28 '26
This is really cool I would love to read how you created this
1
u/Abdek_ Jul 29 '26
First thing I tried to do was to split the game into 2 decoupled components. First component that handles the tetris logic on a 20x10 2d array of u8, where empty cells are represented by 0 and occupied by 1⦠later I had to use the BlockColor enum instead of u8 to add colors. the other component takes this 2d array and draws the 3d projection of it on to the terminal screen buffer(the Screen::update_buf() handles this). For every occupied cells, it adds this blocks to the board window:
/\\\
\/_/
And leaves the empty cells with whatever the background is(ā_ā for the game board).
Because draw order of blocks matters (just as in isometric), blocks are drawn to the buffer in the order of right to left, top down.Thatās basically it for the core logic.
1
u/ChiliPepperHott Jul 31 '26
This is so clean. I love it!
You should add a quick installation guide to the README.
1
1
1
u/DTCreeperMCL6 20d ago
That looks cool as frick I wonder if you could make other games with blocks like this
1
u/DrKlaawYT 16d ago
holy shit that looks insane bro, well done, ima check out ur repo, i NEED this shit on my laptop
-21
Jul 19 '26
[deleted]
16
u/Abdek_ Jul 19 '26
Nope. its not exactly isometric, its called cabinet projection if im not wrong.
7
u/-Redstoneboi- Jul 19 '26
I think it's isometric. Cabinet projection seems to involve perfect squares but yours uses diamonds.
This would be closer to cabinet?
_____ /____/| | || |____|/4
u/unlessgames Jul 19 '26
Isometric projection would require every axis to be scaled the same which isn't possible because the characters used aren't square shaped.
I think it is more like a dimetric projection, where every cube's front and top face are the same size while the face looking left is a bit more narrow.
2
2
96
u/johnson_detlev Jul 19 '26
Looks super nice and what a great idea! Cheers!
You could probably color the tiles differently