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 / init.c < prev    next >
C/C++ Source or Header  |  1992-10-19  |  2KB  |  82 lines

  1. #include "defs.h"
  2. #include "icon"
  3. #include <X11/Xos.h>
  4. #include <pwd.h>
  5. #ifdef SVR4
  6. #define srandom srand
  7. #endif
  8.  
  9. initialise()
  10. {
  11.   struct passwd *who;
  12.   char   *getenv();
  13.   int i;
  14.   Arg args[20];
  15.   
  16.   srandom((int) time((time_t *) 0));
  17.   define_shapes();
  18.   if ((name = getenv("XTETRIS")) == NULL) {
  19.     who = getpwuid(getuid());
  20.     name = who->pw_name;
  21.   }
  22.   
  23.   init_all();
  24.   if (resources.speed < STANDARD_SPEED && resources.usescorefile)
  25.   {
  26.     resources.usescorefile = False;
  27.     fprintf( stderr, "%s: Speed too low for high-score table.  Use '-noscore' to avoid this message.\n",
  28.         programname );
  29.   }
  30.   read_high_scores();
  31.   
  32.   /* Make the icon. */
  33.   
  34.   tetris_icon = XCreateBitmapFromData(XtDisplay(frame),
  35.                       XtWindow(frame),
  36.                       icon_bits, icon_width, icon_height);
  37.   i=0;
  38.   XtSetArg(args[i], XtNiconPixmap, tetris_icon); i++; 
  39.   XtSetValues(toplevel, args, i);
  40. }
  41.  
  42. init_all()
  43. {
  44.   int     i, j;
  45.   Arg args[20];
  46.   
  47.   paused = False;    /* "running" is set False elsewhere */
  48.   score_position = -1;
  49.   end_of_game = 0;
  50.   rows = score = shape_no = rot = xpos = ypos = 0;
  51.   
  52.   for (i = 0; i < UWIDTH; i++)
  53.     for (j = 0; j < UHEIGHT; j++)
  54.       grid[i][j] = NULL;
  55.   
  56.   create_shape();         /* Set up 1st shape */
  57.   create_shape();         /* Set up next shape */
  58.   /*
  59.    *    Don't show anything until it starts. 
  60.    */
  61.   XClearWindow(XtDisplay(canvas), XtWindow(canvas) );
  62.   XClearWindow(XtDisplay(shadow), XtWindow(shadow) );
  63.   XClearWindow(XtDisplay(nextobject), XtWindow(nextobject) );
  64.  
  65.   XtVaSetValues(game_over, XtNlabel, "         ", NULL );
  66.   show_score();
  67. }
  68. /*
  69.   emacs mode: indented-text
  70.   
  71.   emacs Local Variables: 
  72.   emacs mode: c 
  73.   emacs c-indent-level: 2
  74.   emacs c-continued-statement-offset: 2
  75.   emacs c-continued-brace-offset: -2
  76.   emacs c-tab-always-indent: nil
  77.   emacs c-brace-offset: 0 
  78.   emacs tab-width: 8
  79.   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)
  80.   emacs End:
  81.   */
  82.