DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T i

⟦ee92029e9⟧ TextFile

    Length: 2189 (0x88d)
    Types: TextFile
    Names: »init.c«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/X/Xtetris/init.c« 

TextFile

#include "defs.h"
#include "tetris.xicon"
#include <sys/types.h>
#include <sys/timeb.h>
#include <pwd.h>

initialise()
{
        struct passwd *who;
        char   *getenv();
	int i;

        srand((int) time((time_t *) 0));
        define_shapes();
        if ((name = getenv("TETRIS")) == NULL) {
                who = getpwuid(getuid());
                name = who->pw_name;
        }
	print_authors();
        tetris_icon = XCreateBitmapFromData(XtDisplay(frame),
                                            XtWindow(frame),
                                      tetris_bits, tetris_width, tetris_height);
        i=0;
        XtSetArg(args[i], XtNiconPixmap, tetris_icon); i++;
        XtSetValues(toplevel, args, i);
        init_all();
        read_high_scores();
}

init_all()
{
        int     i, j;

	score_position = -1;
        end_of_game = 0;
        rows = score = shape_no = rot = xpos = ypos = 0;
        for (i = 0; i < UWIDTH; i++)
                for (j = 0; j < UHEIGHT; j++)
                        grid[i][j] = 0;
        create_shape();         /* Set up 1st shape */
        create_shape();         /* Set up next shape */
	XSetFunction(XtDisplay(toplevel), gc, GXclear);
        XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
                       0, 0, UNIT * UWIDTH, UNIT * UHEIGHT);
	XSetFunction(XtDisplay(toplevel), gc, GXcopy);
	XSetLineAttributes(XtDisplay(toplevel), gc,
                           1, LineSolid, CapButt, JoinMiter);
	XDrawLine(XtDisplay(toplevel), XtWindow(canvas), gc,
                  0, UHEIGHT * UNIT, UWIDTH * UNIT, UHEIGHT * UNIT);
	XDrawLine(XtDisplay(toplevel), XtWindow(canvas), gc,
                  0, UHEIGHT * UNIT + SHADOW_HEIGHT, 
                  UWIDTH * UNIT, UHEIGHT * UNIT + SHADOW_HEIGHT);
	XDrawLine(XtDisplay(toplevel), XtWindow(canvas), gc,
                  UWIDTH * UNIT, 0, 
                  UWIDTH * UNIT, UHEIGHT * UNIT + SHADOW_HEIGHT + NEXT_HEIGHT);
        XFlush(XtDisplay(toplevel));
	i=0;
	XtSetArg(args[i], XtNstring, "         "); i++;
	XtSetValues(game_over, args, i);
        show_score();
        show_next();
        draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
}