TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A Raycaster in Bash

249 点作者 izabera5 个月前

17 条评论

purplesyringa5 个月前
I <i>love</i> this. I&#x27;ve been wondering how the picture is drawn with less than one `echo` per pixel, and it&#x27;s very clever: the game is &quot;not really&quot; 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 &quot;draw this pixel and move down by one&quot; string to the terminal as many times as necessary using string repetition.<p>I&#x27;ve been considering working on a voxel render engine (not for Bash, but for another computationally limited environment). This is a treasure, I&#x27;m certain I&#x27;ll find something useful here.
评论 #42480026 未加载
tdeck5 个月前
In case you wondered if there is a raycaster written in MS Batch:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;nTh0rn&#x2F;batch-raycaster">https:&#x2F;&#x2F;github.com&#x2F;nTh0rn&#x2F;batch-raycaster</a>
评论 #42477853 未加载
Arch-TK5 个月前
It&#x27;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.
alsetmusic5 个月前
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.
einpoklum5 个月前
And to think, that my own bash scripts spend 300 lines just parsing various command-line options, while instead I could be showing this game... :-P
8n4vidtmkvmk5 个月前
I never ceases to baffle me how we&#x27;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.
评论 #42478262 未加载
markeroon5 个月前
Only 300 lines of code, impressive! I love this.
1vuio0pswjnm75 个月前
&quot;bash is slow.&quot;<p>That&#x27;s in part why I do not use it for scripting. I do not use it for interactive use either.<p>Some popular Linux distributions also avoid bash as a scripting shell.
Teongot5 个月前
I&#x27;d love to see this combined with the author&#x27;s fork()-less implementation of ps to make a (almost) fork()-free implementation of psDoom.<p>Seriously though, this is really cool
mmh00005 个月前
Of course, we need to give an honorable mention to the `awk` raycaster from 9 years ago.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;TheMozg&#x2F;awk-raycaster&#x2F;tree&#x2F;master">https:&#x2F;&#x2F;github.com&#x2F;TheMozg&#x2F;awk-raycaster&#x2F;tree&#x2F;master</a>
评论 #42481165 未加载
shric5 个月前
Beautiful. Correct me if I&#x27;m wrong, but this looks like a bash version of <a href="https:&#x2F;&#x2F;lodev.org&#x2F;cgtutor&#x2F;raycasting.html" rel="nofollow">https:&#x2F;&#x2F;lodev.org&#x2F;cgtutor&#x2F;raycasting.html</a><p>Edit: ah, just noticed this is in the readme :(
评论 #42478948 未加载
评论 #42476571 未加载
anfractuosity5 个月前
Very cool! I&#x27;m curious when it says &quot;did you know that accessing a random element in an array takes linear time&quot;, why that&#x27;s the case, with bash?
评论 #42479861 未加载
armSixtyFour5 个月前
Sadly I can&#x27;t get this working. It just throws up the view into a file called buffered for whatever reason and exits immediately :(
评论 #42481777 未加载
mlconnor5 个月前
Wow, that’s an insane challenge. I can’t believe that’s even possible.
CaesarA5 个月前
I wonder if texture mapping this would look good.
评论 #42476741 未加载
corytheboyd5 个月前
Imagine a TUI where you need to navigate a literal maze of options
评论 #42476745 未加载
评论 #42478515 未加载
评论 #42476777 未加载
ormaaj5 个月前
&lt;3