Esempio n. 1
0
void
NewScoreCard()
{
	register RatIndexType	ratIndex(0);

	for( ratIndex = 0; ratIndex < MAX_RATS; ratIndex = RatIndexType(ratIndex.value() +1))
		UpdateScoreCard(ratIndex);
}
Esempio n. 2
0
static short RandomEvent(void) {
bool visible = FALSE;
register RatIndexType ratIndex(0);
int choice;

choice = random() % 4;

if ((choice == 0) || M->peeking()) {
for (ratIndex = RatIndexType(0); ratIndex.value() < MAX_RATS; ratIndex =
    RatIndexType(ratIndex.value() + 1)) {
  if ((ratIndex != MY_RAT_INDEX)
      && (Rats2Display[ratIndex.value()].visible == TRUE)) {
    visible = TRUE;
    break;
  }
}
}

if (TheNextEvent > 0) {
TheNextEvent = -TheNextEvent;
return (EVENT_D);
} else if (TheNextEvent < 0) {
M->dirIs(Direction(-TheNextEvent));
TheNextEvent = 0;
return (EVENT_MIDDLE_D);
} else if ((M->peeking()) && (visible == TRUE)) { /* Cheat */
TheNextEvent = M->dirPeek().value();
return (EVENT_LEFT_U);
} else if ((M->peeking()) && (choice != 2)) {
return (EVENT_LEFT_U);
} else if (visible == TRUE) {
return (EVENT_MIDDLE_D);
} else if (emptyAhead() && choice != 2) {
return (EVENT_D);
} else if (emptyRight()) {
return (EVENT_F);
} else if (emptyLeft()) {
return (EVENT_S);
} else if ((choice != 2) && (emptyBehind())) {
return (EVENT_A);
} else {
return (4 + (random() % 4));
} /* Never about face unless blocked */
}
Esempio n. 3
0
void
ShowAllPositions()
{
	RatIndexType	ratIndex(0);

	for (ratIndex = 0; ratIndex < MAX_RATS; ratIndex = RatIndexType(ratIndex.value() + 1)) {
		if (ratIndex == MY_RAT_INDEX)
			continue;
		else if (M->rat(ratIndex).playing)
			clearPosition(ratIndex, M->rat(ratIndex).x, M->rat(ratIndex).y);

	}
}
Esempio n. 4
0
void
ShowView(Loc x, Loc y, Direction dir)
{
	register XYpair		*tp = viewTable;
	register int		tx = x.value();
	register int		ty = y.value();
	RatIndexType			ratIndex(0);
	RatLook			ratLook;
	bool			oldVisible;

	ClearView();
	prevEdge3 = prevEdge7 = FALSE;
	while (!M->maze_[tx][ty]) {
		tp = hidden(tx, ty, dir, tp);	/* draw a cell */
		switch (dir.value()) {
		case NORTH:	tx++; break;
		case SOUTH:	tx--; break;
		case EAST:	ty++; break;
		case WEST:	ty--; break;
		}
	}
	if (prevEdge3)
		(void) plotLine(edge3Lines, TRUE);
	if (prevEdge7)
		(void) plotLine(edge7Lines, TRUE);

	/* show the tokens */

	for (ratIndex = 0; ratIndex < MAX_RATS; ratIndex = RatIndexType(ratIndex.value() + 1)) {
		if (ratIndex == MY_RAT_INDEX)
			continue;
		ratLook = &Rats2Display[ratIndex.value()];
		oldVisible = ratLook->visible;
		TokenVisible(ratIndex);
		if (ratLook->visible == TRUE)
			XORToken(ratIndex);
		if (ratLook->visible != oldVisible)
			UpdateScoreCard(ratIndex);
	}
}