Slashdot Mirror


Tetris In 140 Bytes

mikejuk writes "Is it possible to write a JavaScript program in no more than a tweet's length? A website called 140byt.es says it is and has an implementation of Tetris to prove it. Ok, it only has two types of block — hence its title "Binary Tetris" — and there's no rotate, but it works. The blocks fall down the screen and you steer them into place. You can try it out by playing the demo. Of course the real fun is in figuring out how it works and there is lots of help on the site — so if you're bored how about the 140 character challenge?"

17 of 215 comments (clear)

  1. Nostalgia ... by WrongSizeGlass · · Score: 5, Insightful

    It reminds me of the old days when code was efficient and had to fit onto small discs and into limited RAM and/or ROM. The original Mac ROMs were 128k, and all the apps had to run in 128k of RAM. It was amazing what could be done when it just had to fit.

    1. Re:Nostalgia ... by arth1 · · Score: 5, Interesting

      It reminds me of the old days when code was efficient and had to fit onto small discs and into limited RAM and/or ROM. The original Mac ROMs were 128k, and all the apps had to run in 128k of RAM. It was amazing what could be done when it just had to fit.

      Get off my lawn. The ZX-80 and -81 had 1 kB, and there were plenty of games for them. Then there were other computers, all with limited memory.
      I'm sure there are lots of people here except yours truly who have written a variant of SNAKE.

    2. Re:Nostalgia ... by peragrin · · Score: 5, Funny

      However the code itself is 140 bytes, the number of libraries required to operate it is at 10 gigabytes.

      --
      i thought once I was found, but it was only a dream.
    3. Re:Nostalgia ... by thesh0ck · · Score: 5, Informative

      The fact is.. only the math is 140bytes. If you view the source and scroll down you see there is way more than that to actually make it work. Including javascript for controlling the game and displaying the blocks. It is in fact 1361 bytes.

    4. Re:Nostalgia ... by Anonymous Coward · · Score: 5, Insightful

      Oh, well, in that case, allow me to introduce you to my 4 character Tetris program.

      t();

      (That's a function call to an external library that does all the other shit needed)

    5. Re:Nostalgia ... by hal2814 · · Score: 5, Funny

      A tweet? I'm not familiar with that metric. Maybe you could convert it to something more standard like Libraries of Congress.

    6. Re:Nostalgia ... by Anonymous Coward · · Score: 5, Informative

      The european versions had just 1k (two 2114 chips of 1k x 4 bit)

    7. Re:Nostalgia ... by Anonymous Coward · · Score: 5, Funny

      in javascript you don't need to end the last statement on a line with a semicolon, so you could reduce it to t()

    8. Re:Nostalgia ... by Dogtanian · · Score: 5, Informative

      Trust me, 1kB.

      To clarify this, you're right that the original versions of the ZX80 and ZX81 both had 1KB onboard.

      However, the US version of the ZX81 (the Timex Sinclair 1000) shipped with 2KB onboard, which is probably what the GP was thinking of.

      --
      "Slashdot - News and Chat Sites Deviant". (Click "homepage" link above for details).
  2. Read the source code - love the licence.txt by Dark$ide · · Score: 5, Interesting
    Take a look at the source code

    You'll love the non-restrictive EULA.

    --

    Sigs. We don't need no steenking sigs.

    1. Re:Read the source code - love the licence.txt by Anonymous Coward · · Score: 5, Informative

      You'll love the non-restrictive EULA.

      It's called WTFPL.

  3. Somewhat Misleading by iONiUM · · Score: 5, Informative

    Not to diminish their accomplishment, because this is very cool, but the 140 byte implementation is the base logic, it's not the actual printing or keyboard handling. Maybe that's nitpicking, but technically you can't just copy/paste that code and have the game, so I find the summary misleading.

    1. Re:Somewhat Misleading by hydrofix · · Score: 5, Informative

      Here's actually a full Tetris with sound in 1016 characters!

  4. Dear /. Overlords by TubeSteak · · Score: 5, Informative

    so if your bored

    Dear /. Overlords,

    Would it be too much trouble to plug some type of grammar and spelling module into the slash-code?
    Not for us, the /. users; for you, the /. editors. I believe that in this wonderful age of computing, we wouldn't
    begrudge you guys a little help before you hit "submit."

    Sincerely,
    You're

    --
    [Fuck Beta]
    o0t!
    1. Re:Dear /. Overlords by Nerdfest · · Score: 5, Funny

      Your being to picky. People care less about grammar these days ten most other things. Irregardless, there doing the best they can

  5. Still not as good as: by lobiusmoop · · Score: 5, Interesting
    --
    "I bless every day that I continue to live, for every day is pure profit."
  6. Fail - it's actually 845 bytes. by Barbara,+not+Barbie · · Score: 5, Informative

    If you actually look at the code, just the javascript is 733 bytes after taking out all whitespece, etc, not 140. And this doesn't count the html that embeds it - an additional 112 bytes, for a total of 845 bytes.

    --
    Let's call it what it is, Anti-Social Media.