What’s more impressive, the fact that this Wolfenstein-like game is 600 lines of code, or that it’s written in AWK?
AWK is a language primarily used for text processing. But if you can write code the world bows to your wishes. [Fedor Kalugin] leverages the ability of a Linux terminal’s color options to draw his game. The 3D aspect is produced through ray-casting which generates a 2D image from 3D coordinates.
Trying out the game is extremely simple, install gawk, clone the repo, and play:
sudo apt-get install gawk git clone https://github.com/TheMozg/awk-raycaster.git cd awk-raycaster/ gawk -f awkaster.awk
We really appreciate the four different display modes which illustrate doing a lot with very little. They include: black and white text, color text, color background, and combination of color text and background. It’s an advanced texture technique with which every ansi artist is familiar.
Don’t limit yourself to playing with the script and losing interest. Crack that thing open. Try making a spinning wireframe cube based on this framework!
[via HackerNews]
Really cool – can anyone post a video for those of us who can’t easily install/run that?
https://asciinema.org/a/9ppgd3sj5lbdjx4jk14gllx7d
This is just waiting to become a legendary telnet experience!
telnet://foobar
!!
600 lines of code and 2.5d graphics, in code meant for a word processing. Now I wish I had learned to code when my brain was younger.
While very cool, it’s not really 3D, just a pseudo-3D view based on 2D raycasting. You would need to add some true 3D capabilities to make a spinning wireframe cube.
Now real 3d on a flat screen would be a wonder to behold with or without awk.
I think I am missing something in the above post.
Its called 2.5D
Call it whatever you want. There is no such thing as “2.5D”.
Perhaps not in objective reality. Although fractals are often described as having a fractional dimension.
The point is, it’s 3D-looking, but not full 3D. Raycasting produces limited results, it can’t be used for many 3D purposes, but does well for some, and is fast to render.
“2.5D” is a well-known phrase, particularly as applied to games like Wolfenstein 3D, and even Doom, which looked a lot more free and advanced than Wolfenstein, but still had very rigid limits for what you can do. Clever level design worked within the limits, to give the impression of more graphical freedom than there really was. There’s still a few tricks Doom level designers have come up with.
And you couldn’t do a 3D cube with this. Well, you could, viewed from the inside, a square room. But Wolfenstein-type engines have the floor fixed at the bottom half of the screen, ceiling at the top. A cube would require the other way round.
Yes, it’s a well known phrase. The are no fractions of dimensions in reality. Not in this universe, or any other.
@Dave except non integer dimensions which can be described as fractions.
Non-integer dimensions are not real. They are the ridiculous contrived creations of theoretical physicists.
@Dave neither is space nor time. These are merely constructs that best describe our experience of macroscopic interactions with a universe complex enough that we haven’t figured it all out yet. At this stage everything is a demodulated form of thinly spread interactions, plus gravity.
Sure, String theory is looking weaker than ten years ago, but supersymmetry has a long way to go, and n-brane models require exotic interactions to describe them.
All I mean to say is, you’re right; we don’t experience a non-integer dimension. However it is not excluded in our myriad ways of describing interactions, and the point is moot; Even if there is not 2.5th dimension, it is a term commonly used within the context of computer programming and consumer engineering to describe 3D systems where one axis (usually z) is fixed or constrained (such as the pen plotter, where z can essentially be “0” or “1”).
@Dave Non integer dimensions are very important in mathematics, they do exist as much as numbers exist.
Yes, very important in mathematics, but still not real.
Yes, important in the way that a family can have 2.2 kids. It is necessary to allow fractions in calculation, but it does not translate to a fraction of a dimension in real life.
But you can teach your 1/5 of a kid (named Stumpy) that the other 4/5ths of him is in another dimension!
@Dave
If you think the phrase “2.5D” reflects a genuine belief on the part of folks that use it that such systems model two and a half spatial dimensions you’re an idiot. It’s a tongue-in-cheek figure of speech intended to describe games that simulate 3D but aren’t actually. Jesus christ.
Yes, I understand, it’s just an expression.
Thats a matter of perspective what you consider 3d. You could have a 3d spinning cube with no perspective.. but raycasting does have perspective… both have something missing which is more 3d? All 3d on a computer ends up being projected back to 2d.
Doom had “perspective correction”, Wolfenstein didn’t. If you spin on the spot in Wolfenstein 3D, you notice a sort of weird circular or sinusoidal quality to the rendering, that modern games don’t have.
Of course all computer screens (well, most) are 2D, but you can still model 3D objects in the computer. But Wolfenstein doesn’t, it’s a hack. A very clever hack. Doom was even more convoluted, and more clever. John Carmack is a very rare talent. Until Doom came along, nothing like it existed on ordinary computers. After, when people had a bit of time to figure out most of what he was doing, there were loads.
FPSes used to be called “Doom clones”, in the good old 486 days. Also the Internet was better.
I can make a cube spin on the screen with perspective, but you cannot walk around it or look up and down because I didn’t code it that way. Is the cube more 3d than the walls of a raycaster that I can walk around. The raycaster world is defined in 2d with x,z and a fixed y height. With the correct rendering and maths it is as legitimately 3d as my cube. I could create a 3d engine with polygons and define the world in 2d with a fixed height…. would this be 3d?
If you liked this post you may also enjoy Bisqwit’s coding/demo video on how to create a Doom-style 3D engine in C (and some BASIC early on)
https://www.youtube.com/watch?v=HQYsFshbkYw
You can even strafe! Very nice.
I died without figuring out what the elevator looked like…
Me too. But then I spent more time looking at the code than playing the product of it.
That looks pretty much like 3D Dragon Monster Maze 16K from the ZX81
This is so much cheaper than an injection-capable card. Is is possible to use ESP as a generic Linux adapter, and then add support to airmon-ng?
Did you check out what can be done in 256 bytes, not lines?
https://www.youtube.com/watch?v=Z8Av7Sc7yGY
https://www.youtube.com/watch?v=R35UuntQQF8
https://www.youtube.com/watch?v=Sbq2HzXEcN4
Interesting, the system ate half of my comment.
Just wanted to say that the article reminded me of 256 byte intros – so above for examples.
Yeah but if i remember right they were abusing graphic card driver example modes
What? Small intros are coded in assembly for running on MS-DOS, using Windows and/or Linux executables wastes too many bytes to be useful. And in MS-DOS there aren’t any graphics drivers to abuse.
For larger intros the overheads of a real operating system can be worked around, e.g. one can use compression and run part of the code on a GPU (which can be made compact). Even then there isn’t any abuse though.
Perhaps he meant abusing the VGA registers, lots of demos do stuff like that, creating modes that weren’t ever supposed to exist in a rational universe.
They don’t do even that. There’s no space for it. :)
Besides mode 13h provides 320×200 256 color linear framebuffer and can be initialized in 5 bytes (mov ax, 0x13 ; int 0x10) which is pretty ideal for a tiny intro. No double-buffering and non-square pixels but those aren’t a huge problem. To make a 320×240 intro requires a lot of extra bytes (don’t know exactly but there are a number of VGA registers that need tweaking + that the drawing code will be much more complicated and slower), even doing a 320×200 buffer centered in a 320×240 mode requires a bit of coding.
Old-school to-the-metal demos for PC hardware is pretty uncommon nowadays sadly, partly because tweaked modes etc. often requires old computers to work correctly. But emulators are improving I’m told so maybe someday there will be a revival. :)
Not all demos are stuck with 256 bytes, or 4K, or whatever. Lots of demos do weird things with VGA. Mode X, a planar mode, also has advantages that, if you mess with the planes properly, you can blast pixels a lot faster.
Also… back in the bad old days, graphics cards had VESA drivers for MS-DOS. Any game that wanted better than standard VGA used them. Usually they were in the card’s ROM, but sometimes you had to load a VESA extender. Dr Something or other was a popular one.
Nowadays 256 byte demos DO run on Windows and feed Direct3d (usually). The size of the OS, DirectX, etc. don’t count in the competition, just your .exe size. How much code do YOU need to import the DLL and bang the specific functions?
it’s not really fair to say xx bytes without mentioning the platform, but I assume it’s pure x86.
if we can use hardware acceleration by the GPU, you can eat your 256 bytes.
check what some of these GLSL Shaders can do in just a couple lines of code.
http://glslsandbox.com/
Yes but to qualify as a demo/intro they have to be executable. So there are overheads to initialize the graphics etc. before one can use the shader routines.
Reminds me of .kkrieger
The story about their routine for removing unused code is one of my favorite “misadventures in game development” stories. They were running up against the deadline and their file size was still too large. They had to remove some code, but finding and removing unused code manually was going too slowly. So they wrote this routine that runs alongside the game as it’s played. If the player forgot to jump, guess what: the resulting build wouldn’t support jumping.
Can’t seem to find the article where I read about this, but here’s some stories along similar lines from various dev studios: http://www.gamasutra.com/view/feature/132500/dirty_coding_tricks.php?page=1
Wonderful use of AWK! :-)
Here is 1bir (1 Block Interactive Raycaster) that runs on Commodore 64 in 340 lines of 6502 Assembly:
http://www.pouet.net/prod.php?which=61298
Here is an interactive raycaster in 128 bytes http://www.pouet.net/prod.php?which=63518 It runs on any pc with x86 processor (does not require DOS or any software dependencies/GPU/OS). In essence one could run it in a bootsector. It has been analysed here http://finalpatch.blogspot.fr/2014/06/dissecting-128-byte-raycaster.html
If you have gawk and curl already installed (I don’t know a single Linux distribution that doesn’t have these) you can just run the following:
gawk -f <(curl https://raw.githubusercontent.com/TheMozg/awk-raycaster/master/awkaster.awk)
No need to git clone.
Reminds me of when AALib came out, about 15 years ago. A very quick bitmap to ASCII art convertor. People ported Doom to it, as well as video players etc. Never got a chance to use it on a serial terminal, wonder what sort of frame rate you’d get at 115,200 bps? 11.5, I suppose.
You’d think people would be selling old Wyse terminals and the like for peanuts, but where the demand still exists, people will pay a good price when an old system relies on them. The rest, I suppose, end up in bits in Asia and Africa somewhere. Shame, I’d really like one, used to have loads of fun programming the old Unix mini in college, with Wyse 60s, wrote Space Invaders and a great multi-player shooting fest, 8-player games would last about a minute!
probably 5fps (24×80 = ~2KB) if terminal receives pure ascii and no color
AAlib is a poor hack
for something clever watch 8088 Corruption Explained:
https://www.youtube.com/watch?v=L6CkYou6hYU
https://www.youtube.com/watch?v=H1p1im_2uf4
Back in the day, I used this technique on the Atari 800 to produce nearly 1,000 simultaneous on-screen colors, even though its DAC was only capable of 256. Only for static images though. Way cool seeing it used for FMV.
Nice work and really unusual use for AWK. Monsters could use some touch up.
jolla had only gawk 3.1.5 so needed to build newer version.
http://imgur.com/gallery/fB3PPV3
nice!
Googling “Jolla” and pretty sure I want one…
Someone could correct me if i’m wrong, but I’m fairly sure the wireframe cube (and wireframe in general) is done through ray tracing, where as this is ray casting. The two methods are the inverse of each other.
Nah, wireframe is done by simply drawing lines between points. You keep the 3D points in memory, do a bit of conversion with SIN and the like, to turn them into 2D points, then just draw the lines. Ray tracing is infinitely more complicated.
For ray tracing, you do the inverse of what light does. You start off at a pixel on the screen. You draw an imaginary ray through that pixel, from the imaginary camera, and you note what the ray passes through on it’s way. Which objects, and how transparent they are. You add up all the affects each object has on the ray, and the end result tells you what colour it ends up as. So you make that pixel that colour. Then on to the next pixel…
Raycasting is a reduced version of ray tracing. You start off casting a ray, and the first object it hits, you stop and render that colour. Quicker!
BULLSHIT. You want to see PROPER coding? See how a full 3D engine AND most of a level (textures and all) fits is FOUR KILOBYTES: https://www.youtube.com/watch?v=G1Q9LtnnE4w -THAT- is what today’s hopefuls should learn, not that lame Raspberry Pi shit.
Pffft! 4Kb intros have come a long way since 1997…
https://www.youtube.com/watch?v=_YWMGuh15nE
6 years ago . :)
I like the way they did the map. You could do the same in any language. Since you need collision and bounds there is no good procedural method.
Few Notes:
* drawEndX might cause a buffer overflow
* edit line 173 for a better weapon
64 bytes Raycasting http://www.pouet.net/prod.php?which=62445 https://www.youtube.com/watch?v=ygtuB-L88rQ&feature=youtu.be
Hi,
I did mine in python.
https://github.com/daedalus/3Dto2DRayCaster/blob/master/raycaster.py
Neither the author nor the code says anything about GNU/Linux. While most media is ignorant of the difference between Linux, which is a kernel, and GNU, which is all the tools of an entire OS, Hackaday shouldn’t be. Sure, it’s picking nits, but I’m sure the GNU world is tired of everyone calling their work “Linux”.
It runs without issue on my OSX system.
awk’ward. Reminds me one Spectrum game…