Hacker News new | ask | show | jobs
by abhinai 2644 days ago
Fascinating! Are there any easy to follow tutorial on how to manipulate pixel blocks (I wonder what the right term is) inside terminals?
2 comments

If you're referring to the game pieces, the creater probably just used these Unicode characters: https://en.wikipedia.org/wiki/Block_Elements
As you can see from the program and screenshot right in front of you, xe did not.

It's one of only two printw()s in the code, and the screenshot shows the result quite clearly.

You are correct; the code to print the blocks is on lines 35-37 of tinytetris-commented.c.

But the large comment at the top of the tinytetris.c file is made of the block drawing characters :)

The attron sets terminal attributes which presumably cause it to flip the " " into a solid block. I haven't decoded what exactly the number it's feeding in represents, but 262176 is 0b1000000000000100000, and the attributes are defined around line 1100 of curses.h on my system (/A_NORMAL will find it).

the attron() used is attron(A_REVERSE | COLOR_PAIR(n)). The OR operator is used to combine attributes in curses.