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 / window.c < prev    next >
C/C++ Source or Header  |  1995-02-10  |  2KB  |  89 lines

  1. #include "defs.h"
  2.  
  3. static XtIntervalId timer;
  4.  
  5. start_timer()
  6. {
  7.   unsigned long interval;
  8.   int     droprate;
  9.   
  10.   droprate = 2500 - rows * 12;
  11.   if (droprate < 0) 
  12.     interval = 0;
  13.   else
  14.     interval = droprate / (int)resources.speed;
  15.   
  16.   XFlush(XtDisplay(canvas));
  17.   timer = XtAppAddTimeOut( context, interval, drop_block, NULL);
  18. }
  19.  
  20. stop_timer()
  21. {
  22.   if( timer )
  23.   {
  24.     XtRemoveTimeOut(timer);
  25.     timer = 0;
  26.   }
  27. }
  28.  
  29. set_events()
  30. {
  31.   running = True;
  32.   paused = False;
  33.   XtUnmapWidget( start_bt );
  34.   XtMapWidget( pause_bt );
  35. }
  36.  
  37. clear_events()
  38. {
  39.   running = False;
  40.   XtUnmapWidget( pause_bt );
  41.   XtMapWidget( start_bt );
  42. }
  43.  
  44. void restore_widget(w, event, pars, npars )
  45.   Widget w;
  46.   XEvent *event;
  47.   String *pars;
  48.   Cardinal *npars;
  49. {
  50.   int x, y;
  51.  
  52.   if (!running && !end_of_game)
  53.   {
  54.     XClearArea(XtDisplay(w), XtWindow(w), 0, 0, 0, 0, False );
  55.     return;
  56.   }
  57.   if (w == canvas) 
  58.   {
  59.     for(x=0; x<UWIDTH; x++)
  60.       for(y=0; y<UHEIGHT; y++)
  61.     if (grid[x][y] != NULL) {
  62.       XFillRectangle(XtDisplay(w), XtWindow(w), grid[x][y]->gc,
  63.              x * resources.boxsize, y * resources.boxsize, 
  64.              resources.boxsize, resources.boxsize);
  65.     }
  66.     print_shape( canvas, shape_no, xpos, ypos, rot, False );
  67.   }
  68.   else if (w == shadow)
  69.     draw_shadow(shape_no, xpos, rot );
  70.   else if (w == nextobject)
  71.     show_next();
  72.   else
  73.     fprintf( stderr, "Hmm. I got a Refresh() for an unrecognized window!\n" );
  74. }
  75. /*
  76.   emacs mode: indented-text
  77.   
  78.   emacs Local Variables: 
  79.   emacs mode: c 
  80.   emacs c-indent-level: 2
  81.   emacs c-continued-statement-offset: 2
  82.   emacs c-continued-brace-offset: -2
  83.   emacs c-tab-always-indent: nil
  84.   emacs c-brace-offset: 0 
  85.   emacs tab-width: 8
  86.   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)
  87.   emacs End:
  88.   */
  89.