* Copyright (c) 1980 Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)move.c 5.4 (Berkeley) %G%";
* 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
));