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

  1. #include "defs.h"
  2. #include <sys/types.h>
  3. #include <sys/timeb.h>
  4. #include <pwd.h>
  5.  
  6. initialise()
  7. {
  8.         struct passwd *who;
  9.         int     depth;
  10.         Pixrect *mem_create();
  11.         char   *getenv();
  12.  
  13.         srand((int) time((time_t *) 0));
  14.         define_shapes();
  15.         depth = pw->pw_prretained->pr_depth;
  16.         monochrome = 0;
  17.         if (depth == 1)
  18.                 monochrome = 1;
  19.         if ((pr = mem_create(UNIT * UWIDTH, UNIT * UHEIGHT, depth)) == NULL) {
  20.                 fprintf(stderr, "mem_create() returned NULL\n");
  21.                 exit(-1);
  22.         }
  23.         if ((name = getenv("TETRIS")) == NULL) {
  24.                 who = getpwuid(getuid());
  25.                 name = who->pw_name;
  26.         }
  27.         print_authors();
  28.         init_all();
  29.         read_high_scores();
  30. }
  31.  
  32. init_all()
  33. {
  34.         int     i, j;
  35.  
  36.         score_position = -1;
  37.         end_of_game = 0;
  38.         rows = score = shape_no = rot = xpos = ypos = 0;
  39.         for (i = 0; i < UWIDTH; i++)
  40.                 for (j = 0; j < UHEIGHT; j++)
  41.                         grid[i][j] = 0;
  42.         create_shape();         /* Set up 1st shape */
  43.         create_shape();         /* Set up next shape */
  44.         pw_rop(pw, 0, 0, UNIT * UWIDTH, UNIT * UHEIGHT, PIX_SRC | PIX_COLOR(WHITE), NULL, 0, 0);
  45.         pw_vector(pw, 0, UHEIGHT * UNIT, UWIDTH * UNIT, UHEIGHT * UNIT, PIX_SRC | PIX_COLOR(BLACK), 0);
  46.         pw_vector(pw, 0, UHEIGHT * UNIT + SHADOW_HEIGHT, UWIDTH * UNIT, UHEIGHT * UNIT + SHADOW_HEIGHT, PIX_SRC | PIX_COLOR(BLACK), 0);
  47.         panel_set(game_over, PANEL_SHOW_ITEM, FALSE, 0);
  48.         show_score();
  49.         show_next();
  50.         draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
  51. }
  52.