~aleteoryx/9c

ref: 73f196770a756c4286371668ddd4c31ab8c92d92 9c/pong.c -rw-r--r-- 606 bytes
73f19677 — glenda readme a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <u.h>
#include <libc.h>

int score1, score2;

void
usage(void)
{
	fprint(2,"usage: %s [-p points]\n", argv0);
	exits("usage");	
}

void
do_round(void)
{
	
}

void
main(int argc, char* argv[])
{
	int playto = 10;

	ARGBEGIN{
	case 'p':
		playto = atoi(EARGF(usage()));
		if (playto == 0)
			usage();
		break;
	default:
		usage();
		break;
	} ARGEND
	
	if (argv[0])
		usage();
	
	print("playing to %d points\n", playto);
	
	score1 = 0;
	score2 = 0;
	
	while (score1 < playto && score2 < playto)
		do_round();
	
	if (score1 > score2)
		print("Player 1 wins!\n");
	else
		print("Player 2 wins!\n");
}