Updates to 2001/kev
The code and alt code now have '#ifndef..#endif' blocks so that one need not specify all the -D options if they wish to change just one. In the case of SPEED if it's undefined it is set to 50 which is what the Makefile originally had it as but I changed it to 100 as it seemed to be a problem. The author does note how different speeds make for different kinds of play and so this change is even more useful. Format/typo check README.md file. This should complete the review of 2001/kev and I believe only one entry remains now.
This commit is contained in:
1 parent
a19cb214c1
commit
420e16da69
4 files changed
+112
-25
No files matched your search
+83
-21
@@ -4,6 +4,9 @@
|
|||||||
make
|
make
|
||||||
```
|
```
|
||||||
|
|
||||||
|
There is another version which lets you use the arrow keys rather than the more
|
||||||
|
awkward `,` and `.` keys. See [alternate code](#alternate-code) below.
|
||||||
|
|
||||||
|
|
||||||
### Bugs and (Mis)features:
|
### Bugs and (Mis)features:
|
||||||
|
|
||||||
@@ -26,39 +29,92 @@ For more detailed information see [2001 kev in bugs.md](/bugs.md#2001-kev).
|
|||||||
|
|
||||||
NOTE: each player's paddle is at the bottom and the opponent at the top.
|
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):
|
|
||||||
|
|
||||||
```sh
|
|
||||||
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:
|
### Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./kev\
|
./kev # in one terminal
|
||||||
./kev localhost
|
|
||||||
|
./kev localhost # in another terminal on the same host
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If you need to change the speed you can reconfigure it like (say
|
||||||
|
for over a network and not the same host):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make clobber CDEFINE="-DSPEED=50" all # original default value which is very fast
|
||||||
|
```
|
||||||
|
|
||||||
|
If you wish to change the port you can do so like:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make clobber CDEFINE="-DPORT=3773" all
|
||||||
|
```
|
||||||
|
|
||||||
|
Of course if you want a port < 1024 you'll need to be root so don't do that.
|
||||||
|
|
||||||
|
And if you know what you're doing you can redefine the call to the `socket(2)`
|
||||||
|
syscall with the `l_` macro. Of course you can do more than one at the same
|
||||||
|
time. For instance to change the speed and port:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make clobber CDEFINE="-DSPEED=512 -DPORT=3773" all
|
||||||
|
```
|
||||||
|
|
||||||
|
If you have `xterm` try on one system:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev &
|
||||||
|
```
|
||||||
|
|
||||||
|
and then the other, the client system:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev localhost&
|
||||||
|
```
|
||||||
|
|
||||||
|
This might look nicer than just the terminal itself.
|
||||||
|
|
||||||
|
|
||||||
## Alternate code:
|
## Alternate code:
|
||||||
|
|
||||||
To use:
|
This version allows you to use arrow keys on the keyboard rather than the more
|
||||||
|
awkward `,` and `.` keys to move your paddle.
|
||||||
|
|
||||||
|
|
||||||
|
### Alternate build:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make alt
|
make alt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can reconfigure the macros described above in the same way.
|
||||||
|
|
||||||
|
|
||||||
|
### Alternate use:
|
||||||
|
|
||||||
Use `kev.alt` as you would `kev`.
|
Use `kev.alt` as you would `kev`.
|
||||||
|
|
||||||
|
|
||||||
What happens if you use both, one in one terminal and the other in another
|
What happens if you use both, one in one terminal and the other in another
|
||||||
terminal?
|
terminal?
|
||||||
|
|
||||||
|
|
||||||
|
### Alternate try:
|
||||||
|
|
||||||
|
If you have `xterm` try on one system:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev.alt &
|
||||||
|
```
|
||||||
|
|
||||||
|
and then the other, the client system:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev.alt localhost&
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Judges' remarks:
|
## Judges' remarks:
|
||||||
|
|
||||||
Continuing with this year's "retro game" theme, this is another old game;
|
Continuing with this year's "retro game" theme, this is another old game;
|
||||||
@@ -72,13 +128,14 @@ box.
|
|||||||
|
|
||||||
## Author's remarks:
|
## Author's remarks:
|
||||||
|
|
||||||
|
|
||||||
**NETWORK PONG!**
|
**NETWORK PONG!**
|
||||||
|
|
||||||
### REQUIREMENTS
|
### REQUIREMENTS
|
||||||
|
|
||||||
* TCP sockets
|
* TCP sockets
|
||||||
* curses
|
* curses
|
||||||
* `usleep()`
|
* `usleep(3)`
|
||||||
|
|
||||||
### DESCRIPTION
|
### DESCRIPTION
|
||||||
|
|
||||||
@@ -89,6 +146,7 @@ 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
|
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! :)
|
getting the ball past your opponent's paddle. It's pretty fun! :)
|
||||||
|
|
||||||
|
|
||||||
### RUNNING
|
### RUNNING
|
||||||
|
|
||||||
Run the server first without any command line arguments, i.e.
|
Run the server first without any command line arguments, i.e.
|
||||||
@@ -105,8 +163,8 @@ the name of the machine running the server, e.g.
|
|||||||
```
|
```
|
||||||
|
|
||||||
Make sure that the terminals on both ends are the same size. Also, the TCP port
|
Make sure that the terminals on both ends are the same size. Also, the TCP port
|
||||||
number (5455) specified in the [Makefile](Makefile) mustn't be blocked by a
|
number (by default 5455) specified in the [Makefile](Makefile) mustn't be
|
||||||
firewall.
|
blocked by a firewall.
|
||||||
|
|
||||||
Here's a good quick example to see it in action on your own
|
Here's a good quick example to see it in action on your own
|
||||||
machine, assuming you have `Xwindows`:
|
machine, assuming you have `Xwindows`:
|
||||||
@@ -116,6 +174,7 @@ xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev &
|
|||||||
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev localhost&
|
xterm -geometry 80x40 -fg green -bg black -fn 9x15bold -e ./kev localhost&
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### PLAYING
|
### PLAYING
|
||||||
|
|
||||||
Your paddle is the one at the bottom of the screen, your opponent
|
Your paddle is the one at the bottom of the screen, your opponent
|
||||||
@@ -130,9 +189,9 @@ missed the ball.
|
|||||||
|
|
||||||
You can control the speed of the ball by the motion of your paddle
|
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
|
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
|
just bounces normally off it. If your paddle is moving in the
|
||||||
same direction as the ball, then the ball's speed in that
|
same direction as the ball, then the ball's speed in that
|
||||||
direction will increase. If your paddle is moving in the opposite
|
direction will increase. If your paddle is moving in the opposite
|
||||||
direction to the ball, then the ball's speed in that direction
|
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
|
will decrease (or if the ball is going slowly enough, it'll turn
|
||||||
around).
|
around).
|
||||||
@@ -145,12 +204,13 @@ might need to be root anyway), in `Xwindows` try `xset r rate 250
|
|||||||
can reset it later).
|
can reset it later).
|
||||||
|
|
||||||
Look below in the Building section for info on how to speed up or
|
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
|
slow down the game (useful if you increase or decrease the
|
||||||
terminal size).
|
terminal size).
|
||||||
|
|
||||||
|
|
||||||
### BUILDING
|
### BUILDING
|
||||||
|
|
||||||
Just run `make`to use the Makefile as above. The `SPEED` variable in the
|
Just run `make` to use the Makefile as above. The `SPEED` variable in the
|
||||||
Makefile controls the speed of the game (defaults to `50`). This speed is 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
|
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
|
as fast as your network can handle, and values less than 50 are useful for
|
||||||
@@ -165,7 +225,8 @@ dial-up.
|
|||||||
The TCP port to use for network communications is specified by the
|
The TCP port to use for network communications is specified by the
|
||||||
`PORT` variable in the Makefile. If the default of `5455` is
|
`PORT` variable in the Makefile. If the default of `5455` is
|
||||||
blocked for whatever reason, you can change it to something else.
|
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.
|
Of course if you use a port < 1024, you'll need to be root.
|
||||||
|
|
||||||
|
|
||||||
### OBFUSCATION
|
### OBFUSCATION
|
||||||
|
|
||||||
@@ -184,6 +245,7 @@ Finally, the number of "non-whitespace characters" (as defined by
|
|||||||
the rules) in the file is exactly 2048, which I think is rather
|
the rules) in the file is exactly 2048, which I think is rather
|
||||||
unexpectedly cool. :)
|
unexpectedly cool. :)
|
||||||
|
|
||||||
|
|
||||||
### BUGS
|
### BUGS
|
||||||
|
|
||||||
There are 3 warnings when I compile with gcc 2.95.3 (`-Wall -ansi
|
There are 3 warnings when I compile with gcc 2.95.3 (`-Wall -ansi
|
||||||
|
|||||||
@@ -5,6 +5,15 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#ifndef PORT
|
||||||
|
#define PORT 5455
|
||||||
|
#endif
|
||||||
|
#ifndef SPEED
|
||||||
|
#define SPEED 50
|
||||||
|
#endif
|
||||||
|
#ifndef l_
|
||||||
|
#define l_ socket(il.sin_family=AF_INET,SOCK_STREAM,0)
|
||||||
|
#endif
|
||||||
#define o0(M,W) mvprintw(W,M?M-1:M,"%s%s ",M?" ":"",_)
|
#define o0(M,W) mvprintw(W,M?M-1:M,"%s%s ",M?" ":"",_)
|
||||||
#define O0(M,W) M##M=(M+=W##M)-W##M
|
#define O0(M,W) M##M=(M+=W##M)-W##M
|
||||||
#define l1(M,W) M.tv_##W##sec
|
#define l1(M,W) M.tv_##W##sec
|
||||||
|
|||||||
@@ -5,6 +5,15 @@
|
|||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#ifndef PORT
|
||||||
|
#define PORT 5455
|
||||||
|
#endif
|
||||||
|
#ifndef SPEED
|
||||||
|
#define SPEED 50
|
||||||
|
#endif
|
||||||
|
#ifndef l_
|
||||||
|
#define l_ socket(il.sin_family=AF_INET,SOCK_STREAM,0)
|
||||||
|
#endif
|
||||||
#define o0(M,W) mvprintw(W,M?M-1:M,"%s%s ",M?" ":"",_)
|
#define o0(M,W) mvprintw(W,M?M-1:M,"%s%s ",M?" ":"",_)
|
||||||
#define O0(M,W) M##M=(M+=W##M)-W##M
|
#define O0(M,W) M##M=(M+=W##M)-W##M
|
||||||
#define l1(M,W) M.tv_##W##sec
|
#define l1(M,W) M.tv_##W##sec
|
||||||
|
|||||||
+11
-4
@@ -2588,11 +2588,18 @@ added to `.gitignore` by accident) but Cody restored it from the archive.
|
|||||||
|
|
||||||
## [2001/kev](2001/kev/kev.c) ([README.md](2001/kev/README.md]))
|
## [2001/kev](2001/kev/kev.c) ([README.md](2001/kev/README.md]))
|
||||||
|
|
||||||
Cody slowed down the ball just a tad as it went too fast for the speed at which
|
Cody slowed down the ball just a tad (it was already a `-D` macro that was used
|
||||||
the paddles move even when holding down the movement keys.
|
in the code) as it went too fast for the speed at which the paddles move even
|
||||||
|
when holding down the movement keys (but see below).
|
||||||
|
|
||||||
Cody also provided an alternate version which lets you use the arrow keys on
|
Cody also provided an [alternate version](2001/kev/kev.alt.c) which lets you use
|
||||||
your keyboard instead of the more awkward '`,`' and '`.`'.
|
the arrow keys on your keyboard instead of the more awkward '`,`' and '`.`'.
|
||||||
|
|
||||||
|
He updated both versions to have `#ifndef..#endif` pairs for the macros so one
|
||||||
|
can more easily configure different settings without having to specify all of
|
||||||
|
them. The speed, `SPEED`, will be set to 50 if it's not defined at the compiler
|
||||||
|
line as 50 is what it used to be set to. This way it's more to the original but
|
||||||
|
without having to sacrifice playability by running `make`.
|
||||||
|
|
||||||
|
|
||||||
## [2001/ollinger](2001/ollinger/ollinger.c) ([README.md](2001/ollinger/README.md))
|
## [2001/ollinger](2001/ollinger/ollinger.c) ([README.md](2001/ollinger/README.md))
|
||||||
|
|||||||
Reference in new issue
Block a user