* Copyright (c) 1983 Regents of the University of California,
* All rights reserved. Redistribution permitted subject to
* the terms of the Berkeley Software License Agreement.
static char sccsid
[] = "@(#)fly.c 1.3 %G%";
#define abs(a) ((a) < 0 ? -(a) : (a))
#define MIDR (LINES/2 - 1)
#define MIDC (COLS/2 - 1)
int clock
= 120; /* time for all the flights in the game */
puts("Whoops! No more memory...");
oldsig
= signal(SIGINT
, succumb
);
column
= rnd(COLS
-2) + 1;
if (row
== MIDR
&& column
- MIDC
< 2 && MIDC
- column
< 2){
mvaddstr(0,0,"*** Out of torpedoes. ***");
mvaddstr(0,26,"Commands = r,R,l,L,u,U,d,D,f,+,q");
mvaddstr(LINES
-1-1,21,"TORPEDOES FUEL TIME");
addstr("------- + -------");
for (n
= MIDR
-4; n
< MIDR
-1; n
++){
for (n
= MIDR
-4; n
< MIDR
-1; n
++){
for(n
= LINES
-1-2; n
>= MIDR
+ 1; n
--){
mvaddch(n
, MIDC
+MIDR
-n
, '/');
mvaddch(n
, MIDC
-MIDR
+n
, '\\');
for(n
= LINES
-1-2; n
>= MIDR
+ 1; n
--){
mvaddch(n
, MIDC
+MIDR
-n
, ' ');
mvaddch(n
, MIDC
-MIDR
+n
, ' ');
if (row
+ dr
<= LINES
-3 && row
+ dr
> 0)
if (column
+ dc
< COLS
-1 && column
+ dc
> 0)
mvaddstr(0,60,"*** Out of fuel ***");
d
= (double) ((row
- MIDR
)*(row
- MIDR
) + (column
- MIDC
)*(column
- MIDC
));
row
+= (rnd(9) - 4) % (4 - abs(row
- MIDR
));
column
+= (rnd(9) - 4) % (4 - abs(column
- MIDC
));
mvaddstr(oldr
, oldc
- 1, " ");
mvaddstr(row
, column
- 1, "/-\\");
signal(SIGALRM
, moveenemy
);
signal(SIGALRM
, SIG_DFL
);
mvcur(0,COLS
-1,LINES
-1,0);
signal(SIGTSTP
, SIG_DFL
);