3 ms·
> a Space Invaders game > a minimal roguelike in Forth > 3-D rotating objects in ASCII art in 20 lines of Python > an RPN calculator with forward-mode automa
by trealira 2y ago
> a Space Invaders game
> a minimal roguelike in Forth
> 3-D rotating objects in ASCII art in 20 lines of Python
> an RPN calculator with forward-mode automatic differentiation
Those all sound pretty cool. Are those in the link you provided? I'd be interested in seeing how you did the 3-D rotations in only 20 lines, or what a minimal roguelike in Forth would look like.
- kragen 2y agoThanks! Two of them are there! Or, sort of, three of them. The Space Invaders game is http://canonical.org/~kragen/sw/dev3/qvaders.html http://canonical.org/~kragen/sw/dev3/qvaders.html, built on the game engine in http://canonical.org/~kragen/sw/dev3/qj2d.js http://canonical.org/~kragen/sw/dev3/qj2d.js. An earlier version without the engine, the explosions, or the Xbox support is at http://canonical.org/~kragen/sw/dev3/invaders.html http://canonical.org/~kragen/sw/dev3/invaders.html. The minimal roguelike is http://canonical.org/~kragen/sw/dev3/wmaze.fs http://canonical.org/~kragen/sw/dev3/wmaze.fs. It runs in a few different Forths (GForth is probably the easiest) but I haven't ported it to F83 yet. There's an asciicast at https://asciinema.org/a/672405 https://asciinema.org/a/672405. I'm kind of a novice at Forth, so I might not be doing things in the best way. The ASCII-art rotating cube is http://canonical.org/~kragen/sw/netbook-misc-devel/rotcube.py http://canonical.org/~kragen/sw/netbook-misc-devel/rotcube.p.... It's actually only 15 lines of Python. A longer wireframe Unicode braille version is at http://canonical.org/~kragen/sw/dev3/braillecube.py http://canonical.org/~kragen/sw/dev3/braillecube.py with an asciicast at https://asciinema.org/a/390271 https://asciinema.org/a/390271. There's also a 41-line C++ ASCII-art version at http://canonical.org/~kragen/sw/dev3/rotcube.cpp http://canonical.org/~kragen/sw/dev3/rotcube.cpp and a 42-line semi-wireframe C version using my graphics library Yeso at https://gitlab.com/kragen/bubbleos/-/blob/master/yeso/cube.c https://gitlab.com/kragen/bubbleos/-/blob/master/yeso/cube.c. The RPN calculator is at http://canonical.org/~kragen/sw/81hacks/autodiffgraph/ http://canonical.org/~kragen/sw/81hacks/autodiffgraph/.
- trealira 2y agoThanks! I upvoted you but forgot to reply. Those are as interesting as I thought they'd be.
- kragen 2y agoAwesome, I'm glad you liked them! I probably should have said in my original comment that the 3-D rotation itself was only 3 of the 15 lines: s = 0.1 # sine c = (1 - s**2)**0.5 # cosine ... cube = [(c*x + s*z, y, -s*x + c*z) for x, y, z in cube] # Rotate by theta. The rest was ASCII art, animation, perspective projection, and geometry generation.