play_level.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* $NetBSD: play_level.c,v 1.6 2003/08/07 09:37:37 agc Exp $ */
  2. /*
  3. * Copyright (c) 1980, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the University nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. */
  30. #include <sys/cdefs.h>
  31. #ifndef lint
  32. #if 0
  33. static char sccsid[] = "@(#)play_level.c 8.1 (Berkeley) 5/31/93";
  34. #else
  35. __RCSID("$NetBSD: play_level.c,v 1.6 2003/08/07 09:37:37 agc Exp $");
  36. #endif
  37. #endif /* not lint */
  38. # include "robots.h"
  39. /*
  40. * play_level:
  41. * Let the player play the current level
  42. */
  43. void
  44. play_level()
  45. {
  46. COORD *cp;
  47. move(My_pos.y, My_pos.x);
  48. addch(PLAYER);
  49. refresh();
  50. for (cp = Robots; cp < &Robots[MAXROBOTS]; cp++) {
  51. if (cp->y < 0)
  52. continue;
  53. move(cp->y, cp->x);
  54. addch(ROBOT);
  55. }
  56. refresh();
  57. # ifdef DEBUG
  58. standout();
  59. move(Min.y, Min.x);
  60. addch(inch());
  61. move(Max.y, Max.x);
  62. addch(inch());
  63. standend();
  64. # endif /* DEBUG */
  65. setjmp(End_move);
  66. flush_in();
  67. while (!Dead && Num_robots > 0) {
  68. move(My_pos.y, My_pos.x);
  69. if (!jumping())
  70. refresh();
  71. get_move();
  72. if (Real_time)
  73. alarm(0);
  74. if (Field[My_pos.y][My_pos.x] != 0)
  75. Dead = TRUE;
  76. if (!Dead)
  77. move_robots(FALSE);
  78. if (Was_bonus) {
  79. move(Y_PROMPT, X_PROMPT);
  80. clrtoeol();
  81. move(Y_PROMPT + 1, X_PROMPT);
  82. clrtoeol();
  83. Was_bonus = FALSE;
  84. }
  85. }
  86. /*
  87. * if the player didn't die, add on the possible bonuses
  88. */
  89. if (!Dead) {
  90. Was_bonus = FALSE;
  91. if (Level == Start_level && Start_level > 1) {
  92. move(Y_PROMPT, X_PROMPT);
  93. printw("Advance bonus: %d", S_BONUS);
  94. refresh();
  95. add_score(S_BONUS);
  96. Was_bonus = TRUE;
  97. }
  98. if (Wait_bonus != 0) {
  99. if (!Was_bonus)
  100. move(Y_PROMPT, X_PROMPT);
  101. else
  102. move(Y_PROMPT + 1, X_PROMPT);
  103. printw("Wait bonus: %d", Wait_bonus);
  104. refresh();
  105. add_score(Wait_bonus);
  106. Was_bonus = TRUE;
  107. }
  108. }
  109. }