xref: /csrg-svn/games/robots/play_level.c (revision 33690)
121470Smckusick /*
221470Smckusick  * Copyright (c) 1980 Regents of the University of California.
3*33690Sbostic  * All rights reserved.
4*33690Sbostic  *
5*33690Sbostic  * Redistribution and use in source and binary forms are permitted
6*33690Sbostic  * provided that this notice is preserved and that due credit is given
7*33690Sbostic  * to the University of California at Berkeley. The name of the University
8*33690Sbostic  * may not be used to endorse or promote products derived from this
9*33690Sbostic  * software without specific prior written permission. This software
10*33690Sbostic  * is provided ``as is'' without express or implied warranty.
1121470Smckusick  */
1221470Smckusick 
1321470Smckusick #ifndef lint
14*33690Sbostic static char sccsid[] = "@(#)play_level.c	5.3 (Berkeley) 03/09/88";
15*33690Sbostic #endif /* not lint */
1621470Smckusick 
1721470Smckusick # include	"robots.h"
1821470Smckusick 
1921470Smckusick /*
2021470Smckusick  * play_level:
2121470Smckusick  *	Let the player play the current level
2221470Smckusick  */
2321470Smckusick play_level()
2421470Smckusick {
2521470Smckusick 	register COORD	*cp;
2621470Smckusick 	register int	y, x, bonus;
2721470Smckusick 
2821470Smckusick 	move(My_pos.y, My_pos.x);
2921470Smckusick 	addch(PLAYER);
3021470Smckusick 	refresh();
3121470Smckusick 	for (cp = Robots; cp < &Robots[MAXROBOTS]; cp++) {
3225019Smckusick 		if (cp->y < 0)
3325019Smckusick 			continue;
3421470Smckusick 		move(cp->y, cp->x);
3521470Smckusick 		addch(ROBOT);
3621470Smckusick 	}
3721470Smckusick 	refresh();
3821470Smckusick # ifdef DEBUG
3921470Smckusick 	standout();
4021470Smckusick 	move(Min.y, Min.x);
4121470Smckusick 	addch(inch());
4221470Smckusick 	move(Max.y, Max.x);
4321470Smckusick 	addch(inch());
4421470Smckusick 	standend();
4521470Smckusick # endif DEBUG
4621470Smckusick 	setjmp(End_move);
4721470Smckusick 	flush_in();
4821470Smckusick 	while (!Dead && Num_robots > 0) {
4921470Smckusick 		move(My_pos.y, My_pos.x);
5021470Smckusick 		if (!jumping())
5121470Smckusick 			refresh();
5221470Smckusick 		get_move();
5321470Smckusick 		if (Real_time)
5421470Smckusick 			alarm(0);
5521470Smckusick 		if (Field[My_pos.y][My_pos.x] != 0)
5621470Smckusick 			Dead = TRUE;
5721470Smckusick 		if (!Dead)
5821470Smckusick 			move_robots(FALSE);
5921470Smckusick 		if (Was_bonus) {
6021470Smckusick 			move(Y_PROMPT, X_PROMPT);
6121470Smckusick 			clrtoeol();
6221470Smckusick 			move(Y_PROMPT + 1, X_PROMPT);
6321470Smckusick 			clrtoeol();
6421470Smckusick 			Was_bonus = FALSE;
6521470Smckusick 		}
6621470Smckusick 	}
6721470Smckusick 
6821470Smckusick 	/*
6921470Smckusick 	 * if the player didn't die, add on the possible bonuses
7021470Smckusick 	 */
7121470Smckusick 
7221470Smckusick 	if (!Dead) {
7321470Smckusick 		Was_bonus = FALSE;
7421470Smckusick 
7521470Smckusick 		if (Level == Start_level && Start_level > 1) {
7621470Smckusick 			move(Y_PROMPT, X_PROMPT);
7721470Smckusick 			printw("Advance bonus: %d", S_BONUS);
7821470Smckusick 			refresh();
7921470Smckusick 			add_score(S_BONUS);
8021470Smckusick 			Was_bonus = TRUE;
8121470Smckusick 		}
8221470Smckusick 
8321470Smckusick 		if (Wait_bonus != 0) {
8421470Smckusick 			if (!Was_bonus)
8521470Smckusick 				move(Y_PROMPT, X_PROMPT);
8621470Smckusick 			else
8721470Smckusick 				move(Y_PROMPT + 1, X_PROMPT);
8821470Smckusick 			printw("Wait bonus: %d", Wait_bonus);
8921470Smckusick 			refresh();
9021470Smckusick 			add_score(Wait_bonus);
9121470Smckusick 			Was_bonus = TRUE;
9221470Smckusick 		}
9321470Smckusick 	}
9421470Smckusick }
95