Live data from Hacker News

A first-person engine in 265 lines of JS

playfuljs.com

71–80 of 99 posts

Re: A first-person engine in 265 lines of JS

#71
post #25

Heh, reminds me of kkrieger - a first person shooter in 100KB for a scene demo. https://www.scene.org/file.php?file=%2Fparties%2F2004%2Fbrea...

If you missed it a couple of weeks ago, this article about its creation was really interesting: http://fgiesen.wordpress.com/2012/04/08/metaprogramming-for-... ( Thread: https://news.ycombinator.com/item?id=7739599 )

And here is Farbrausch's repo, which includes the .kkrieger code along with a lot of other interesting stuff.

https://github.com/farbrausch/fr_public

Re: A first-person engine in 265 lines of JS

#76
post #5
post #3

As someone with no experience in computer graphics it's always insane to see demos like this. Especially using just around 250 lines of javascript. Really impressive. Also on the topic, the demo scene stuff is mind blowing, too. [0] [0]: http://awards.scene.org/awards.php

The nice thing about this implementation is that the code is very clear and easy to follow. You could easily make it much shorter if that were the goal.

Exactly. I think that's wonderful about this example, it's not just 250 lines of heavily compressed code, it's readable and clean.

Re: A first-person engine in 265 lines of JS

#77

This demo unfortunately uses an incorrect perspective transformation. There is no reason to go to trig if you represent the camera plane as a vector, and step along it one pixel at a time, and allowing the wall height to vary linearly in the distance to the camera vector (taking lines to lines). In addition to being correct[1], it has the added benefit of being faster if implemented well. My (admittedly n00bish and e…

As an aside, the division by a square root being in the main loop of the algorithm is related to why http://en.wikipedia.org/wiki/Fast_inverse_square_root was developed.

Re: A first-person engine in 265 lines of JS

#78
post #3

As someone with no experience in computer graphics it's always insane to see demos like this. Especially using just around 250 lines of javascript. Really impressive. Also on the topic, the demo scene stuff is mind blowing, too. [0] [0]: http://awards.scene.org/awards.php

Me three. It's covered the 're-read in 6 months time' criteria. I must confess I do change from reading to scanning as soon as the heavy math kicks in.

Re: A first-person engine in 265 lines of JS

#79
post #25

Heh, reminds me of kkrieger - a first person shooter in 100KB for a scene demo. https://www.scene.org/file.php?file=%2Fparties%2F2004%2Fbrea...

If you missed it a couple of weeks ago, this article about its creation was really interesting: http://fgiesen.wordpress.com/2012/04/08/metaprogramming-for-... ( Thread: https://news.ycombinator.com/item?id=7739599 )

It's really interesting but would someone mind explaining why they have to keep this code under some size limit?

Re: A first-person engine in 265 lines of JS

#80
post #25

Earlier quoted context omitted.

If you missed it a couple of weeks ago, this article about its creation was really interesting: http://fgiesen.wordpress.com/2012/04/08/metaprogramming-for-... ( Thread: https://news.ycombinator.com/item?id=7739599 )

It's really interesting but would someone mind explaining why they have to keep this code under some size limit?

Because they can. Because it's fun and challenging to do so. Because bragging rights.
Post reply on HN