Hacker News new | ask | show | jobs
by qsera 66 days ago
>everything you could do with QBASIC, you can do with an HTML file

Oh yea? give me the equalent of PLAY function. Or the PSET function to turn individual pixels on and off on the screen. Give me the function to read the color of any onscreen pixel (admittantly not QBASIC but some C variant)...

FFS you can't even draw something delayed on screen without having to deal with the setTimeout, setInterval madness. That alone would kill any interest that a kid might be starting out with!

1 comments

>Regarding your examples: PSET corresponds to `ctx.fillRect(x, y, 1, 1)` on a canvas, reading a pixel corresponds to `ctx.getImageData(x, y, 1, 1)`.

What is a `ctx` and why do I need that? These are all hacks. Graphics programming in bolted on HTML in the form of canvas. It is a horrible platform for doing fun graphics programming when compared to qbasic.

>For delays, you define "sleep" (one line) and write "await sleep(500)" inside a loop, just like with "SLEEP" in QBASIC.

Kindly provide the code for this sleep function and tell me how a beginner who is trying draw some graphics on screen is supposed to figure that.

I think if you could figure out how QBASIC works, you can easily figure out how to draw in a canvas: https://www.devtoolsdaily.com/canvas/playground/

For sleep: const sleep = (ms) => new Promise(x => setTimeout(x, ms))

then you use like, for(;;) { console.log("hello"); await sleep(1000); }

The extra you get with this is the awesome dev tools. You can try it in this very page.