

JavaScript game of Tron in 219 bytes - bhaveshdhupar
http://alokmenghrajani.github.com/tron/

======
necubi
It's unfortunate that they decided to save 2 bytes by using onkeyup instead of
onkeydown. That choice makes the game nearly unplayable for me. Compare the
version in the demo to the one here: <http://micahw.com/tron.html> (221
bytes).

In any case, this is really impressive. It's always fun to see the tricks
people employ to get these tiny sizes (smaller than this comment!).

~~~
Natsu
No wonder the "lag" feels so bad. Also, the area is way too tiny and it needs
a way to restart without having to reload the page.

~~~
pgsandstrom
Also it needs multiplayer, achievements and a story mode. No, but seriously,
this was not a competition in making a playable game, they clearly specify the
rules that they have set for themselves.

~~~
indrax
Perhaps there should be a competitive genre where the goal is not brevity or
obfuscation, but being good.

------
Irfaan
I think I see a way of shaving another byte:

instead of "0<x%n&", you should be able to do "x%n&&". Works for me on Chrome.

My goal is to shave 2 bytes, so you can change the key handler _back_ to
onkeydown. :P

~~~
amenghra
There are 5 possible collisions: top edge, left edge, right edge, bottom edge
and the tail.

Your proposal does not cover the top edge.

------
groaner
Is this supposed to be Tron or Snake? I distinctly remember Tron being a
multiplayer game, with the mechanics such that moving along a wall or trail
increases your speed, putting you in position to cut off the other players and
make them crash.

~~~
exDM69
In the classic Snake game, the tail of the snake moves and the snake grows
longer when you eat snakefood. In Tron, the light trail stays there and you
try close in your opponents. So this game is definitely Tron, not Snake.

Tron is usually a multiplayer game and the speedup next to light trail you
mentioned is missing.

Btw. back in the BBS days there was a Finnish freeware Tron-with-weapons game
called "DeLuxe Moposota" (rough translation: moped wars). I have very nice
memories of it. It works nicely DosBOX. Here's a youtube clip:
<http://www.youtube.com/watch?v=Gozt-1BgVrU>

------
chrisbroadfoot
I would save 2 bytes by changing

    
    
       n=150,x=11325
    

to

    
    
       n=632,x=1e6 (or similar)
    

This increases the board size to 632x632 and saves 2 bytes, which can be used
to use _onkeydown_.

I suppose you only start approximately in the center, though.

------
cstuder
The code documentation part is a quite clever use of a slide tool. Very
enlightening.

------
unimpressive
Encountered a bug: When I die, the game keeps counting score as my "dead"
player keeps going across land behind the scenes.

~~~
objclxt
It's 219 bytes, it's not that clever! When you die it simply displays 'game
over' along with incremented timer. Because the entire logic is inside a
`setInterval` call it never gets stopped.

setInterval is set to update in 9 ms intervals - I assume because whilst it's
probably more playable (easier) at higher intervals doing so would require
additional bytes.

------
zrgiu_
Here's a question for you: how will this look on the new Mackbook Pro with
Retina Display ? The tron line is 1px wide, and on that computer's screen the
one pixel is too small to see.

~~~
asdfaoeu
Surely that must have some sort of scaling by default for webpages. Otherwise
I would guess nearly all websites appear miniature.

~~~
fishbacon
From what I have heard everything is up-scaled to match the native resolution
so things that are not optimized for the new displays just looks kinda bad.

~~~
eekfuh
Images would be this way, but fonts, gradients, vectors, etc all look fine.
(Unless the app itself hasn't been updated to render those in the new density.
Safari works great)

------
AlexFromBelgium
I read 'j' 'k' 'l' and thought "Sweet! Vim controls"

Not... :(

~~~
lucascaton
LOL!

------
jules
Cool, but due to limitations of the human mind it's almost impossible to play
without QWERTY.

------
odddogmedia
It's really cool to see how you've come up with tron in just 219b.

You mention saving 11 bytes, bringing the total to 212. Then another 9
(seemingly making it 203). But go on to say you saved 2 more bytes, making it
219. I'm confused.

~~~
reledi
From 212 bytes, 9 bytes were added (not subtracted) to keep track of the
score, making the total 221 bytes. Save 2 bytes and you get 219 bytes.

------
creamyhorror
I can't see the white line in my browser, just a square of black. I know it's
working because I get "game over" if I start the game with i, j, k or l. I'm
on Firefox 14.0. Do fix it.

~~~
ArcticCelt
rules: ...the code need only run on Chrome 17.

Works fine on Chrome. Use it. And read the rules next time. :)

~~~
dbaupp
Works fine for me on Firefox Nightly too.

------
ohadpr
beautiful.

i once participated in a similar competition only that it was in x86 Assembly,
my friends and I brought it down to 70 bytes and the winner from Finland did
it in 48!

<http://myweb.cableone.net/benlunt/hugi/compoold.htm#compo1>

------
dekz
You have a typo in the first sentence, 'exercice'. I like your presentation of
code walk throughs with slides.

~~~
amenghra
thanks for pointing it out, fixed!

------
epaga
Clever stuff, thanks!

typos: "exercice" -> "exercise", "brining" -> "bringing"

~~~
amenghra
thanks for pointing things out, fixed!

------
yowmamasita
219b for a buggy Tron game. my score keeps going up on game over screen

------
anoother
Why are the control reversed (mirrored)? Is that normal?

~~~
amenghra
the controls are absolute, with: j goes left l goes right k goes down i goes
up.

If you are a vim user, you'll be confused and fell like things are reversed.
Sorry :(

------
vhf
Score doesn't work properly on my chromium. After game over, hitting keys
makes me score more points.

~~~
jonasb
The game is still running in the background. It's just hidden.

------
bousquetcm
so... we don't like Chrome? Bc it's not playable and I don't feel like opening
FireFox.

------
itsbits
219 bytes makes it look gr8 work but lot of bugs...

~~~
amenghra
not bugs; tradeoffs by design :)

