#include "defs.h" #include #include #include initialise() { struct passwd *who; int depth; Pixrect *mem_create(); char *getenv(); define_shapes(); compute_shape_constants(); pr = xv_create(XV_NULL, SERVER_IMAGE, XV_HEIGHT, UNIT * UWIDTH, XV_WIDTH, UNIT * UHEIGHT, 0); if (!name && ((name = getenv("TETRIS")) == NULL)) { who = getpwuid(getuid()); name = who->pw_name; } init_all(); read_high_scores(); } init_all() { int i, j; if (useSeed) { srandom(seed = (int)atol((char *)/* XView CONVERSION - You may wish to change this to xv_get format Look at panel.h and/or See Sect 2.5 */panel_get_value(seed_item))); } else { srandom(seed = (int) time((time_t *) 0)); } { char buf[32]; sprintf(buf, "%d", seed); xv_set(seed_item, PANEL_VALUE, buf, 0); } starttime = 0; score_position = -1; end_of_game = 0; rows = score = display_shape_no = display_rot = display_xpos = display_ypos = 0; for (i = 0; i < UWIDTH; i++) for (j = 0; j < UHEIGHT; j++) displaygrid[i][j] = 0; create_shape(); /* Set up 1st shape */ create_shape(); /* Set up next shape */ pw_rop(pw, 0, 0, UNIT * UWIDTH, UNIT * UHEIGHT, CLR, NULL, 0, 0); pw_vector(pw, 0, UHEIGHT * UNIT, UWIDTH * UNIT, UHEIGHT * UNIT, PIX_SRC, 0); pw_vector(pw, 0, UHEIGHT * UNIT + SHADOW_HEIGHT, UWIDTH * UNIT, UHEIGHT * UNIT + SHADOW_HEIGHT, PIX_SRC, 0); xv_set(game_over, XV_SHOW, FALSE, 0); show_score(); show_next(); draw_shadow(display_shape_no, display_xpos, display_ypos, display_rot, shape[display_shape_no].color); }