home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / games / volume6 / sun-tetris2 / notify.c < prev    next >
C/C++ Source or Header  |  1989-07-06  |  4KB  |  142 lines

  1. #include "defs.h"
  2.  
  3. Notify_value
  4. drop_block(me, which)
  5.         Notify_client me;
  6.         int     which;
  7. {
  8.  
  9.         if (block_can_drop(shape_no, xpos, ypos, rot))
  10.                 print_shape(shape_no, xpos, ypos++, rot, WHITE);
  11.         else {
  12.                 if (ypos < 0)
  13.                         end_game();
  14.                 else {
  15.                         score += shape[shape_no].pointv[rot];
  16.                         store_shape(shape_no, xpos, ypos, rot);
  17.                         remove_full_lines(ypos);
  18.                         create_shape();
  19.                         show_score();
  20.                         show_next();
  21.                 }
  22.         }
  23.         print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  24.         draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  25.         return (NOTIFY_DONE);
  26. }
  27.  
  28. show_score()
  29. {
  30.         char    buf[BUFSIZ], buf1[BUFSIZ], buf2[BUFSIZ];
  31.  
  32.         sprintf(buf, "Score: %d", score);
  33.         panel_set(score_item, PANEL_LABEL_STRING, buf, 0);
  34.         sprintf(buf1, "Level: %d", rows / 10);
  35.         panel_set(level_item, PANEL_LABEL_STRING, buf1, 0);
  36.         sprintf(buf2, "Rows : %d", rows);
  37.         panel_set(rows_item, PANEL_LABEL_STRING, buf2, 0);
  38. }
  39.  
  40. void
  41. quit_proc()
  42. {
  43.         clear_events();
  44.         stop_timer();
  45.         window_destroy(frame);
  46. }
  47.  
  48. end_game()
  49. {
  50.         end_of_game = 1;
  51.         clear_events();
  52.         stop_timer();
  53.         panel_set(game_over, PANEL_SHOW_ITEM, TRUE, 0);
  54.         update_highscore_table();
  55.         print_high_scores();
  56. }
  57.  
  58. void
  59. restart_proc()
  60. {
  61.         clear_events();
  62.         stop_timer();
  63.         init_all();
  64. }
  65.  
  66. void
  67. start_proc()
  68. {
  69.         if (end_of_game)
  70.                 return;
  71.         set_events();
  72.         start_timer();
  73. }
  74.  
  75. void
  76. pause_proc()
  77. {
  78.         clear_events();
  79.         stop_timer();
  80. }
  81.  
  82. left_proc()
  83. {
  84.         if (block_can_left(shape_no, xpos, ypos, rot)) {
  85.                 print_shape(shape_no, xpos, ypos, rot, WHITE);
  86.                 xpos--;
  87.                 print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  88.                 draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  89.         }
  90. }
  91.  
  92. right_proc()
  93. {
  94.         if (block_can_right(shape_no, xpos, ypos, rot)) {
  95.                 print_shape(shape_no, xpos, ypos, rot, WHITE);
  96.                 xpos++;
  97.                 print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  98.                 draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  99.         }
  100. }
  101.  
  102. anti_proc()
  103. {
  104.         int     newrot;
  105.  
  106.         newrot = (rot + 3) % 4;
  107.         if (check_rot(shape_no, xpos, ypos, newrot)) {
  108.                 print_shape(shape_no, xpos, ypos, rot, WHITE);
  109.                 rot = newrot;
  110.                 print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  111.                 draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  112.         }
  113. }
  114.  
  115. clock_proc()
  116. {
  117.         int     newrot;
  118.  
  119.         newrot = (rot + 1) % 4;
  120.         if (check_rot(shape_no, xpos, ypos, newrot)) {
  121.                 print_shape(shape_no, xpos, ypos, rot, WHITE);
  122.                 rot = newrot;
  123.                 print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  124.                 draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  125.         }
  126. }
  127.  
  128. fast_proc()
  129. {
  130.         while (block_can_drop(shape_no, xpos, ypos, rot)) {
  131.                 print_shape(shape_no, xpos, ypos, rot, WHITE);
  132.                 ypos++;
  133.                 print_shape(shape_no, xpos, ypos, rot, shape[shape_no].color);
  134.         }
  135. }
  136.  
  137. void
  138. done_proc()
  139. {
  140.         window_set(score_frame, WIN_SHOW, FALSE, 0);
  141. }
  142.