I love this. I've been wondering how the picture is drawn with less than one `echo` per pixel, and it's very clever: the game is "not really" 3D, so you can run raytracing just once per column, and then you only need to draw a couple of lines (for sky, grass, and the actual object) -- this is done by outputting the "draw this pixel and move down by one" string to the terminal as many times as necessary using string repetition.
I've been considering working on a voxel render engine (not for Bash, but for another computationally limited environment). This is a treasure, I'm certain I'll find something useful here.
It's unfortunate that stty requires forking. Maybe the next project will be to use bash and rowhammer to call the necessary ioctls to do it without forking.
I had no idea this was possible with Bash. I’ve considered myself proficient with Bash at a pretty advanced level at times and this just blows me away. I don’t have the math chops to understand how it’s implemented, but it’s a pleasure to see.
I never ceases to baffle me how we're still stuck with these mind bogglingly slow shells. Pure madness. I can maybe understand that some apps require all the vt100 weirdness or whatever, but probably 90% of apps just write to stdout and err. Surely we can blit some text to the screen a bit quicker and put the other 10% into some compat mode.
Shells are slow (particularly bash), sure, but I'm not sure how the rest of your comment follows from that. The shell is not involved in interpreting terminal escape sequences in any way, and modern terminals are quite fast - I can render animations in a 350-column terminal and they are as smooth as can be, given the constraints.
Besides, the whole premise of this post is that bash is the wrong language for raycasting, kind of like writing bubblesort in CSS.
>put the other 10% into some compat mode
There is nothing preventing that, just test if the string contains sane characters only and use a fast path for that. The problem is that there is no actual fast path for software text rendering, you still need to process ligatures, etc.
She has been brainstorming how to handle texture mapping within the performance constraints of doing it in bash for a week now (long before she actually got this working) and so far we've come up with some hypothetical ideas but she has not tried any of them yet. Maybe tomorrow...
I've been considering working on a voxel render engine (not for Bash, but for another computationally limited environment). This is a treasure, I'm certain I'll find something useful here.
reply