
Show HN: 2048.cpp – Play 2048 in directly your terminal - plibither8
https://github.com/plibither8/2048.cpp
======
josteink
Have we really come so far? This has to be full circle, right?

First we had a wave of “see what can be done in a browser!” kind of demos.

Which at the time was massively impressing, because nobody thought you could
_seriously_ use the browser for other things than documents and very slow and
clicky applications.

These days impressive browser-based experiences are the norm and native
software is often accused of being visually “boring” and inanimate.

And here we’re back at the beginning: a tech demo for a native app, in the
terminal, trying to reproduce what was once a tech demo of what you could do
in a browser, as if that’s somehow novel.

Just 30 (or more?) years after nethack.

I’m honestly not sure how to feel about that ;)

~~~
chickenfries
The game that 2048 is based on is a native mobile app...

~~~
chickenfries
Also, neither game was successful because it was an impressive graphically...
it was just a fun game. This whole discussion is irrelevant but happens all
the time on HN. Why?

------
erayare
Type

    
    
        telnet telehack.com
    
        2048
    

in a terminal

~~~
garaetjjte
For other telnet games, there is milek7.pl with tetris, breakout and
multiplayer pong.

~~~
ccozan
oh, I miss the backgammon games over telnet.

Does anyone knows of any servers still online?

~~~
patrickdavey
There's always fibs :)

telnet fibs.com 4321

------
abecedarius
Another, in Python:
[https://github.com/darius/sturm/blob/master/2048.py](https://github.com/darius/sturm/blob/master/2048.py)
This one animates the sliding of the pieces.

The terminal input-handling might not work in your OS -- I gave up trying to
find a nice cross-platform approach to that.

~~~
hk__2
> The terminal input-handling might not work in your OS -- I gave up trying to
> find a nice cross-platform approach to that.

I wrote a terminal version of 2048 back in 2014 [1] and the input-handling
works on all platforms I know of. You may want to look at the code:
[https://github.com/bfontaine/term2048/blob/master/term2048/k...](https://github.com/bfontaine/term2048/blob/master/term2048/keypress.py)

[1]:
[https://github.com/bfontaine/term2048](https://github.com/bfontaine/term2048)

~~~
abecedarius
Thanks. I'm not sure yet if that will help with the trouble I was having (I
wanted the library to support extra features not needed for 2048), but it's
great to see _small_ code to learn from.

------
iraphael
I wrote it in c as a first project in intro CS in college:

[https://github.com/iRapha/2048linux](https://github.com/iRapha/2048linux)

------
jgtrosh
I did a similar thing with 1010 a while ago:
[https://github.com/trosh/1010](https://github.com/trosh/1010)

These projects are probably useless but very fun to make and contribute to if
you feel like practising. Some stranger actually contributed to my rushed 1010
clone, it was the best feeling ever.

------
necubi
A few years ago I wrote a terminal version of threes (the imho better
predecessor to 2048):
[https://github.com/mwylde/Threes.scala](https://github.com/mwylde/Threes.scala),
including ANSI graphics for the gameboard.

------
evex
Same in Rust

[https://github.com/0xbsec/terminal2048](https://github.com/0xbsec/terminal2048)

------
vmednis
Did a similar thing a while ago that should work on all POSIX systems.
[https://github.com/vmednis/2048](https://github.com/vmednis/2048)

------
ninjakeyboard
Very cool!

I noticed Wikipedia references another app for terminal in C:
[https://github.com/Tiehuis/2048-cli](https://github.com/Tiehuis/2048-cli)

Might be interesting to compare.

~~~
krylon
There is version written in sed, too.

~~~
themattrix
That was mine!
[https://github.com/themattrix/sed2048](https://github.com/themattrix/sed2048)

~~~
krylon
You rock!

EDIT: Not only because of the technical achievement, but because this little
has allowed me to waste some time playing a fun game, while looking very busy
to passers-by to whom anything being done in a terminal looks like black magic
from The Matrix. ;-) That game can be seriously addictive.

------
tlextrait
Wrote it in C++ too a while back (5 years ago )
[https://github.com/tlextrait/2048](https://github.com/tlextrait/2048)

------
Mic92
Shameless self-plug: Play 2048 in the kernel -
[https://github.com/Mic92/2048.ko](https://github.com/Mic92/2048.ko)

------
billconan
nice! how did you record the commandline as a gif?

~~~
gbaygon
I will throw another option, very lightweight: licecap, works on win and osx,
from the original dev of winamp!

[https://www.cockos.com/licecap/](https://www.cockos.com/licecap/)

~~~
mikewhy
Had no idea and I've been pushing licecap for years.

------
sossles
Ok, now I'm tempted to rewrite Twenty to work in the terminal. It's already
c++!

------
djsumdog
Huh. Seems to misalign the right side of the grid in my terminal. Still pretty
cool though.

------
foota
At first I thought this was going to be one of those template preprocessor
games.

