Live data from Hacker News

Notch trying jsFiddle

jsfiddle.net

101–110 of 143 posts

Re: Notch trying jsFiddle

#101

Earlier quoted context omitted.

I respectfully disagree with your use of low level, though I do understand your analogy about the pixelbuffer being like a frame buffer. But he's actually using Javascript arrays which can get passed around inside a javascript VM, and do not have a set size. Not very "low level". I spent a moment and changed the arrays to Float32Arrays which have set sizes and sit in memory without being fucked with by the VM and spe…

Side by side, this is amazingly smoother than the OP.

For me, the difference is only visible using Firefox. Chromium even renders the inefficient original version smoothly.

Re: Notch trying jsFiddle

#102
I'm shocked and pleasantly surprised that js/canvas can putpixel fast enough for this. It must be around as fast as assembly on a 486!

Part of me can't decide if that's awesome or tragic.

Re: Notch trying jsFiddle

#103
post #6

Awesome implementation, actually no advanced feature is used, this code could easily ported even to assembler in any device where you can set pixels in RGB format. And indeed it is pretty impressive how fast the rendering happens given that the code operates at such lower level... Even selecting the color of every pixel requires non trivial work in the inner loop. AWESOME code.

I would argue that this is terrible code. It's not using the appropriate tools (webGL), it's badly structured, uncommented and unmaintainable (seriously, why on earth would anyone name their variables zd, _zd and __zd?). The Minecraft source code is also of notoriously poor quality. I honestly don't understand how you came to your conclusion.

Re: Notch trying jsFiddle

#104
This is actually quite fluid on iPhone 5. I asked a co-worker to try this on his Galaxy S3(quad-core, no lte) and it was really slow there. And in Chrome it was even slower than that on the S3.

Doesn't any web browser on Android use a JIT?

Re: Notch trying jsFiddle

#106
post #6

Awesome implementation, actually no advanced feature is used, this code could easily ported even to assembler in any device where you can set pixels in RGB format. And indeed it is pretty impressive how fast the rendering happens given that the code operates at such lower level... Even selecting the color of every pixel requires non trivial work in the inner loop. AWESOME code.

I would argue that this is terrible code. It's not using the appropriate tools (webGL), it's badly structured, uncommented and unmaintainable (seriously, why on earth would anyone name their variables zd, _zd and __zd?). The Minecraft source code is also of notoriously poor quality. I honestly don't understand how you came to your conclusion.

The code is a direct port of Minecraft4k[1], it's optimised for space considerations.

[1] https://twitter.com/notch/status/275329867984302081

Re: Notch trying jsFiddle

#107
post #24

Can someone dissect this code and explain what it does?

The first set of three nested loops is procedurally generating texmap, which is a multidimensional Array(16 * 16 * 3 * 16). 16x16 pixel textures, one for each the top, sides, and bottom, and then 16 of those. The inner loop tests against i, which is the current block "type" and performs customizations to the procedurally generated textures. The next set of three nested loops is generating a random "world" with a tunn…

It is worth to note that lightning model is trivial and only maps given directions of faces to given amount of bright. But other than that the bright is adjusted by distance.

It is pretty cool to see how a trivial lightning model like that can produce a pretty looking result.

If you want to see just the brightness of faces without texture to see more easily how light is used, just change the line:

    var cc = texmap[u + v * 16 + tex * 256 * 3];
Into:

    var cc = 255+(255
To also remove the "distant is less bright" effect just add:

    ddist = 255;
Before:

    var r = ((col >> 16) ...

Re: Notch trying jsFiddle

#108

Earlier quoted context omitted.

I would argue that this is terrible code. It's not using the appropriate tools (webGL), it's badly structured, uncommented and unmaintainable (seriously, why on earth would anyone name their variables zd, _zd and __zd?). The Minecraft source code is also of notoriously poor quality. I honestly don't understand how you came to your conclusion.

The code is a direct port of Minecraft4k[1], it's optimised for space considerations. [1] https://twitter.com/notch/status/275329867984302081

But that directly backs up my argument. From the horses mouth:

"Code is awful due to the nature of the project"

Post reply on HN