Slashdot Mirror


Javascript Game of Tron In 226 Bytes

Have you upgraded your hardware to play something beefier than 140-byte Tetris? New submitter alokmenghrajani writes with "a detailed view of how we size-optimized a game of Tron to just 226 bytes." It's also optimized for Chrome, and very fast.

11 of 115 comments (clear)

  1. 1KB Chess For The Sinclair by TheGoodNamesWereGone · · Score: 5, Informative

    1KB Chess for the Sinclair still has that beat.

    1. Re:1KB Chess For The Sinclair by lobiusmoop · · Score: 5, Informative

      Actually it was only 672 bytes - the 1024 byte memory had to include the screen memory also, much like shared video memory today - could take up to 768 of the 1024 bytes for a full 32x24 screen! (the chess game only used an 11-line screen for the board etc)

      And it's even considered by some to be the greatest program ever written.

      --
      "I bless every day that I continue to live, for every day is pure profit."
  2. Re:portability by hobarrera · · Score: 4, Interesting

    It works on chrome and firefox. This isn't a portability issue: normally developers add huge amounts of code to support IE. If it needs tweaking for IE, it would probably be 50% larger.

  3. Re:Damn. by TheRaven64 · · Score: 4, Informative
    Works fine in Safari. That said, if you press a key other than ijkl it does something random. I assumed wasd would work, and was very confused until I read the instructions. It's also single player, so you basically drive around until you hit your own wall - there's no way of winning. It's more a drawing program with a crappy UI than a game. Making it only 226 bytes of source isn't that impressive, it's basically:
    • Change direction if key is pressed
    • Test if pixel next in that direction is white, if so exit
    • If not, set it to white, set current location to that address
    • Repeat.

    I wouldn't be surprised if you could write the same game in under 226 bytes of Z80 or 6502 assembly, so doing it in a high-level language seems much less impressive.

    --
    I am TheRaven on Soylent News
  4. 2 player? by Ambitwistor · · Score: 5, Informative

    It's not really a game of Tron without a competing lightcycle. (Without fruit, it's not really a game of Snake either.)

  5. Calling this a game of "Tron" is a stretch by readandburn · · Score: 5, Insightful
    It should be called "Drawing-A-Line-In-A-Tiny-Black-Square-With-Terrible-Controls".

    Come to think of it, that might make a better movie than that last Tron.

  6. This again... by zAPPzAPP · · Score: 4, Funny

    226 byte which I am sure include library calls, only runs on top of the multi megabyte of browser code, may use various other resources as well.

    By this standard, I can write Tron in 1 bit.

    1

    There.
    Call it the "Run Tron Bit". It runs on top of a full impletation of Tron.

  7. Same thing in x86 asm by Juippi · · Score: 4, Informative

    This was fun, because I got pretty much the same thing down to 56 bytes in x86 assembly some 15 years ago. I remember the best entry in the competition I wrote it for being around 48 bytes or so; I missed at least one trick for setting the graphics segment more efficiently, and also something related to either collision handling or keyboard input, don't remember which.
    In any case, this is possibly the right version of the code. Should compile with NASM, and is even playable in Dosbox with arrow keys if you turn the emulation speed as low as it can go.

  8. And how much supporting code? by davidbrit2 · · Score: 4, Insightful

    How many megabytes of supporting code are necessary to run those 226 bytes?

  9. not tron by eyenot · · Score: 5, Funny

    I think there's a difference between Tron and Suicidal Etch-A-Sketch

    --
    "Stratigraphically the origin of agriculture and thermonuclear destruction will appear essentially simultaneous" -- Lee
  10. Etch-A-Sketch by tepples · · Score: 4, Funny

    Suicidal Etch-A-Sketch

    Please leave Governor Romney out of this.