Add 2004/schnitzi/try.sh + make it use fgets()
Format/typo check README.md file. I also slowed down the animations as well as in modern systems they go too fast, especially the Star Wars scrolling text one.
This commit is contained in:
1 parent
5d9557a126
commit
2e99bb2a20
6 files changed
+55
-31
No files matched your search
+15
-27
@@ -8,36 +8,20 @@ make
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./schnitzi
|
||||
./schnitzi <foo | vi -n
|
||||
```
|
||||
|
||||
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
./schnitzi <schnitzi.inp0 2>/dev/null| vi
|
||||
./schnitzi <schnitzi.inp1 2>/dev/null| vi
|
||||
./try.sh
|
||||
```
|
||||
|
||||
For others, create an output file and use your system
|
||||
pasteboard/selection/cut buffer to "input" the output into vi:
|
||||
|
||||
```sh
|
||||
./schnitzi <schnitzi.inp0 >schnitzi.out0
|
||||
./schnitzi <schnitzi.inp1 >schnitzi.out1
|
||||
```
|
||||
|
||||
NOTE: if you're one of those who don't know how to exit `vi` :-) don't worry as
|
||||
it will exit for you.
|
||||
|
||||
NOTE: this entry will make vi(m) swap files in the current working directory.
|
||||
You might wish to clean them up. We could say how but lest there is another file
|
||||
that matches the glob we won't. In any event vi swap files start with a dot
|
||||
followed by the file name followed by another dot followed by `s` and two more
|
||||
letters like. If no file is opened it will not have the file name but just be
|
||||
e.g. `.swp`. When a second letter has no remaining availabilities it goes to
|
||||
another one e.g. `u`.
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
@@ -64,9 +48,10 @@ string contains cursor navigation commands, you can go back and
|
||||
overwrite things that were already inserted earlier in string,
|
||||
anywhere on the screen. Can you see where this is going?
|
||||
|
||||
|
||||
### ANIMATION!
|
||||
|
||||
The program takes input from stdin which defines the animated
|
||||
The program takes input from `stdin` which defines the animated
|
||||
elements (sprites) that appear on the screen. For each sprite,
|
||||
you can specify exactly when and how long it will appear, and which
|
||||
direction it is moving. Also, the sprite can oscillate between
|
||||
@@ -75,16 +60,17 @@ Forgive me, animators, if I'm mangling the terminology. Sprites
|
||||
which appear later in the input file will be drawn in front of
|
||||
sprites which appear earlier.
|
||||
|
||||
The output, to stdout, is a string which, when pasted into vi, will
|
||||
perform the animation defined in the input. (The vi editor is a
|
||||
common (and ancient) editor that should be available on most Unix,
|
||||
Linux, Solaris, and Mac OS X machines; you can get it on Windows
|
||||
by installing Cygwin, which is how I do it.)
|
||||
The output, written to `stdout`, is a string which, when pasted into vi, will
|
||||
perform the animation defined in the input. (The vi editor is a common (and
|
||||
ancient) editor that should be available on most Unix, Linux, Solaris, and macOS
|
||||
systems; you can get it on Windows by installing Cygwin, which is how I do
|
||||
it.)
|
||||
|
||||
|
||||
### THE INPUT
|
||||
|
||||
It's easiest to place the input in a file, so you can redirect it
|
||||
to stdin when running the program. What follows is a detailed
|
||||
to `stdin` when running the program. What follows is a detailed
|
||||
description of the input file format.
|
||||
|
||||
The first line is specified thusly:
|
||||
@@ -93,12 +79,12 @@ The first line is specified thusly:
|
||||
[duration] [timefactor]
|
||||
```
|
||||
|
||||
The first parameter, duration, defines how long the animation will run. The
|
||||
The first parameter, `duration`, defines how long the animation will run. The
|
||||
second, `timefactor`, is used as sort of a fudge factor for machines that run
|
||||
too fast to see the animation. A `timefactor` of 0 means, "run the animation as
|
||||
fast as you can". On a pretty fast machine, I've had to set it as high as 2000
|
||||
to get the animation to slow down sufficiently. Note that the higher the
|
||||
`timefactor`, the longer the output string that you'll have to copy- and-paste,
|
||||
`timefactor`, the longer the output string that you'll have to copy and paste,
|
||||
as extra characters are necessary to "waste time" between frames.
|
||||
|
||||
Following the first line parameters, you may have up to nine
|
||||
@@ -139,6 +125,7 @@ Input is terminated by end of file. Duh.
|
||||
Two samples input files are included; one a nice pastoral park
|
||||
scene, the other a bit of scrolling text.
|
||||
|
||||
|
||||
### RUNNING THE ANIMATION
|
||||
|
||||
Try one of these methods to get the animation to run:
|
||||
@@ -164,6 +151,7 @@ is a right-click menu option on the top window bar.
|
||||
|
||||
3. Memorize the output, and type it into vi really really fast.
|
||||
|
||||
|
||||
### A FINAL NOTE
|
||||
|
||||
I would like to remind the Pixar Animation Studios that I retain
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#define gets(x) fgets((x),100,stdin)
|
||||
#define l "=================================================="
|
||||
#define m " "
|
||||
int _(
|
||||
@@ -6,7 +7,7 @@ float x,
|
||||
float y){
|
||||
return x>=0&&x<50&&y>=0&&y<20;}
|
||||
int main (){
|
||||
char a[2][20][51],c[9][4][51][51],d[100];
|
||||
char a[2][20][51],c[9][4][100][100],d[100];
|
||||
int e,f,g,h=0,i,j=0,k,b=0,n[9],o[9],p[9],x[9],y[9],q[9],r,s,t;
|
||||
float u[9],v[9],w[9],z[9];
|
||||
printf ("i%s\033Yppppppppppppppppppp1G0",l);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
100 1000
|
||||
100 2000
|
||||
0 1000 0 10 0.0 0.0 50 2 1
|
||||
------------------------------\~~~~~~~~~~~~~~~~~~~
|
||||
\__________________
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
30 2000
|
||||
30 10000
|
||||
0 100 10 25 0.0 -1.0 25 4 1
|
||||
A long time
|
||||
ago, in a
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 2004/schnitzi
|
||||
#
|
||||
|
||||
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
|
||||
# this way allows us to have the user specify a different compiler in an easy
|
||||
# way.
|
||||
if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
|
||||
echo "$ ./schnitzi <schnitzi.inp0 | vi -n" 1>&2
|
||||
./schnitzi <schnitzi.inp0 | vi -n
|
||||
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
echo
|
||||
|
||||
echo "$ ./schnitzi <schnitzi.inp1 | vi -n" 1>&2
|
||||
./schnitzi <schnitzi.inp1 | vi -n
|
||||
Reference in new issue
Block a user