Live data from Hacker News

Notch trying jsFiddle

jsfiddle.net

61–70 of 143 posts

Re: Notch trying jsFiddle

#61
post #23

Earlier quoted context omitted.

This code uses zero canvas / javascript specific functions. It is using basic trigonometric functions and is using canvas only to write RGB pixels. Canvas are much more powerful and high level than that, but this is not a good example as Notch just needed to set pixels.

Aren't the following canvas/javascript specific? ctx = document.getElementById('game').getContext('2d'); pixels = ctx.createImageData(w, h); ctx.putImageData(pixels, 0, 0); EDIT: Thanks for the clarification!

Antirez meant to say that notch is using canvas as a dumb framebuffer.

He builds the raster image pixel by pixel instead of using higher level primitives (polygons).

Re: Notch trying jsFiddle

#62

Why is the framerate poor even when I shrink the viewing area down 10x10? It seems to have the same stutter as the original large view. Is it because it's doing the same calculations but just showing fewer pixels?

Part of the reason it's slow is that it doesn't use typed arrays. This may be much faster for you: http://jsfiddle.net/uzMPU/1573/

Yes, at least 2x here. I'll pull up Chrome's FPS display later.

Re: Notch trying jsFiddle

#63

Very cool, but a few notes to anyone getting their hopes up on the powers of Canvas: As you may have anticipated, this demo runs at less than 1 frame per second on my Nexus 7. :/ In terms of per-pixel manipulation of a Canvas, it is very slow, even with javascript's (not very well supported) typed arrays. Simply put, multidimensional loops (unrolled or not) will always kill performance in JS with any significant dime…

Runs about 6-7 fps on my iPhone 5.

Re: Notch trying jsFiddle

#64
While this is cool, isn't this exactly what WebGL is for? I know drivers/support is an issue, but Chrome also ships with a multicore software renderer (SwiftShader) which can probably get a lot further than a JS putImageData engine.

Re: Notch trying jsFiddle

#65

Very cool, but a few notes to anyone getting their hopes up on the powers of Canvas: As you may have anticipated, this demo runs at less than 1 frame per second on my Nexus 7. :/ In terms of per-pixel manipulation of a Canvas, it is very slow, even with javascript's (not very well supported) typed arrays. Simply put, multidimensional loops (unrolled or not) will always kill performance in JS with any significant dime…

Runs about 6-7 fps on my iPhone 5.

Nice :) Shows you how fast ARM is progressing...

Re: Notch trying jsFiddle

#67
This shows how far the browser has to go....was it just me, or did your browser start to choke while rendering this?

It rendered it fine, but I could tell that the DOM was being abused heavily. I don't mean that in a bad way, but it just felt very 'heavy'.

On the flip side, this is awesome that the browser can do this - and it's awesome that browsers can do this.

Re: Notch trying jsFiddle

#69
post #14

Earlier quoted context omitted.

Yes, the procedure generates the texture of every "type" of block, the first loops after the init() function. 16 different types of blocks are generated. Then a random map is created, with the "center" that is set to empty blocks with high probability. Finally a function traces the map on the screen at every tick of the clock.

Ok, that's pretty cool :P

I've recorded a video explaining how it works: https://www.youtube.com/watch?v=WaZvDCmlERc
Post reply on HN