-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpong.c
52 lines (46 loc) · 1 KB
/
pong.c
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
51
/* One player pong, based on helper code found in the book by Bruce Molay
* Understanding Unix/Linux Programming.
* date: 3/29/2017
* author: Tasuku Miura
*/
#include <stdio.h>
#include <curses.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include "alarmlib.h"
#include "ball.h"
#include "court.h"
#include "paddle.h"
#include "pongglobal.h"
#include "pongutil.h"
/*
* pong 1.0
*
* user input:
* m move paddle down, k: move paddle up
* Q quit
*
* blocks on read, but timer tick sets SIGALRM which are caught
* by ball_move
*/
struct ppball the_ball ;
struct ppcourt the_court;
struct pppaddle the_paddle;
int balls_left = 10;
time_t wall_clock = 0;
/** the main loop **/
int main()
{
int c;
void set_up();
set_up();
while ( balls_left > 0 && ( c = getch()) != 'Q' ){
if ( c == 'k' )
paddle_up();
else if ( c == 'm' )
paddle_down();
}
wrap_up();
return 0;
}