Live data from Hacker News

A Raycaster in Bash

github.com

21–30 of 36 posts

Re: A Raycaster in Bash

#21

Imagine a TUI where you need to navigate a literal maze of options

Like this one in Jurassic Park? https://youtu.be/URVS4H7vrdU Funnily enough, the slow rendering is kind of a plot device here.

The program from that scene was not some crazy invention for the purpose of having an interesting computer scene. It is a real piece of software for silicon graphics workstations called fsn (File System Navigator).

There's a x windows remake of it called fsv: https://fsv.sourceforge.net/

And then there's this even cooler UI which takes this whole idea much further called eagle mode: https://eaglemode.sourceforge.net/

Re: A Raycaster in Bash

#23
post #21

Earlier quoted context omitted.

Like this one in Jurassic Park? https://youtu.be/URVS4H7vrdU Funnily enough, the slow rendering is kind of a plot device here.

The program from that scene was not some crazy invention for the purpose of having an interesting computer scene. It is a real piece of software for silicon graphics workstations called fsn (File System Navigator). There's a x windows remake of it called fsv: https://fsv.sourceforge.net/ And then there's this even cooler UI which takes this whole idea much further called eagle mode: https://eaglemode.sourceforge.net/

psDooM pits you against processes on the system represented as enemies: https://psdoom.sourceforge.net/

Re: A Raycaster in Bash

#26
post #16
post #14

In case you wondered if there is a raycaster written in MS Batch: https://github.com/nTh0rn/batch-raycaster

That's really cool! The explanation on their blog is great!

Thanks for the hint! That's exactly what I was looking for as I have never looked into raycasting but having an interest in it.

Direct Links:

- https://nthorn.com/articles/batch_raycaster/ (batch variant)

- https://lodev.org/cgtutor/raycasting.html (general intro)

Re: A Raycaster in Bash

#27

Very cool! I'm curious when it says "did you know that accessing a random element in an array takes linear time", why that's the case, with bash?

normal arrays in bash are implemented as linked lists. bash stores a pointer to the last accessed element, which turns the most common case of iteration into O(1), but the performance is terrible if you need to jump around

see some basic benchmarks here https://gist.github.com/izabera/16a46ed79c2248349a1fb8384468...

there are also associative arrays which are bucketed hash tables, which are fine for string keys but imho they are hardly ever worth it as a replacement for indexed arrays

Re: A Raycaster in Bash

#28

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 r…

The VoxelCanvas.js file (in Javascript, obv.) might be interesting to you as well. Same (raycasting) idea:

https://github.com/EngineersNeedArt/Mooncraft2000

Re: A Raycaster in Bash

#29
post #27

Very cool! I'm curious when it says "did you know that accessing a random element in an array takes linear time", why that's the case, with bash?

normal arrays in bash are implemented as linked lists. bash stores a pointer to the last accessed element, which turns the most common case of iteration into O(1), but the performance is terrible if you need to jump around see some basic benchmarks here https://gist.github.com/izabera/16a46ed79c2248349a1fb8384468... there are also associative arrays which are bucketed hash tables, which are fine for string keys but i…

Thanks a lot, that's very interesting re. it using linked lists, and nice benchmark!
Post reply on HN