3 ms·
A WASM runtime in TypeScript types is impressive in its own right, but I think I can dimly see how it could work with a lot of effort. https://github.com/Michig
by dfabulich 2y ago
A WASM runtime in TypeScript types is impressive in its own right, but I think I can dimly see how it could work with a lot of effort. https://github.com/MichiganTypeScript/typescript-types-only-wasm-runtime https://github.com/MichiganTypeScript/typescript-types-only-...
What I don't understand is how this thing does keyboard input.
At 3:42, the video simply says, "And, yes, there's a way to do keyboard input," without elaborating on how. What sorcery is that? There must be something outside the type system translating keyboard input into TypeScript types…??
- darcien 2y agoI haven't checked the DOOM one, but for the Pong example, the keyboard input is prerecorded. As in the sequence of the keyboard key press are sequenced in a TS array[0]. [0]: https://github.com/MichiganTypeScript/typescript-types-only-wasm-runtime/blob/afb418c24fa3980ec4cd4e4b04382fc7759ed348/packages/playground/pong/pong.engine.ts#L30-L47 https://github.com/MichiganTypeScript/typescript-types-only-...
- dimitropoulos 2y agoyep! exactly this! like how a tool assisted speedrunner works
- Jare 2y agoThat's also how the Doom demos worked right? :D
- pcthrowaway 2y agoIf I had to guess, it's a file with an array of keys pressed (or unpressed) at some time interval (say 0.1 seconds). Then a VS code extension can append to the array every 0.1 second along with any key-press states at that time. The compiler updates the game state whenever this array gets updated. However, I'm guessing this is why we see a demo of pong and not doom. Doom probably just can't keep up with this. No idea if I'm remotely on the right track here though.
- dimitropoulos 2y ago(author here) pause on that screen and look at the code displayed on the right (as well as the note at the bottom!) the way to do keyboard inputs is basically exactly what people do for tool assisted speedrunners. Some people at this point in the message just went "oh cool!" and others went "you liar! that's not the same thing!". There was SO MUCH to say in 7 minutes in a short video like that, but rest assured, I'll go into depth on that in the next videos. The pong stuff that's shown is real (only the animating part was the creative liberty) and it's in the open source codebase.