home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!island!argv
- From: argv@island.uu.net (Dan Heller)
- Newsgroups: comp.sources.x
- Subject: v04i027: xtetris - X version of tetris, Part01/03
- Message-ID: <823@island.uu.net>
- Date: 14 Jun 89 12:14:54 GMT
- Organization: Island Graphics, Marin County, California
- Lines: 684
- Approved: island!argv@sun.com
-
- Submitted-by: Didier Tallot <Tallot@bdblues.altair.fr>
- Posting-number: Volume 4, Issue 27
- Archive-name: xtetris/part01
-
- [ This version of the game of tetris requires the HP widgets -- which I
- don't have. So, I couldn't test it. There is no Imakefile, but the
- makefile is rather simple. --argv ]
-
- #!/bin/sh
- # shar: Shell Archiver (v1.22)
- #
- # This is part 1 of a multipart archive
- # do not concatenate these parts, unpack them in order with /bin/sh
- #
- # Run the following text with /bin/sh to create:
- # COPYRIGHT
- # MANIFEST
- # Makefile
- # README
- # defs.h
- # draw.c
- # event.c
- # init.c
- # main.c
- # notify.c
- # score.c
- # shape.c
- # support.c
- # tetris.xicon
- # window.c
- # xtetris.6
- #
- if test -r s2_seq_.tmp
- then echo "Must unpack archives in sequence!"
- next=`cat s2_seq_.tmp`; echo "Please unpack part $next next"
- exit 1; fi
- echo "x - extracting COPYRIGHT (Text)"
- sed 's/^X//' << 'SHAR_EOF' > COPYRIGHT &&
- XCopyright 1989 Phill Everson & Martyn Shortley
- X
- XThis notice and any statement of authorship must be reproduced
- Xon all copies. The authors do not make any warranty expressed
- Xor implied, or assume any liability or responsiblity for the
- Xuse of this software.
- X
- XAny distributor of copies of this software shall grant the
- Xrecipient permission for further redistribution as permitted
- Xby this notice. Any distributor must distribute this software
- Xwithout any fee or other monetary gains, unless expressed written
- Xpermission is granted by the authors.
- X
- XThis software or its use shall not be: sold, rented, leased,
- Xtraded, or otherwise marketed without the expressed written
- Xpermission of the authors.
- X
- XIf the software is modified in a manner creating derivative
- Xcopyrights, appropriate legends may be placed on derivative
- Xwork in addition to that set forth above.
- X
- XPermission is hereby granted to copy, reproduce, redistribute or
- Xotherwise use this software as long as the conditions above
- Xare met.
- X
- XAll rights not granted by this notice are reserved.
- X
- XAuthors: Phill Everson <everson@cs.bris.ac.uk>
- X Martyn Shortley <shortley@cs.bris.ac.uk>
- X
- XModifications for X : Didier Tallot <tallot@bdblues.altair.fr>
- X Copyright 1989 Didier Tallot
- SHAR_EOF
- chmod 0644 COPYRIGHT || echo "restore of COPYRIGHT fails"
- echo "x - extracting MANIFEST (Text)"
- sed 's/^X//' << 'SHAR_EOF' > MANIFEST &&
- X File Name Archive # Description
- X-----------------------------------------------------------
- X COPYRIGHT 1
- X MANIFEST 1 This shipping list
- X Makefile 1
- X README 1
- X defs.h 1
- X draw.c 1
- X event.c 1
- X init.c 1
- X main.c 1
- X notify.c 1
- X score.c 1
- X shape.c 1
- X support.c 1
- X tetris.6 1
- X tetris.icon 1
- X window.c 1
- SHAR_EOF
- chmod 0644 MANIFEST || echo "restore of MANIFEST fails"
- echo "x - extracting Makefile (Text)"
- sed 's/^X//' << 'SHAR_EOF' > Makefile &&
- XBINDIR=/usr/games/
- XCC=cc
- XCFLAGS=-O
- X
- XINCLUDES = -I.
- X
- XLIBS = -lXw -lXt -lX11
- X
- XPROG=xtetris
- XCFILES=main.c event.c init.c shape.c support.c notify.c window.c \
- X score.c draw.c
- XOFILES=main.o event.o init.o shape.o support.o notify.o window.o \
- X score.o draw.o
- X
- X.c.o:
- X $(CC) -c $(CFLAGS) $(INCLUDES) $*.c
- X
- X$(PROG): $(OFILES)
- X $(CC) $(CFLAGS) -o $(PROG) $(OFILES) $(LIBS)
- X
- X$(OFILES): defs.h
- X
- X# tetris needs to be setuid so that the high scores file can be updated.
- X# if you don't like setuid programs on your system then just make sure
- X# that the high score file is globally read/writable.
- Xinstall: $(PROG)
- X install -s $(PROG) $(BINDIR)
- X chmod u+s $(BINDIR)/$(PROG)
- X
- Xclean:
- X rm *.o core
- SHAR_EOF
- chmod 0644 Makefile || echo "restore of Makefile fails"
- echo "x - extracting README (Text)"
- sed 's/^X//' << 'SHAR_EOF' > README &&
- XX Based Tetris
- X
- XThis version of xtetris is based on the version posted to
- Xcomp.sources.games byll Everson & Martyn Shortley in early
- XMarch, 1989.
- X
- XThis was developed under SunOS4.0 running on a Sun3.
- X
- XTo install:
- X
- X Set HIGH_SCORE_TABLE in defs.h to the pathname of your high
- X scores table. (If you do not want tetris to be installed setuid
- X (the default) this file will have to be globally
- X read/writable). The high score file will be created the first
- X time tetris is executed.
- X
- X Set BINDIR in Makefile to be the desired location of the
- X compiled binary.
- X
- X type "make install"
- X
- XDidier Tallot <tallot@bdblues.altair.fr>
- XGIP Altair, INRIA, Rocquencourt, France
- X
- X29 May, 1989
- SHAR_EOF
- chmod 0644 README || echo "restore of README fails"
- echo "x - extracting defs.h (Text)"
- sed 's/^X//' << 'SHAR_EOF' > defs.h &&
- X#include <stdio.h>
- X
- X#include <X11/Xlib.h>
- X#include <X11/Intrinsic.h>
- X#include <X11/StringDefs.h>
- X#include <X11/Shell.h>
- X
- X#include <Xw/Xw.h>
- X
- X#define UWIDTH 10 /* canvas size in units */
- X#define UHEIGHT 30
- X
- X#define UNIT 19 /* pixels in a unit */
- X#define SHADOW_OFFSET UNIT
- X#define SHADOW_HEIGHT (UNIT+SHADOW_OFFSET) /* shadow area height in
- X * pixels */
- X#define NEXT_HEIGHT (UNIT*5) /* Height for next block */
- X
- X#define HIGH_TABLE_SIZE 10 /* size of high score table */
- X#ifndef HIGH_SCORE_TABLE
- X#define HIGH_SCORE_TABLE "/usr/games/lib/tetris_scores"
- X#endif
- X
- X#define NO_COLS 16
- X
- X#define WHITE 0
- X#define RED 1
- X#define ORANGE 2
- X#define YELLOW 3
- X#define GREEN 4
- X#define BLUE 5
- X#define CYAN 6
- X#define VIOLET 7
- X#define BLACK 8
- X
- Xstatic Arg args[20];
- X
- XWidget toplevel;
- XWidget frame, score_frame;
- XWidget panel, score_panel;
- XWidget sub1_panel, sub2_panel;
- XWidget canvas;
- XWidget high_score_item[HIGH_TABLE_SIZE+1], score_item, level_item, rows_item, game_over;
- XWidget tbar, start_bt, pause_bt, newgame_bt, scores_bt, quit_bt, done_bt;
- XGC gc;
- XPixmap tetris_icon;
- X
- Xint end_of_game, score_position;
- Xint shape_no, xpos, ypos, rot, score, rows;
- Xint next_no, next_rot;
- Xchar *name;
- Xunsigned char grid[UWIDTH][UHEIGHT];
- X
- Xstruct score_table {
- X char name[BUFSIZ];
- X int score;
- X int rows;
- X int level;
- X char hostname[BUFSIZ];
- X char date[BUFSIZ];
- X} high_scores[HIGH_TABLE_SIZE];
- X
- Xstruct shape_table {
- X int table[4][4];
- X int width;
- X int height;
- X int offset;
- X int pointv[4];
- X char color;
- X} shape[7];
- X
- Xstruct shape {
- X int shape;
- X int rot;
- X int width;
- X int height;
- X int offset;
- X int pointv;
- X char color;
- X int was_shown;
- X int was_shadowed;
- X} *current, *next;
- X
- Xvoid print_high_scores(), done_proc(), quit_proc(), start_proc(), pause_proc(), restart_proc();
- Xvoid canvas_event_proc();
- Xvoid drop_block();
- Xvoid restore_canvas();
- SHAR_EOF
- chmod 0644 defs.h || echo "restore of defs.h fails"
- echo "x - extracting draw.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > draw.c &&
- X#include "defs.h"
- X
- Xdraw_shadow(shape_no, xpos, ypos, rot, col)
- X int shape_no, xpos, ypos, rot, col;
- X{
- X int y1;
- X int x1, x2, x3, x4;
- X int t0, t1, t2, t3;
- X int xsize;
- X
- X t0 = shape[shape_no].table[0][rot]; /* Bit map of 1st Row */
- X t1 = shape[shape_no].table[1][rot]; /* Bit map of 2nd Row */
- X t2 = shape[shape_no].table[2][rot]; /* Bit map of 3rd Row */
- X t3 = shape[shape_no].table[3][rot]; /* Bit map of 4th Row */
- X
- X x1 = xpos * UNIT; /* Position of 1st column of block grid */
- X x2 = x1 + UNIT; /* Position of 2nd column of block grid */
- X x3 = x2 + UNIT; /* Position of 3rd column of block grid */
- X x4 = x3 + UNIT; /* Position of 4th column of block grid */
- X
- X y1 = UHEIGHT * UNIT + SHADOW_OFFSET / 2;
- X xsize = UWIDTH * UNIT;
- X
- X XSetFunction(XtDisplay(toplevel), gc, GXclear);
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X 0, y1, xsize, UNIT);
- X XFlush(XtDisplay(toplevel));
- X if (col == WHITE) XSetFunction(XtDisplay(toplevel), gc, GXclear);
- X else XSetFunction(XtDisplay(toplevel), gc, GXcopy);
- X if (t0 & 8 || t1 & 8 || t2 & 8 || t3 & 8)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x1, y1, UNIT, UNIT);
- X if (t0 & 4 || t1 & 4 || t2 & 4 || t3 & 4)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x2, y1, UNIT, UNIT);
- X if (t0 & 2 || t1 & 2 || t2 & 2 || t3 & 2)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x3, y1, UNIT, UNIT);
- X if (t0 & 1 || t1 & 1 || t2 & 1 || t3 & 1)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x4, y1, UNIT, UNIT);
- X XFlush(XtDisplay(toplevel));
- X}
- X
- Xshow_next()
- X{
- X int y, y1, xsize;
- X
- X y = UHEIGHT * UNIT + SHADOW_HEIGHT;
- X xsize = UNIT * UWIDTH;
- X
- X XSetFunction(XtDisplay(toplevel), gc, GXclear);
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X 0, y + UNIT, xsize, NEXT_HEIGHT - UNIT);
- X
- X XSetFunction(XtDisplay(toplevel), gc, GXcopy);
- X XDrawString(XtDisplay(toplevel), XtWindow(canvas), gc,
- X 5, y + UNIT, "Next block", 10);
- X
- X y1 = y / UNIT + 1;
- X print_shape(next_no, 5, y1, next_rot, shape[next_no].color);
- X XFlush(XtDisplay(toplevel));
- X}
- X
- Xprint_shape(shape_no, x, y, rot, col)
- X int shape_no, x, y, rot, col;
- X{
- X int x1, x2, x3, x4, y1;
- X int t0, t1, t2, t3;
- X
- X t0 = shape[shape_no].table[0][rot]; /* Bit map of 1st Row */
- X t1 = shape[shape_no].table[1][rot]; /* Bit map of 2nd Row */
- X t2 = shape[shape_no].table[2][rot]; /* Bit map of 3rd Row */
- X t3 = shape[shape_no].table[3][rot]; /* Bit map of 4th Row */
- X
- X x1 = x * UNIT; /* Position of 1st column of block grid */
- X x2 = x1 + UNIT; /* Position of 2nd column of block grid */
- X x3 = x2 + UNIT; /* Position of 3rd column of block grid */
- X x4 = x3 + UNIT; /* Position of 4th column of block grid */
- X y1 = y * UNIT; /* Position of 1st row of block grid */
- X
- X if (col == WHITE) XSetFunction(XtDisplay(toplevel), gc, GXclear);
- X else XSetFunction(XtDisplay(toplevel), gc, GXcopy);
- X if (y > -1) {
- X if (t0 & 8)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x1, y1, UNIT, UNIT);
- X if (t0 & 4)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x2, y1, UNIT, UNIT);
- X if (t0 & 2)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x3, y1, UNIT, UNIT);
- X if (t0 & 1)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x4, y1, UNIT, UNIT);
- X }
- X y1 += UNIT; /* Position of next row */
- X if (y > -2) {
- X if (t1 & 8)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x1, y1, UNIT, UNIT);
- X if (t1 & 4)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x2, y1, UNIT, UNIT);
- X if (t1 & 2)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x3, y1, UNIT, UNIT);
- X if (t1 & 1)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x4, y1, UNIT, UNIT);
- X }
- X y1 += UNIT; /* Position of next row */
- X if (y > -3) {
- X if (t2 & 8)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x1, y1, UNIT, UNIT);
- X if (t2 & 4)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x2, y1, UNIT, UNIT);
- X if (t2 & 2)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x3, y1, UNIT, UNIT);
- X if (t2 & 1)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x4, y1, UNIT, UNIT);
- X }
- X y1 += UNIT; /* Position of next row */
- X if (y > -4) {
- X if (t3 & 8)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x1, y1, UNIT, UNIT);
- X if (t3 & 4)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x2, y1, UNIT, UNIT);
- X if (t3 & 2)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x3, y1, UNIT, UNIT);
- X if (t3 & 1)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x4, y1, UNIT, UNIT);
- X }
- X
- X XSetFillStyle(XtDisplay(toplevel), gc, FillTiled);
- X y1 = y * UNIT; /* Position of 1st row of block grid */
- X if (y > -1) {
- X if (t0 & 8)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x1 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t0 & 4)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x2 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t0 & 2)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x3 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t0 & 1)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x4 +1, y1 +1, UNIT -2, UNIT -2);
- X }
- X y1 += UNIT; /* Position of next row */
- X if (y > -2) {
- X if (t1 & 8)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x1 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t1 & 4)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x2 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t1 & 2)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x3 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t1 & 1)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x4 +1, y1 +1, UNIT -2, UNIT -2);
- X }
- X y1 += UNIT; /* Position of next row */
- X if (y > -3) {
- X if (t2 & 8)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x1 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t2 & 4)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x2 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t2 & 2)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x3 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t2 & 1)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x4 +1, y1 +1, UNIT -2, UNIT -2);
- X }
- X y1 += UNIT; /* Position of next row */
- X if (y > -4) {
- X if (t3 & 8)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x1 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t3 & 4)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x2 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t3 & 2)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x3 +1, y1 +1, UNIT -2, UNIT -2);
- X if (t3 & 1)
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X x4 +1, y1 +1, UNIT -2, UNIT -2);
- X }
- X XSetFillStyle(XtDisplay(toplevel), gc, FillSolid);
- X XFlush(XtDisplay(toplevel));
- X}
- SHAR_EOF
- chmod 0644 draw.c || echo "restore of draw.c fails"
- echo "x - extracting event.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > event.c &&
- X#include "defs.h"
- X#define BUFSIZE 100
- X
- Xvoid
- Xcanvas_event_proc(w, client_data, event)
- X Widget w;
- X caddr_t client_data;
- X XEvent *event;
- X{
- X char buf[BUFSIZE];
- X int length;
- X
- X if (event->type == ButtonRelease)
- X return;
- X if (event->type == ButtonPress) {
- X switch (event->xbutton.button) {
- X case Button1:
- X if (event->xbutton.state == (Button1Mask || ShiftMask))
- X anti_proc();
- X else
- X left_proc();
- X break;
- X case Button3:
- X if (event->xbutton.state == (Button3Mask || ShiftMask))
- X clock_proc();
- X else
- X right_proc();
- X break;
- X
- X case Button2:
- X if (event->xbutton.state != (Button2Mask || ShiftMask))
- X fast_proc();
- X break;
- X }
- X return;
- X }
- X if (event->type == KeyRelease)
- X return;
- X if (event->type == KeyPress) {
- X length = XLookupString (event, buf, BUFSIZE, NULL, NULL);
- X switch (buf[0]) {
- X case 'j':
- X left_proc();
- X break;
- X case 'k':
- X anti_proc();
- X break;
- X case 'l':
- X right_proc();
- X break;
- X case ' ':
- X fast_proc();
- X break;
- X }
- X return;
- X }
- X}
- SHAR_EOF
- chmod 0644 event.c || echo "restore of event.c fails"
- echo "x - extracting init.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > init.c &&
- X#include "defs.h"
- X#include "tetris.xicon"
- X#include <sys/types.h>
- X#include <sys/timeb.h>
- X#include <pwd.h>
- X
- Xinitialise()
- X{
- X struct passwd *who;
- X char *getenv();
- X int i;
- X
- X srand((int) time((time_t *) 0));
- X define_shapes();
- X if ((name = getenv("TETRIS")) == NULL) {
- X who = getpwuid(getuid());
- X name = who->pw_name;
- X }
- X print_authors();
- X tetris_icon = XCreateBitmapFromData(XtDisplay(frame),
- X XtWindow(frame),
- X tetris_bits, tetris_width, tetris_height);
- X i=0;
- X XtSetArg(args[i], XtNiconPixmap, tetris_icon); i++;
- X XtSetValues(toplevel, args, i);
- X init_all();
- X read_high_scores();
- X}
- X
- Xinit_all()
- X{
- X int i, j;
- X
- X score_position = -1;
- X end_of_game = 0;
- X rows = score = shape_no = rot = xpos = ypos = 0;
- X for (i = 0; i < UWIDTH; i++)
- X for (j = 0; j < UHEIGHT; j++)
- X grid[i][j] = 0;
- X create_shape(); /* Set up 1st shape */
- X create_shape(); /* Set up next shape */
- X XSetFunction(XtDisplay(toplevel), gc, GXclear);
- X XFillRectangle(XtDisplay(toplevel), XtWindow(canvas), gc,
- X 0, 0, UNIT * UWIDTH, UNIT * UHEIGHT);
- X XSetFunction(XtDisplay(toplevel), gc, GXcopy);
- X XSetLineAttributes(XtDisplay(toplevel), gc,
- X 1, LineSolid, CapButt, JoinMiter);
- X XDrawLine(XtDisplay(toplevel), XtWindow(canvas), gc,
- X 0, UHEIGHT * UNIT, UWIDTH * UNIT, UHEIGHT * UNIT);
- X XDrawLine(XtDisplay(toplevel), XtWindow(canvas), gc,
- X 0, UHEIGHT * UNIT + SHADOW_HEIGHT,
- X UWIDTH * UNIT, UHEIGHT * UNIT + SHADOW_HEIGHT);
- X XDrawLine(XtDisplay(toplevel), XtWindow(canvas), gc,
- X UWIDTH * UNIT, 0,
- X UWIDTH * UNIT, UHEIGHT * UNIT + SHADOW_HEIGHT + NEXT_HEIGHT);
- X XFlush(XtDisplay(toplevel));
- X i=0;
- X XtSetArg(args[i], XtNstring, " "); i++;
- X XtSetValues(game_over, args, i);
- X show_score();
- X show_next();
- X draw_shadow(shape_no, xpos, ypos, rot, shape[shape_no].color);
- X}
- SHAR_EOF
- chmod 0644 init.c || echo "restore of init.c fails"
- echo "x - extracting main.c (Text)"
- sed 's/^X//' << 'SHAR_EOF' > main.c &&
- X#include "defs.h"
- X
- X#include <Xw/Panel.h>
- X#include <Xw/TitleBar.h>
- X#include <Xw/PButton.h>
- X#include <Xw/RCManager.h>
- X#include <Xw/SText.h>
- X#include <Xw/WorkSpace.h>
- X
- X
- X
- X
- Xmain(argc, argv)
- X int argc;
- X char **argv;
- X{
- X int i, j;
- X XFontStruct *cyril;
- X
- X toplevel = XtInitialize(argv[0], "TEtris", NULL, 0, &argc, argv);
- X frame = XtCreateManagedWidget("Frame",
- X XwpanelWidgetClass,
- X toplevel,
- X NULL,0);
- X i=0;
- X XtSetArg(args[i], XtNwidgetType, XwTITLE); i++;
- X XtSetArg(args[i], XtNstring, "tetris"); i++;
- X cyril = XLoadQueryFont(XtDisplay(toplevel),"cyr-s25");
- X if (cyril) XtSetArg(args[i], XtNfont, cyril); i++;
- X tbar = XtCreateManagedWidget("TitleBar",
- X XwtitlebarWidgetClass,
- X frame,
- X args, i);
- X i=0;
- X XtSetArg(args[i], XtNwidgetType, XwPULLDOWN); i++;
- X XtSetArg(args[i], XtNwidth, UWIDTH * UNIT); i++;
- X XtSetArg(args[i], XtNlayoutType, XwREQUESTED_COLUMNS); i++;
- X XtSetArg(args[i], XtNlayout, XwMAXIMIZE); i++;
- X XtSetArg(args[i], XtNcolumns, 2); i++;
- X panel = XtCreateManagedWidget("Panel",
- X XwrowColWidgetClass,
- X frame,
- X args, i);
- X i=0;
- X XtSetArg(args[i], XtNlayoutType, XwREQUESTED_COLUMNS); i++;
- X XtSetArg(args[i], XtNcolumns, 1); i++;
- X XtSetArg(args[i], XtNborderWidth, 0); i++;
- X sub1_panel = XtCreateManagedWidget("Panel",
- X XwrowColWidgetClass,
- X panel,
- X args, i);
- X i=0;
- X XtSetArg(args[i], XtNlayoutType, XwREQUESTED_COLUMNS); i++;
- X XtSetArg(args[i], XtNcolumns, 1); i++;
- X XtSetArg(args[i], XtNborderWidth, 0); i++;
- X sub2_panel = XtCreateManagedWidget("Panel",
- X XwrowColWidgetClass,
- X panel,
- X args, i);
- X i=0;
- X XtSetArg(args[i], XtNstring, "Score: 0 "); i++;
- X XtSetArg(args[i], XtNborderWidth, 0); i++;
- X XtSetArg(args[i], XtNstrip, FALSE); i++;
- X score_item = XtCreateManagedWidget("Score",
- X XwstatictextWidgetClass,
- X sub1_panel,
- X args, i);
- X i=0;
- X XtSetArg(args[i], XtNstring, "Level: 0 "); i++;
- X XtSetArg(args[i], XtNborderWidth, 0); i++;
- X XtSetArg(args[i], XtNstrip, FALSE); i++;
- X level_item = XtCreateManagedWidget("Level",
- X XwstatictextWidgetClass,
- X sub1_panel,
- X args, i);
- X i=0;
- X XtSetArg(args[i], XtNstring, "Rows: 0 "); i++;
- X XtSetArg(args[i], XtNborderWidth, 0); i++;
- X XtSetArg(args[i], XtNstrip, FALSE); i++;
- X rows_item = XtCreateManagedWidget("Rows",
- X XwstatictextWidgetClass,
- X sub1_panel,
- X args, i);
- X i=0;
- X XtSetArg(args[i], XtNstring, " "); i++;
- X XtSetArg(args[i], XtNborderWidth, 0); i++;
- X XtSetArg(args[i], XtNstrip, FALSE); i++;
- X game_over = XtCreateManagedWidget("Game",
- X XwstatictextWidgetClass,
- SHAR_EOF
- echo "End of part 1"
- echo "File main.c is continued in part 2"
- echo "2" > s2_seq_.tmp
- exit 0
-