/* Copyright (c) 2000 Jean-Marc Zucconi * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer * in this position and unchanged. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include "qix.h" #include "images.h" #define BIG_FONT "-adobe-helvetica-bold-r-normal--24-240-75-75-p-138-iso8859-1" #define BIG_FONT_S "-adobe-helvetica-bold-r-normal--18-180-75-75-p-103-iso8859-1" #define BIG_FONT_H 24 #define BIG_FONT_S_H 18 #define MSG_FONT "-adobe-times-medium-r-normal--18-180-75-75-p-94-iso8859-1" #define MSG_FONT_S "-adobe-times-medium-r-normal--14-140-75-75-p-74-iso8859-1" #define PIX_W 11 #define PIX_H 20 #define PIX_W_SMALL 9 #define PIX_H_SMALL 16 static void msg (int, int, char *), w_create (); static int key_wait (int), color (int, int, int), refresh (); static char key (KeySym); static Display *disp; static int scr; static Window window; static int x, y, width, height; static Pixmap pixmap; static Pixmap f11_pixmap, f12_pixmap, f13_pixmap, f14_pixmap, f15_pixmap, f18_pixmap, f19_pixmap, f1c_pixmap, f1d_pixmap, f1e_pixmap, f1f_pixmap, you_pixmap, blank_pixmap, fuse_pixmap, qix_head_pixmap, fill_pixmap; static GC gc, gc_info, gc_pause, gc_msg, gc_you; Colormap cmap; XFontStruct *msg_font, *disp_font; int big_font_h; int k_mask = (1<fid); cur = XCreateBitmapFromData(disp, window, nocurs, 1, 1); XDefineCursor (disp, window, XCreatePixmapCursor(disp, cur, cur, &c, &c, 0, 0)); XMapWindow (disp, window); XFlush (disp); } static int color (int r, int g, int b) { /* return the pixel value of given color */ XColor c; c.red = r <<8; /* rgb values are in the 0-65535 range */ c.green = g <<8; c.blue = b <<8; if (!XAllocColor(disp, cmap, &c)) { /* find the closest entry in our colormap */ XColor col[256]; float delt[256], x; int n, i, p; n = DisplayCells (disp, scr); if (n > 256) n = 256; for (i = 0; i < n; i++) col[i].pixel = i; XQueryColors (disp, cmap, col, n); for (i = 0; i < n; i++) { x = (r - (col[i].red >> 8)); delt[i] = x*x; x = (g - (col[i].green >> 8)); delt[i] += x*x; x = (b - (col[i].blue >> 8)); delt[i] += x*x; } x = delt[0]; p = 0; for ( i = 0; i < n; i++) { if (delt[i] < x) { x = delt[i]; p = i; } } c.pixel = p; } return c.pixel; } static Pixmap mkpix (XImage *img, GC gc, unsigned long *pixel, char *f) { int i, j; Pixmap p; char *x = f + 2; p = XCreatePixmap (disp, window, f[0], f[1], DefaultDepth (disp, scr)); for (j = 0; j < f[1]; j++) for (i = 0; i < f[0]; i++) XPutPixel (img, i, j, pixel[*x++]); XPutImage (disp, p, gc, img, 0, 0, 0, 0, f[0], f[1]); return p; } static void init_pixmaps () { int n; unsigned long pixel[256]; char *data = (char *) malloc (256*256*32); GC gc = XCreateGC (disp, window, 0, 0); XImage *img = XCreateImage (disp, DefaultVisual(disp,scr), DefaultDepth(disp,scr), ZPixmap, 0, data, PIX_W, PIX_H, 8, 0); for (n = 0; used_colors[n] != -1; n++) pixel[n] = color (used_colors[n] >> 16, (used_colors[n] >> 8) & 0xff, used_colors[n] & 0xff); #define XPIX(f) f##_pixmap = mkpix (img, gc, pixel, f##_img) #define XPIXS(f) f##_pixmap = mkpix (img, gc, pixel, f##_9x16_img) if (small) { XPIXS (f11); XPIXS (f13); XPIXS (f15); XPIXS (f19); XPIXS (f1d); XPIXS (f1f); XPIXS (f12); XPIXS (f14); XPIXS (f18); XPIXS (f1c); XPIXS (f1e); XPIXS (blank); XPIXS (qix_head); XPIXS (fuse); XPIXS (you); XPIXS (fill); pix_width = PIX_W_SMALL; pix_height = PIX_H_SMALL; } else { XPIX (f11); XPIX (f13); XPIX (f15); XPIX (f19); XPIX (f1d); XPIX (f1f); XPIX (f12); XPIX (f14); XPIX (f18); XPIX (f1c); XPIX (f1e); XPIX (blank); XPIX (qix_head); XPIX (fuse); XPIX (you); XPIX (fill); pix_width = PIX_W; pix_height = PIX_H; } XDestroyImage (img); } void VT_init () { if (!init) { x = 0; y = 0; if (small) { width = HEIGHT*PIX_W_SMALL; height = WIDTH*PIX_H_SMALL; } else { width = HEIGHT*PIX_W; height = WIDTH*PIX_H; } w_create (); init_pixmaps (); init = 1; } } void Pos (int y, int x, unsigned char c) { Pixmap p; switch (c) { case '*': p = fuse_pixmap; break; case Blank: if (filling) p = fill_pixmap; else p = blank_pixmap; break; case You: p = you_pixmap; break; case Qix_Head: p = qix_head_pixmap; break; case F_11: p = f11_pixmap; break; case F_12: p = f12_pixmap; break; case F_13: p = f13_pixmap; break; case F_14: p = f14_pixmap; break; case F_15: p = f15_pixmap; break; case F_18: p = f18_pixmap; break; case F_19: p = f19_pixmap; break; case F_1C: p = f1c_pixmap; break; case F_1D: p = f1d_pixmap; break; case F_1E: p = f1e_pixmap; break; case F_1F: p = f1f_pixmap; break; } XCopyArea (disp, p, window, gc, 0, 0, pix_width, pix_height, x*pix_width, y*pix_height); XCopyArea (disp, p, pixmap, gc, 0, 0, pix_width, pix_height, x*pix_width, y*pix_height); XFlush (disp); } static struct { char x, y; } qix_pos[] = { {4,9}, {4,10}, {4,11}, {4,12}, {4,13}, {4,14}, {4,15}, {4,16}, {4,17}, {4,18}, {5,18}, {6,18}, {7,18}, {7,17}, {8,17}, {9,17}, {9,16}, {9,15}, {9,14}, {10,14}, {11,14}, {12,14}, {13,14}, {14,14}, {15,14}, {16,14}, {17,14}, {17,15}, {17,16}, {17,17}, {17,18}, {17,19}, {16,19}, {15,19}, {14,19}, {13,19}, {12,19}, {11,19}, {11,20}, {11,21}, {11,22}, {11,23}, {11,24}, {11,25}, {11,26}, {11,27}, {11,28}, {11,29}, {11,30}, {11,31}, {11,32}, {11,33}, {12,33}, {13,33}, {14,33}, {14,32}, {14,31}, {14,30}, {14,29}, {15,29}, {15,28}, {15,27}, {15,26}, {15,25}, {14,25}, {13,25}, {13,24}, {13,23}, {13,22}, {14,22}, {15,22}, {16,22}, {17,22}, {18,22}, {19,22}, {19,23}, {19,24}, {18,24}, {18,25}, {18,26}, {18,27}, {18,28}, {18,29}, {18,30}, {18,31}, {18,32}, {18,33}, {18,34}, {18,35}, {18,36}, {18,37}, {17,37}, {16,37}, {16,38}, {16,39}, {17,39}, {18,39}, {18,40}, {18,41}, {17,41}, {16,41}, {16,42}, {16,43}, {17,43}, {18,43}, {18,44}, {18,45}, {17,45}, {16,45}, {16,46}, {16,47}, {17,47}, {18,47}, {18,48}, {18,49}, {17,49}, {16,49}, {16,50}, {16,51}, {17,51}, {18,51}, {18,52}, {18,53}, {17,53}, {16,53}, {16,54}, {16,55}, {17,55}, {18,55}, {18,56}, {18,57}, {18,58}, {18,59}, {18,60}, {18,61}, {17,61}, {16,61}, {15,61}, {14,61}, {13,61}, {13,60}, {13,59}, {13,58}, {13,57}, {13,56}, {13,55}, {13,54}, {13,53}, {13,52}, {13,51}, {13,50}, {13,49}, {14,49}, {14,48}, {14,47}, {14,46}, {14,45}, {14,44}, {14,43}, {14,42}, {14,41}, {14,40}, {13,40}, {12,40}, {11,40}, {11,39}, {10,39}, {9,39}, {8,39}, {7,39}, {7,40}, {7,41}, {7,42}, {7,43}, {7,44}, {7,45}, {7,46}, {8,46}, {9,46}, {10,46}, {11,46}, {11,47}, {11,48}, {11,49}, {11,50}, {11,51}, {11,52}, {11,53}, {11,54}, {11,55}, {11,56}, {11,57}, {11,58}, {11,59}, {11,60}, {11,61}, {11,62}, {11,63}, {11,64}, {11,65}, {11,66}, {11,67}, {10,67}, {9,67}, {9,66}, {9,65}, {9,64}, {9,63}, {9,62}, {9,61}, {9,60}, {9,59}, {9,58}, {8,58}, {8,57}, {8,56}, {8,55}, {8,54}, {8,53}, {7,53}, {6,53}, {5,53}, {5,54}, {5,55}, {6,55}, {7,55}, {7,56}, {7,57}, {7,58}, {7,59}, {7,60}, {7,61}, {7,62}, {7,63}, {7,64}, {7,65}, {7,66}, {7,67}, {7,68}, {7,69}, {7,70}, {7,71}, {7,72}, {7,73}, {7,74}, {7,75}, {6,75}, {5,75}, {4,75}, {3,75}, {2,75}, {2,74}, {2,73}, {2,72}, {2,71}, {2,70}, {3,70}, {4,70}, {4,69}, {4,68}, {4,67}, {4,66}, {4,65}, {3,65}, {3,66}, {3,67}, {3,68}, {2,68}, {2,67}, {2,66}, {2,65}, {2,64}, {2,63}, {2,62}, {2,61}, {0, 0}}; static int animate (int xoff, int yoff) { int i, k, dx, dy, dx0, dy0, len = 1, ret = 0; Pixmap p; p = XCreatePixmap (disp, window, width, height, DefaultDepth (disp, scr)); XCopyArea (disp, pixmap, p, gc, 0, 0, width, height, 0, 0); dx0 = qix_pos[2].x - qix_pos[1].x; dy0 = qix_pos[2].y - qix_pos[1].y;; while (!XPending (disp)) ; for (i = 1; qix_pos[i].x; i++) { Pos (xoff+qix_pos[i].x, yoff+qix_pos[i].y, Qix_Head); if (i > 1) { dx = qix_pos[i].x - qix_pos[i-1].x; dy = qix_pos[i].y - qix_pos[i-1].y; if (dx == 0) { if (dy == 1) { if (dx0 == 0) Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_18); else if (dx0 == 1) Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_14); else Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_13); } else if (dy == -1) { if (dx0 == 0) Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_18); else if (dx0 == 1) Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_11); else Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_12); } } else if (dx == -1) { if (dy0 == 0) Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_1F); else if (dy0 == 1) Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_11); else Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_14); } else { /* dx = +1 */ if (dy0 == 0) Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_1F); else if (dy0 == 1) Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_12); else Pos (xoff+qix_pos[i-1].x, yoff+qix_pos[i-1].y, F_13); } dx0 = dx; dy0 = dy; } k = i - 24; if (k) { int x = yoff+qix_pos[k].y, y = xoff+qix_pos[k].x; XCopyArea (disp, p, window, gc, x*pix_width, y*pix_height, pix_width, pix_height, x*pix_width, y*pix_height); XCopyArea (disp, p, pixmap, gc, x*pix_width, y*pix_height, pix_width, pix_height, x*pix_width, y*pix_height); } if (len < 24) len++; if (refresh ()) { ret = 1; break; } usleep (20000); } XFreePixmap(disp, p); return ret; } static int refresh () { XEvent e; int ret = 0, n = XPending (disp); while (n--) { XNextEvent (disp, &e); switch (e.type) { case Expose: XCopyArea (disp, pixmap, window, gc, e.xexpose.x, e.xexpose.y, e.xexpose.width, e.xexpose.height, e.xexpose.x, e.xexpose.y); break; case KeyPress: if (key (XKeycodeToKeysym (disp, e.xkey.keycode, 0)) == K_CR) ret = 1; break; default: break; } } return ret; } void Help_Screen () { int X, Y; int w = WIDTH, h = HEIGHT; if (help_shown) return; help_shown = 1; XFillRectangle (disp, pixmap, gc, 0, 0, width, height); XFillRectangle (disp, window, gc, 0, 0, width, height); Pos (1, 1, F_13); for (Y = 2; Y < h-2; Y++) Pos (1, Y, F_18); Pos (1, h-2, F_12); for (X = 2; X < w-2; X++) Pos (X, h-2, F_1F); Pos (w-2, h-2, F_11); for (Y = h-3; Y > 1; Y--) Pos (w-2, Y, F_18); Pos (w-2, 1, F_14); for (X = w-3; X > 1; X--) Pos (X, 1, F_1F); X = (w-24)/2; /* title */ /* width is 18 chars. start at (h-18)/2 */ Y = (h-18)/2; Pos (X+3, Y++, F_13); Pos (X+3, Y++, F_18); Pos (X+3, Y++, F_18); Pos (X+3, Y++, F_12); Pos (X+3, Y++, Blank); Pos (X+3, Y++, Blank); Pos (X+3, Y++, F_18); Pos (X+3, Y++, F_1E); Pos (X+3, Y++, F_18); Pos (X+3, Y++, Blank); Pos (X+3, Y++, Blank); Pos (X+3, Y++, F_18); Pos (X+3, Y++, F_12); Pos (X+3, Y++, Blank); Pos (X+3, Y++, F_13); Pos (X+3, Y++, F_18); Y = (h-18)/2 - 1; Pos (X+4, Y++, F_13); Pos (X+4, Y++, F_11); Pos (X+4, Y++, Blank); Pos (X+4, Y++, Blank); Pos (X+4, Y++, F_1F); Pos (X+4, Y++, Blank); Pos (X+4, Y++, Blank); Pos (X+4, Y++, Blank); Pos (X+4, Y++, F_1F); Pos (X+4, Y++, Blank); Pos (X+4, Y++, Blank); Pos (X+4, Y++, Blank); Pos (X+4, Y++, Blank); Pos (X+4, Y++, F_14); Pos (X+4, Y++, F_1E); Pos (X+4, Y++, F_11); Y = (h-18)/2 - 1; Pos (X+5, Y++, F_1F); Pos (X+5, Y++, Blank); Pos (X+4, Y++, Blank); Pos (X+5, Y++, F_12); Pos (X+5, Y++, F_1F); Pos (X+5, Y++, Blank); Pos (X+5, Y++, Blank); Pos (X+5, Y++, Blank); Pos (X+5, Y++, F_1F); Pos (X+5, Y++, Blank); Pos (X+5, Y++, Blank); Pos (X+5, Y++, Blank); Pos (X+5, Y++, Blank); Pos (X+5, Y++, F_13); Pos (X+5, Y++, F_1D); Pos (X+5, Y++, F_12); Y = (h-18)/2 - 1; Pos (X+6, Y++, F_14); Pos (X+6, Y++, F_18); Pos (X+6, Y++, F_18); Pos (X+6, Y++, F_1D); Pos (X+6, Y++, F_1D); Pos (X+6, Y++, F_12); Pos (X+6, Y++, Blank); Pos (X+6, Y++, F_18); Pos (X+6, Y++, F_1D); Pos (X+6, Y++, F_18); Pos (X+6, Y++, Blank); Pos (X+6, Y++, Blank); Pos (X+6, Y++, F_18); Pos (X+6, Y++, F_11); Pos (X+6, Y++, Blank); Pos (X+6, Y++, F_14); Pos (X+6, Y++, F_18); Y = (h-18)/2 + 4; Pos (X+7, Y++, F_14); X++; /* texts */ Y = (h-18)/2 - 24; msg (X+3, Y, "You - "); XCopyArea (disp, you_pixmap, window, gc, 0, 0, pix_width, pix_height, (Y+8)*pix_width, (X+2.25)*pix_height); XCopyArea (disp, you_pixmap, pixmap, gc, 0, 0, pix_width, pix_height, (Y+8)*pix_width, (X+2.25)*pix_height); msg (X+5, Y, "Fuse - "); XCopyArea (disp, fuse_pixmap, window, gc, 0, 0, pix_width, pix_height, (Y+8)*pix_width, (X+4.25)*pix_height); XCopyArea (disp, fuse_pixmap, pixmap, gc, 0, 0, pix_width, pix_height, (Y+8)*pix_width, (X+4.25)*pix_height); msg (X+8, Y, "Fence Off The Screen Trying To Avoid The Hazzards."); msg (X+10, Y, "Hazzards : "); msg (X+10, Y+13, "Qix - Kills If Touches The Line You Are Drawing"); msg (X+11, Y+13, "Fuse - Traverses The Outside Killing On Contact"); msg (X+14, Y, "Movement : use arrow keys"); msg (X+15, Y+9, "i or 8 to go up"); msg (X+16, Y+9, "j or 4 to go left"); msg (X+17, Y+9, "l or 6 to go right"); msg (X+18, Y+9, "k or 2 to go down"); msg (X+20, Y, "Draw Fence : < Space Bar >"); Y = (h+18)/2 + 6; msg (X+3, Y, "Qix -"); msg (X+14, Y-10, "New Screen : Once 75% Fenced Off"); msg (X+16, Y-10, "Higher Scoring For Areas"); msg (X+18, Y-10, "Greater Than 75%."); msg (X+20, Y-10, "E : Exit P : Pause"); /* qix */ if (animate (X, 0)) /* XXX ok only for a 25x80 screen!!!! */ return; Y = h - 18; X = w - 1; msg (X+1, Y, "Hit < Return > To Play"); X = key_wait ((1<fid); XDrawImageString (disp, window, gc_msg, y*pix_width, x*pix_height, s, l); XDrawImageString (disp, pixmap, gc_msg, y*pix_width, x*pix_height, s, l); XSetFont(disp, gc_info, disp_font->fid); XFlush (disp); } static char key (KeySym sym) { switch (sym) { case XK_KP_Left: case XK_Left: case XK_J: case XK_j: return K_LEFT; case XK_KP_Right: case XK_Right: case XK_L: case XK_l: return K_RIGHT; case XK_KP_Up: case XK_Up: case XK_I: case XK_i: return K_UP; case XK_KP_Down: case XK_Down: case XK_K: case XK_k: return K_DOWN; case XK_P: case XK_p: return K_PAUSE; case XK_E: case XK_e: return K_EXIT; case XK_space: return K_WALL; case XK_KP_Enter: case XK_Return: return K_CR; case XK_Y: case XK_y: return K_YES; case XK_N: case XK_n: return K_NO; case XK_Shift_L: double_speed = 1; default: return K_NONE; } } char VT_getchar () { XEvent e; static unsigned char buffer[100]; static int ibuf = 0; int n, k; if (ibuf) { n = buffer[0]; bcopy (buffer+1, buffer, ibuf--); return n; } n = XPending (disp); while (n--) { XNextEvent (disp, &e); switch (e.type) { case KeyRelease: if (XKeycodeToKeysym (disp, e.xkey.keycode, 0) == XK_Shift_L) double_speed = 0; break; case KeyPress: k = key (XKeycodeToKeysym (disp, e.xkey.keycode, 0)); if (ibuf < 100 && k != K_NONE) buffer[ibuf++] = k; break; case Expose: XCopyArea (disp, pixmap, window, gc, e.xexpose.x, e.xexpose.y, e.xexpose.width, e.xexpose.height, e.xexpose.x, e.xexpose.y); break; default: break; } } if (ibuf) { n = buffer[0]; bcopy (buffer+1, buffer, ibuf--); return n; } return K_NONE; } void VT_clear () { XFillRectangle (disp, pixmap, gc, 0, 0, width, height); XFillRectangle (disp, window, gc, 0, 0, width, height); } void VT_fill_start () { filling = 1; } void VT_fill_end () { filling = 0; } void VT_beep () { XBell (disp, 0); } void VT_print_covered () { XCharStruct sizes; int dir, asc, dsc; XDrawImageString (disp, window, gc_info, 2*pix_width, height-big_font_h, "Covered", 7); XDrawImageString (disp, pixmap, gc_info, 2*pix_width, height-big_font_h, "Covered", 7); XTextExtents (disp_font, "Covered ", 9, &dir, &asc, &dsc, &sizes); x_covered = sizes.width; XTextExtents (disp_font, "00.00 ", 10, &dir, &asc, &dsc, &sizes); x_score = sizes.width + x_covered; XTextExtents (disp_font, "12345 ", 9, &dir, &asc, &dsc, &sizes); x_score2 = x_score + sizes.width; x_level = x_score2 + sizes.width; XTextExtents (disp_font, "Level ", 7, &dir, &asc, &dsc, &sizes); x_level2 = x_level + sizes.width; x_lives = x_level2 + 8*pix_width; XTextExtents (disp_font, "Paused", 6, &dir, &asc, &dsc, &sizes); x_pause = width - sizes.width - 2*pix_width; XTextExtents (disp_font, "Another game ? (Y/N)", 20, &dir, &asc, &dsc, &sizes); x_cont = width - sizes.width - 2*pix_width; XFlush (disp); } void VT_covered (double f) { char s[20]; sprintf(s, "%5.2f", f); XDrawImageString (disp, window, gc_info, 2*pix_width+x_covered, height-big_font_h, s, 5); XDrawImageString (disp, pixmap, gc_info, 2*pix_width+x_covered, height-big_font_h, s, 5); XFlush (disp); } void VT_print_score () { XDrawImageString (disp, window, gc_info, 2*pix_width+x_score, height-big_font_h, "Score", 5); XDrawImageString (disp, pixmap, gc_info, 2*pix_width+x_score, height-big_font_h, "Score", 5); XFlush (disp); } void VT_score (int a) { char s[20]; sprintf (s, "%5d", a); XDrawImageString (disp, window, gc_info, 2*pix_width+x_score2, height-big_font_h, s, 5); XDrawImageString (disp, pixmap, gc_info, 2*pix_width+x_score2, height-big_font_h, s, 5); XFlush (disp); } void VT_print_lives () { /* empty */ } void VT_lives (int l) { int x = 0; while (l--) { XCopyArea (disp, you_pixmap, window, gc, 0, 0, pix_width, pix_height, 2*pix_width+x, 0); XCopyArea (disp, you_pixmap, pixmap, gc, 0, 0, pix_width, pix_height, 2*pix_width+x, 0); x += pix_width*2; } XCopyArea (disp, blank_pixmap, window, gc, 0, 0, pix_width, pix_height, 2*pix_width+x, 0); XCopyArea (disp, blank_pixmap, pixmap, gc, 0, 0, pix_width, pix_height, 2*pix_width+x, 0); XFlush (disp); } void VT_print_level () { XDrawImageString (disp, window, gc_info, 2*pix_width+x_level, height-big_font_h, "Level", 5); XDrawImageString (disp, pixmap, gc_info, 2*pix_width+x_level, height-big_font_h, "Level", 5); XFlush (disp); } void VT_level (int level) { char s[4]; sprintf (s, "%2d", level); XDrawImageString (disp, window, gc_info, 2*pix_width+x_level2, height-big_font_h, s, 2); XDrawImageString (disp, pixmap, gc_info, 2*pix_width+x_level2, height-big_font_h, s, 2); XFlush (disp); } void top_header (char *m, int num) { char s[100]; int l = strlen (m); int w = (WIDTH-24)/2; VT_clear (); msg (w+2, (HEIGHT-l)/2, m); sprintf (s, "QIX Super League %d Game%s", num, num > 1 ? "s" : ""); l = strlen (s); msg (w+5, (HEIGHT-l)/2, s); msg (w+8, HEIGHT/2 -25, "Player Score Level Date"); } void top_entry (int e, int score, int level, char *name, char *date, int you) { char s[100]; int w = (WIDTH-24)/2; sprintf (s, "%-16s %6d %5d %s", name, score, level, date); if (you) { int l = strlen (s); XSetFont(disp, gc_you, msg_font->fid); XDrawImageString (disp, window, gc_you, (HEIGHT/2-25)*pix_width, (w+10+e)*pix_height, s, l); XDrawImageString (disp, pixmap, gc_you, (HEIGHT/2-25)*pix_width, (w+10+e)*pix_height, s, l); XSetFont(disp, gc_info, disp_font->fid); XFlush (disp); } else msg (w+10+e, HEIGHT/2-25, s); } void top_score (int score) { char s[100]; int l; int w = (WIDTH-24)/2; sprintf (s, "Your Score %d", score); l = strlen (s); msg (w+22, HEIGHT/2-7, s); } void wait_message () { VT_clear (); VT_beep (); msg (10, 10, "Please Wait ..."); sleep (5); } int terminate (char *s) { int k; if (s) { perror (s); exit (1); } XSetFont(disp, gc_pause, disp_font->fid); XDrawImageString (disp, window, gc_pause, x_cont, height-big_font_h, "Another game ? (Y/N)", 20); XDrawImageString (disp, pixmap, gc_pause, x_cont, height-big_font_h, "Another game ? (Y/N)", 20); XFlush (disp); k = key_wait ((1<fid); XDrawImageString (disp, window, gc_pause, x_pause, height-big_font_h, "Paused", 6); XDrawImageString (disp, pixmap, gc_pause, x_pause, height-big_font_h, "Paused", 6); XFlush (disp); key_wait (1<