* Copyright (c) 1980 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
[] = "@(#)move.c 5.3 (Berkeley) 6/18/88";
* Get and execute a move from the player
register int y
, x
, lastmove
;
if (Next_move
>= Move_list
)
lastmove
= -1; /* flag for "first time in" */
if (Teleport
&& must_telep())
else if (Num_robots
> 1 && Stand_still
)
else if (Num_robots
> 1 && Pattern_roll
) {
if (*++Next_move
== '\0') {
while (isdigit(c
= getchar()))
Count
= Count
* 10 + (c
- '0');
case 'Y': case 'U': case 'H': case 'J':
case 'K': case 'L': case 'B': case 'N':
if (query("Really quit?"))
mvaddch(My_pos
.y
, My_pos
.x
, ' ');
mvaddch(My_pos
.y
, My_pos
.x
, PLAYER
);
* Must I teleport; i.e., is there anywhere I can move without
if (Stand_still
&& Num_robots
> 1 && eaten(&My_pos
))
for (y
= -1; y
<= 1; y
++) {
if (newpos
.y
<= 0 || newpos
.y
>= Y_FIELDSIZE
)
for (x
= -1; x
<= 1; x
++) {
if (newpos
.x
<= 0 || newpos
.x
>= X_FIELDSIZE
)
if (Field
[newpos
.y
][newpos
.x
] > 0)
newpos
.y
= My_pos
.y
+ dy
;
newpos
.x
= My_pos
.x
+ dx
;
if (newpos
.y
<= 0 || newpos
.y
>= Y_FIELDSIZE
||
newpos
.x
<= 0 || newpos
.x
>= X_FIELDSIZE
||
Field
[newpos
.y
][newpos
.x
] > 0 || eaten(&newpos
)) {
move(My_pos
.y
, My_pos
.x
);
else if (dy
== 0 && dx
== 0)
mvaddch(My_pos
.y
, My_pos
.x
, ' ');
mvaddch(My_pos
.y
, My_pos
.x
, PLAYER
);
* Player would get eaten at this place
for (y
= pos
->y
- 1; y
<= pos
->y
+ 1; y
++) {
if (y
<= 0 || y
>= Y_FIELDSIZE
)
for (x
= pos
->x
- 1; x
<= pos
->x
+ 1; x
++) {
if (x
<= 0 || x
>= X_FIELDSIZE
)
* Reset the count variables
* See if we are jumping, i.e., we should not refresh.
return (Jump
&& (Count
|| Running
|| Waiting
));