1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 */ 12 13 #ifndef lint 14 static char sccsid[] = "@(#)play_level.c 5.3 (Berkeley) 03/09/88"; 15 #endif /* not lint */ 16 17 # include "robots.h" 18 19 /* 20 * play_level: 21 * Let the player play the current level 22 */ 23 play_level() 24 { 25 register COORD *cp; 26 register int y, x, bonus; 27 28 move(My_pos.y, My_pos.x); 29 addch(PLAYER); 30 refresh(); 31 for (cp = Robots; cp < &Robots[MAXROBOTS]; cp++) { 32 if (cp->y < 0) 33 continue; 34 move(cp->y, cp->x); 35 addch(ROBOT); 36 } 37 refresh(); 38 # ifdef DEBUG 39 standout(); 40 move(Min.y, Min.x); 41 addch(inch()); 42 move(Max.y, Max.x); 43 addch(inch()); 44 standend(); 45 # endif DEBUG 46 setjmp(End_move); 47 flush_in(); 48 while (!Dead && Num_robots > 0) { 49 move(My_pos.y, My_pos.x); 50 if (!jumping()) 51 refresh(); 52 get_move(); 53 if (Real_time) 54 alarm(0); 55 if (Field[My_pos.y][My_pos.x] != 0) 56 Dead = TRUE; 57 if (!Dead) 58 move_robots(FALSE); 59 if (Was_bonus) { 60 move(Y_PROMPT, X_PROMPT); 61 clrtoeol(); 62 move(Y_PROMPT + 1, X_PROMPT); 63 clrtoeol(); 64 Was_bonus = FALSE; 65 } 66 } 67 68 /* 69 * if the player didn't die, add on the possible bonuses 70 */ 71 72 if (!Dead) { 73 Was_bonus = FALSE; 74 75 if (Level == Start_level && Start_level > 1) { 76 move(Y_PROMPT, X_PROMPT); 77 printw("Advance bonus: %d", S_BONUS); 78 refresh(); 79 add_score(S_BONUS); 80 Was_bonus = TRUE; 81 } 82 83 if (Wait_bonus != 0) { 84 if (!Was_bonus) 85 move(Y_PROMPT, X_PROMPT); 86 else 87 move(Y_PROMPT + 1, X_PROMPT); 88 printw("Wait bonus: %d", Wait_bonus); 89 refresh(); 90 add_score(Wait_bonus); 91 Was_bonus = TRUE; 92 } 93 } 94 } 95