[comp.windows.x] new life

PGRUBER@luke.dnet.ge.COM (09/22/90)

To those how are interested in a different life:

  Below is a 'diff -c' of the life.c file, include with xlock, and a modified
  verison, hobbesLife.c, that will display the hobbes character.
  Also the bitmap of hobbes is included and a list of lines added to xlock.c
  to accept the new bitmap.
  
  Steps: 1) make necessary changes, add new file name (.c &.o) to Makefile 
	 2) do a makedepend, and 3) do a make xlock


Pat 
Patrick Gruber 	
GE			phone (609) 338-2866
Front and Cooper Sts.
Camden, NJ. 08102		email PGRUBER%LUKE.DECNET@CRD.GE.COM
  
*** life.c	Mon Sep 25 11:18:10 1989
--- hobbesLife.c	Thu Jul 19 08:02:09 1990
***************
*** 36,42 ****
  #include <X11/Xos.h>
  #include <X11/Xlib.h>
  #include <X11/Xutil.h>
! #include "lifeicon.bit";
  
  static XImage logo = {
      0, 0,			/* width, height */
--- 36,42 ----
  #include <X11/Xos.h>
  #include <X11/Xlib.h>
  #include <X11/Xutil.h>
! #include "hobbes";
  
  static XImage logo = {
      0, 0,			/* width, height */
***************
*** 317,323 ****
      else
  	XPutImage(Dsp, Win, Gc, &logo,
  		  0, 0, xb + xs * col, yb + ys * row,
! 		  lifeicon_width, lifeicon_height);
  }
  
  static void
--- 317,323 ----
      else
  	XPutImage(Dsp, Win, Gc, &logo,
  		  0, 0, xb + xs * col, yb + ys * row,
! 		  hobbes_width, hobbes_height);
  }
  
  static void
***************
*** 376,382 ****
  }
  
  void
! drawlife()
  {
      unsigned char *loc,
                 *temploc;
--- 376,382 ----
  }
  
  void
! drawhobbes()
  {
      unsigned char *loc,
                 *temploc;
***************
*** 456,462 ****
  }
  
  void
! initlife(d, w, g, c, t, n)
      Display    *d;
      Window      w;
      GC          g;
--- 456,462 ----
  }
  
  void
! inithobbes(d, w, g, c, t, n)
      Display    *d;
      Window      w;
      GC          g;
***************
*** 486,494 ****
  
  	srandom(time((long *) 0));
  	init_fates();
! 	logo.data = lifeicon_bits;
! 	logo.width = lifeicon_width;
! 	logo.height = lifeicon_height;
  	logo.bytes_per_line = 4;
      }
      if (!color)
--- 486,494 ----
  
  	srandom(time((long *) 0));
  	init_fates();
! 	logo.data = hobbes_bits;
! 	logo.width = hobbes_width;
! 	logo.height = hobbes_height;
  	logo.bytes_per_line = 4;
      }
      if (!color)
***************
*** 501,507 ****
      ys = height / NROWS;
      xb = (width - xs * NCOLS) / 2;
      yb = (height - ys * NROWS) / 2;
!     pixels = (xs < lifeicon_width || ys < lifeicon_height);
  
      XFillRectangle(Dsp, Win, eraseGC, 0, 0, width, height);
  
--- 501,507 ----
      ys = height / NROWS;
      xb = (width - xs * NCOLS) / 2;
      yb = (height - ys * NROWS) / 2;
!     pixels = (xs < hobbes_width || ys < hobbes_height);
  
      XFillRectangle(Dsp, Win, eraseGC, 0, 0, width, height);
  
***************
*** 518,524 ****
  }
  
  int
! lifedone()
  {
      int         elapsedTime = seconds() - startTime;
  
--- 518,524 ----
  }
  
  int
! hobbesdone()
  {
      int         elapsedTime = seconds() - startTime;
  

The following lines where added to xlock.c

   122  extern void inithobbes();
   123  extern int  hobbesdone();
   124  extern void drawhobbes();

   134      {"hobbes", hobbesdone, drawhobbes, inithobbes}

hobbes bit map copy for network

#define hobbes_width 25
#define hobbes_height 25
#define hobbes_x_hot 16
#define hobbes_y_hot 15
static char hobbes_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00,
   0x78, 0xe0, 0x07, 0x00, 0xfc, 0xf8, 0x07, 0x00, 0xcc, 0x07, 0x04, 0x00,
   0x0c, 0xf0, 0x0b, 0x00, 0x7c, 0x1c, 0x06, 0x00, 0x38, 0x00, 0x00, 0x00,
   0xe0, 0x03, 0x10, 0x00, 0xe0, 0x41, 0x11, 0x00, 0x20, 0x40, 0x11, 0x00,
   0xe0, 0x07, 0x10, 0x00, 0xe0, 0xc1, 0x17, 0x00, 0x10, 0xe0, 0x2f, 0x00,
   0x20, 0xe0, 0x6f, 0x00, 0x18, 0xe0, 0x2f, 0x00, 0x20, 0xc6, 0x67, 0x00,
   0x18, 0x84, 0x2b, 0x00, 0x20, 0x08, 0x64, 0x00, 0x70, 0xf0, 0x13, 0x00,
   0x80, 0x01, 0x08, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00};