Format fix 2011/eastman/README.md
I also noted to use reset to restore the terminal after use. Also - since the author noted they tested Mac OS X 10.7 - I tested it with macOS Ventura (with M1 chip). Seemed useful to note that information since a lot has changed since those days.
This commit is contained in:
1 parent
e4d427a194
commit
2b3a16f3b9
1 file changed
+33
-22
+33
-22
@@ -1,7 +1,7 @@
|
||||
# Best ball
|
||||
|
||||
Peter Eastman
|
||||
<peter.eastman@gmail.com>
|
||||
Peter Eastman
|
||||
<peter.eastman@gmail.com>
|
||||
|
||||
## To build:
|
||||
|
||||
@@ -23,6 +23,16 @@ Quit the program. Resize your terminal window. Run it again.
|
||||
./eastman
|
||||
```
|
||||
|
||||
NOTE: to restore your cursor in your shell, try `reset`.
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) tested this with
|
||||
[macOS Ventura](https://www.apple.com/macos/ventura/) with the M1 chip for
|
||||
the author (who tested [OS X 10.7
|
||||
(Lion)](https://en.wikipedia.org/wiki/OS_X_Lion) and [fedora
|
||||
10](https://fedoraproject.org/wiki/Releases/10/FeatureList)) and reported that
|
||||
it works fine.
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
This round program will generate a classic spherical result!
|
||||
@@ -34,20 +44,21 @@ You might also want to turn off any scrollback history. The program will
|
||||
size itself to the initial geometry of your terminal.
|
||||
|
||||
If you are ambitious, make the font really small and the window really
|
||||
large for hi-rez graphics!
|
||||
large for hi-res graphics!
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
This program uses ANSI graphics to recreate the classic Boing Ball demo from
|
||||
the Commodore Amiga. See http://www.youtube.com/watch?v=-ga41edXw3A if you
|
||||
the Commodore Amiga. See <https://www.youtube.com/watch?v=-ga41edXw3A> if you
|
||||
aren't familiar with it. Back in its day, this demo inspired lust and awe in
|
||||
geeks around the world.
|
||||
|
||||
The graphics are raytraced, with procedural textures on the ball and the back
|
||||
wall. I did cheat a little to simplify the calculations: it uses a parallel
|
||||
projection, but textures the back wall to look as if there were a floor being
|
||||
viewed in perspective. The shadow is also just part of the texture, not an
|
||||
actual raytraced shadow.
|
||||
The graphics are
|
||||
[raytraced](https://en.wikipedia.org/wiki/Ray_tracing_(graphics), with
|
||||
procedural textures on the ball and the back wall. I did cheat a little to
|
||||
simplify the calculations: it uses a parallel projection, but textures the back
|
||||
wall to look as if there were a floor being viewed in perspective. The shadow
|
||||
is also just part of the texture, not an actual raytraced shadow.
|
||||
|
||||
This program automatically adapts to the size of the terminal it is running in,
|
||||
so try enlarging the window to get higher resolution. Don't resize while the
|
||||
@@ -59,12 +70,12 @@ To compile:
|
||||
cc -lm eastman.c
|
||||
```
|
||||
|
||||
Portability:
|
||||
### Portability
|
||||
|
||||
It should be completely portable. I've tested with gcc on Mac OS X 10.7 and
|
||||
Fedora 10. I would expect it to work in any Unix-like environment.
|
||||
It should be completely portable. I've tested with gcc on Mac OS X 10.7 (Lion)
|
||||
and Fedora 10. I would expect it to work in any Unix-like environment.
|
||||
|
||||
Obfuscation:
|
||||
### Obfuscation
|
||||
|
||||
I have merged expressions wherever possible, making extensive use of ternary
|
||||
operators, commas, return values of assignment operators, etc. The entire
|
||||
@@ -73,22 +84,22 @@ evaluations, is a single expression involving 41 operators.
|
||||
|
||||
Variables are named alphabetically in the order they are declared.
|
||||
|
||||
The third argument to ioctl() should really be a "struct winsize", and I should
|
||||
then look up the ws_row and ws_col fields, but that makes it way too obvious
|
||||
what I'm doing there. Since a winsize just contains four unsigned shorts, I
|
||||
The third argument to `ioctl()` should really be a `struct winsize`, and I should
|
||||
then look up the `ws_row` and `ws_col` fields, but that makes it way too obvious
|
||||
what I'm doing there. Since a `struct winsize` just contains four unsigned shorts, I
|
||||
replaced it with an array. And since all the values will be much less than
|
||||
32767, I further simplified the type to just short[].
|
||||
`32767`, I further simplified the type to just `short[]`.
|
||||
|
||||
A wonderful thing about ANSI graphics is that it produces nearly unintelligible
|
||||
code. Consider the printf spec to print a single space in a desired color:
|
||||
"\x1B[%dm ". I could have done something to further obfuscate it, but it's
|
||||
`"\x1B[%dm `. I could have done something to further obfuscate it, but it's
|
||||
already indistinguishable from line noise, so why bother?
|
||||
|
||||
There are lots of other minor obfuscations to make the code less obvious. For
|
||||
example, I could have written the outer loop as while(1), but why write a 1
|
||||
when I can calculate it from the return value of usleep() instead? And I could
|
||||
have written usleep(80000), but usleep(79383) just looks so much better. And
|
||||
so on.
|
||||
example, I could have written the outer loop as `while(1)`, but why write a 1
|
||||
when I can calculate it from the return value of `usleep()` instead? And I could
|
||||
have written `usleep(80000)`, but `usleep(79383)` just looks so much better.
|
||||
And so on.
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
|
||||
Reference in new issue
Block a user