* Copyright (c) 1983 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)fly.c 5.3 (Berkeley) %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
);