home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / xap / xgames / xtetris-.6 / xtetris- / xtetris-2.6 / notify.c < prev    next >
C/C++ Source or Header  |  1991-10-03  |  5KB  |  248 lines

  1. #include "defs.h"
  2.  
  3. void show_score(w, event, pars, npars)
  4.   Widget w;
  5.   XEvent *event;
  6.   String *pars;
  7.   Cardinal *npars;
  8. {
  9.   char    buf[BUFSIZ];
  10.   
  11.   sprintf( buf, "Score: %d", score);
  12.   XtVaSetValues( score_item, XtNlabel, buf, NULL );
  13.   
  14.   sprintf( buf, "Level: %d", rows / 10);
  15.   XtVaSetValues( level_item, XtNlabel, buf, NULL );
  16.  
  17.   sprintf( buf, "Rows:  %d", rows);
  18.   XtVaSetValues( rows_item, XtNlabel, buf, NULL );
  19. }
  20.  
  21. void about_proc( w, event, pars, npars )
  22.   Widget w;
  23.   XEvent *event;
  24.   String *pars;
  25.   Cardinal *npars;
  26. {
  27.   XtPopupSpringLoaded(about_frame);
  28. }
  29.  
  30. void quit_proc( w, event, pars, npars )
  31.   Widget w;
  32.   XEvent *event;
  33.   String *pars;
  34.   Cardinal *npars;
  35. {
  36.   clear_events();
  37.   stop_timer();
  38.   XtDestroyWidget(toplevel);
  39.   exit(0);
  40. }
  41.  
  42. void end_game(w, event, pars, npars)
  43.   Widget w;
  44.   XEvent *event;
  45.   String *pars;
  46.   Cardinal *npars;
  47. {
  48.   end_of_game = 1;
  49.   clear_events();
  50.   stop_timer();
  51.   XtUnmapWidget( start_bt );
  52.   XtUnmapWidget( pause_bt );
  53.  
  54.   XtVaSetValues(game_over,XtNlabel, "Game Over", NULL); 
  55.   update_highscore_table();
  56.   print_high_scores();
  57. }
  58.  
  59. void newgame_proc(w, event, pars, npars)
  60.   Widget w;
  61.   XEvent *event;
  62.   String *pars;
  63.   Cardinal *npars;
  64. {
  65.   clear_events();
  66.   stop_timer();
  67.   init_all();
  68. }
  69.  
  70. void start_proc(w, event, pars, npars)
  71.   Widget w;
  72.   XEvent *event;
  73.   String *pars;
  74.   Cardinal *npars;
  75. {
  76.   if (running || end_of_game) return;
  77.   paused = False;
  78.   running = True;
  79.   restore_widget(canvas,event,pars,npars);
  80.   restore_widget(shadow,event,pars,npars);
  81.   restore_widget(nextobject,event,pars,npars);
  82.   set_events();
  83.   start_timer();
  84. }
  85.  
  86. void resume_proc(w, event, pars, npars)
  87.   Widget w;
  88.   XEvent *event;
  89.   String *pars;
  90.   Cardinal *npars;
  91. {
  92.   if (!paused) return;
  93.   start_proc(w,event,pars,npars);
  94. }
  95.  
  96. void pause_proc(w, event, pars, npars)
  97.   Widget w;
  98.   XEvent *event;
  99.   String *pars;
  100.   Cardinal *npars;
  101. {
  102.   if (!running) return;
  103.   paused = True;
  104.   running = False;
  105.   restore_widget(canvas,event,pars,npars);
  106.   restore_widget(shadow,event,pars,npars);
  107.   restore_widget(nextobject,event,pars,npars);
  108.   clear_events();
  109.   stop_timer();
  110. }
  111.  
  112. void drop_block(w, event, pars, npars)
  113.   Widget w;
  114.   XEvent *event;
  115.   String *pars;
  116.   Cardinal *npars;
  117. {
  118.   if (block_can_drop(shape_no, xpos, ypos, rot))
  119.     print_shape( canvas, shape_no, xpos, ypos++, rot, True );
  120.   else {
  121.     if (ypos < 0)
  122.     {
  123.       end_game();
  124.       return;
  125.     }
  126.     else {
  127.       score += shape[shape_no].forms[rot].points;
  128.       store_shape(shape_no, xpos, ypos, rot);
  129.       remove_full_lines(ypos);
  130.       create_shape();
  131.       show_score();
  132.       show_next();
  133.       draw_shadow( shape_no, xpos, rot );
  134.     }
  135.   }
  136.   print_shape( canvas, shape_no, xpos, ypos, rot, False );
  137.   start_timer();
  138. }
  139.  
  140. void left_proc(w, event, pars, npars)
  141.   Widget w;
  142.   XEvent *event;
  143.   String *pars;
  144.   Cardinal *npars;
  145. {
  146.   if (!running) return;
  147.   
  148.   if (block_can_left(shape_no, xpos, ypos, rot)) {
  149.     print_shape( canvas, shape_no, xpos, ypos, rot, True );
  150.     xpos--;
  151.     print_shape( canvas, shape_no, xpos, ypos, rot, False );
  152.     draw_shadow(shape_no, xpos, rot );
  153.   }
  154. }
  155.  
  156. void right_proc(w, event, pars, npars)
  157.   Widget w;
  158.   XEvent *event;
  159.   String *pars;
  160.   Cardinal *npars;
  161. {
  162.   if (!running) return;
  163.   
  164.   if (block_can_right(shape_no, xpos, ypos, rot)) {
  165.     print_shape( canvas, shape_no, xpos, ypos, rot, True );
  166.     xpos++;
  167.     print_shape( canvas, shape_no, xpos, ypos, rot, False );
  168.     draw_shadow(shape_no, xpos, rot );
  169.   }
  170. }
  171.  
  172. void anti_proc(w, event, pars, npars)
  173.   Widget w;
  174.   XEvent *event;
  175.   String *pars;
  176.   Cardinal *npars;
  177. {
  178.   int     newrot;
  179.   
  180.   if (!running) return;
  181.   
  182.   newrot = (rot + 3) % 4;
  183.   if (check_rot(shape_no, xpos, ypos, newrot)) {
  184.     print_shape( canvas, shape_no, xpos, ypos, rot, True );
  185.     rot = newrot;
  186.     print_shape( canvas, shape_no, xpos, ypos, rot, False );
  187.     draw_shadow(shape_no, xpos, rot );
  188.   }
  189. }
  190.  
  191. void clock_proc(w, event, pars, npars)
  192.   Widget w;
  193.   XEvent *event;
  194.   String *pars;
  195.   Cardinal *npars;
  196. {
  197.   int     newrot;
  198.   
  199.   if (!running) return;
  200.   
  201.   newrot = (rot + 1) % 4;
  202.   if (check_rot(shape_no, xpos, ypos, newrot)) {
  203.     print_shape( canvas, shape_no, xpos, ypos, rot, True );
  204.     rot = newrot;
  205.     print_shape( canvas, shape_no, xpos, ypos, rot, False );
  206.     draw_shadow(shape_no, xpos, rot );
  207.   }
  208. }
  209.  
  210. void fast_proc(w, event, pars, npars)
  211.   Widget w;
  212.   XEvent *event;
  213.   String *pars;
  214.   Cardinal *npars;
  215. {
  216.   if (!running) return;
  217.   
  218.   while (block_can_drop(shape_no, xpos, ypos, rot)) {
  219.     print_shape( canvas, shape_no, xpos, ypos, rot, True );
  220.     ypos++;
  221.     print_shape( canvas, shape_no, xpos, ypos, rot, False );
  222.   }
  223. }
  224.  
  225. void done_proc(w, event, pars, npars)
  226.   Widget w;
  227.   XEvent *event;
  228.   String *pars;
  229.   Cardinal *npars;
  230. {
  231.   XtPopdown(score_frame);
  232.   XtPopdown(about_frame);
  233. }
  234. /*
  235.   emacs mode: indented-text
  236.   
  237.   emacs Local Variables: 
  238.   emacs mode: c 
  239.   emacs c-indent-level: 2
  240.   emacs c-continued-statement-offset: 2
  241.   emacs c-continued-brace-offset: -2
  242.   emacs c-tab-always-indent: nil
  243.   emacs c-brace-offset: 0 
  244.   emacs tab-width: 8
  245.   emacs tab-stop-list: (2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84)
  246.   emacs End:
  247.   */
  248.