This is a HUGE commit:
417 files changed, 874 insertions(+), 874 deletions(-)
As the IOCCC website now is https enabled I have updated the
'http://www.ioccc' to 'https://www.ioccc'.
There was also a typo in Makefiles where it said 'for VERY WELCOME' when
it should be 'are VERY WELCOME'.
Finally slashdot.org is also https enabled so references to
'http://slashdot' were changed to 'https://slashdot'.
This was done by my sgit tool (see https://github.com/xexyl/sgit)
like:
sgit -e 's,http://www.ioccc,https://www.ioccc,g' -e 's/for VERY WELCOME/are VERY WELCOME/g' -e .
but because I didn't have a list of files that should be modified I had
to be careful which files to commit as I had files that were changed but
not ready to be committed. Since I did it in steps, finding typos as I
went along, I actually ran sgit three times but to simplify the above
(and to show that it's possible to do more than one sed command) I made
it all as one. Since I did not have a list of files ahead of time I had
to determine what files to commit, first going through them like:
for j in $(for i in $(git status|grep modified|cut -d: -f2); do \
git grep 'https://www.ioccc' "$i"; done|cut -d: -f1|sort|uniq); \
do git diff "$j"; done|less -r
(I had to pipe through less because of a strange problem with the git
diff which appears to be because of a terminal problem maybe due to the
command above but it was all I could come up with in a very tired head.)
The above and
git status | grep modified:
showed that some C files had been modified which obviously should not be
done so I had to do:
git co '*c'
to undo those changes.
Finally to commit the correct files I did:
for i in $(git status|grep modified|cut -d: -f2); do \
git grep -E 'https://www.ioccc|https://slashdot|are VERY WELCOME' "$i"; \
done |cut -d: -f1|sort|uniq|xargs git commit -v
or so (with any formatting issues or typos here due to typos in the log
due to the terminal (in)sanity issue described).
Best Curses Game
Kevin Pulo
Australia
http://www.kev.pulo.com.au/
Mastodon: https://fosstodon.org/@devkev
To build:
make
To run:
./kev # in one terminal
./kev hostname # in another terminal
NOTE: each player's paddle is at the bottom and the opponent at the top.
If you need to change the speed you can reconfigure it like (say for over a network and not the same host):
make clobber SPEED=50 all # default value which is very fast
There is an alternate version which lets you use the arrow keys to control your paddle. See below Alternate code.
Try:
./kev
./kev localhost
Alternate code:
To use:
make alt
Use kev.alt as you would kev.
What happens if you use both, one in one terminal and the other in another terminal?
Judges' remarks:
Continuing with this year's "retro game" theme, this is another old game; arguably, one of the oldest. Requires a functioning network, and curses.
The graphics aren't the impressive part; the graphics and network are. How many games come out at $50 and still require you to wait for a patch to come out before you can play multiplayer? This one works out of the box.
Author's remarks:
NETWORK PONG!
REQUIREMENTS
- TCP sockets
- curses
usleep()
DESCRIPTION
This program is a two-player networked version of the eighties arcade classic,
Pong. It uses standard TCP sockets to
communicate over the net, and ncurses for display. It supports variable
terminal sizes (though both players must have the same terminal size) and game
speeds. Each player has a paddle to hit the ball, and you get points for
getting the ball past your opponent's paddle. It's pretty fun! :)
RUNNING
Run the server first without any command line arguments, i.e.
./kev
Then run the client with a single command line argument which is the name of the machine running the server, e.g.
./kev localhost
Make sure that the terminals on both ends are the same size. Also, the TCP port number (5455) specified in the Makefile mustn't be blocked by a firewall.
Here's a good quick example to see it in action on your own
machine, assuming you have Xwindows:
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev &
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev localhost&
PLAYING
Your paddle is the one at the bottom of the screen, your opponent
is at the top. To move your paddle left, hold down , (i.e. <
but don't press shift). To move your paddle right, hold down ..
To quit, either player may press q.
The current score is shown on the left side of the halfway line. Your score is the lower number, your opponents score is the upper number. Your score is the number of times your opponent has missed the ball.
You can control the speed of the ball by the motion of your paddle when the ball hits it. If your paddle is still, then the ball just bounces normally off it. If your paddle is moving in the same direction as the ball, then the ball's speed in that direction will increase. If your paddle is moving in the opposite direction to the ball, then the ball's speed in that direction will decrease (or if the ball is going slowly enough, it'll turn around).
You might want to increase your keyboard repeat rate before
playing. On the Linux console try kbdrate -r 24.0 -d 250
(kbdrate might be "hidden" from normal users in /sbin, and you
might need to be root anyway), in Xwindows try xset r rate 250 24 (find out your current rate first with xset q, so that you
can reset it later).
Look below in the Building section for info on how to speed up or slow down the game (useful if your increase or decrease the terminal size).
BUILDING
Just run maketo use the Makefile as above. The SPEED variable in the
Makefile controls the speed of the game (defaults to 50). This speed is the
delay between frames in milliseconds. Thus a value of 0 will make the game go
as fast as your network can handle, and values less than 50 are useful for
larger terminals or more exciting games. The program needs bandwidth equal to
1/s bytes per second (where s is the speed value). Any latency on the network
will be added to s - so you should probably subtract any latency from the
value of s you want to have. Given that loopback and fast Ethernet LANs are
both much less than 1ms of latency, you should only need to worry about this if
you plan on playing over a slower link like a cable modem, DSL, or (God-forbid)
dial-up.
The TCP port to use for network communications is specified by the
PORT variable in the Makefile. If the default of 5455 is
blocked for whatever reason, you can change it to something else.
Of course if you use a port < 1024, you'll need to be root.
OBFUSCATION
The program's broad structure is fairly straightforward, but individual tasks are rarely done in a straightforward manner. ;)
Identifier names have mostly been chosen to resemble paddles and balls, and to generally decrease readability.
The source has been cleverly formatted to resemble one of the paddles from the game, rotated 90 degrees. ;) (The "source paddle" has approximately the same aspect ratio as the game at 80 columns wide, which is 1:10.)
Finally, the number of "non-whitespace characters" (as defined by the rules) in the file is exactly 2048, which I think is rather unexpectedly cool. :)
BUGS
There are 3 warnings when I compile with gcc 2.95.3 (-Wall -ansi -pedantic) on my Linux system, but all are completely harmless.
I don't like the curses and/or termcaps/terminfos on IRIX and
Solaris (the only two non-Linux systems I have access to).
Despite calling timeout(0);, notimeout(win, TRUE);, nodelay(win, TRUE); and/or keypad(win, FALSE);, it still seems to force a delay
into calls to getch() - I'm guessing at a termcap/terminfo level.
At any rate, I can't seem to force no delay. This is a shame,
because it basically plays havoc with the input code, particularly
the read-ahead canceller. It still works, but not nearly as well
(key presses are dodgy and holding down keys doesn't always work),
and so I much prefer and recommend Linux libncurses.
Sometimes when q is pressed in one, the other will crash out
with Broken pipe.
If the specified port can't be bound or connected to, the program segfaults.
If your terminal is too wide (we're talking gigantic here - over 500 characters wide) then the program can segfault. It's also possible to crash the program a player scores over a billion points (1e9). Maybe you can consider that the goal... ;)
If you run the client and server on different architectures, both architectures need to have the same character systems (i.e. don't try mixing ASCII and EBCDIC). It is independent of endianness though.
Copyright and CC BY-SA 4.0 License:
This file is Copyright (c) 2023 by Landon Curt Noll. All Rights Reserved. You are free to share and adapt this file under the terms of this license:
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
For more information, see: https://creativecommons.org/licenses/by-sa/4.0/