home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
games
/
volume13
/
x4war2
/
part01
/
bgbitmap.c
next >
Wrap
C/C++ Source or Header
|
1992-08-03
|
15KB
|
357 lines
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>
#include <stdio.h>
#include "war.h"
Display *display;
int screen_num;
GC gc, undraw_gc;
Pixmap pixmap;
void main(argc, argv)
int argc;
char **argv;
{
XFontStruct *font_info;
XGCValues values;
if ((display = XOpenDisplay(NULL)) == NULL) {
fprintf(stderr, "cannot open display\n");
exit(-1);
}
screen_num = DefaultScreen(display);
pixmap = XCreatePixmap(display, RootWindow(display, screen_num),
DIMENSION, DIMENSION, 1);
font_info = XLoadQueryFont(display, "9x15bold");
values.arc_mode = ArcChord;
values.foreground = 0;
values.background = 1;
undraw_gc = XCreateGC(display, pixmap, GCForeground | GCBackground |
GCArcMode, &values);
values.foreground = 1;
values.background = 0;
values.font = font_info->fid;
gc = XCreateGC(display, pixmap, GCForeground|GCBackground|GCFont,
&values);
printf("'war_background.xbm' file will be created at ./bitmaps\n");
printf("please wait a second...\n");
draw();
XWriteBitmapFile(display, "war_background", pixmap,
DIMENSION, DIMENSION, -1, -1);
system("mv ./war_background ./bitmaps/war_background.xbm");
printf("completed!\n");
XUnloadFont(display, font_info->fid);
XFreeGC(display, gc);
XFreeGC(display, undraw_gc);
XCloseDisplay(display);
exit(0);
}
draw()
{
static unsigned char dash_list[] = {10, 10};
int i, j;
XFillRectangle(display, pixmap, undraw_gc, 0, 0, DIMENSION, DIMENSION);
XDrawString(display, pixmap, gc, 110, 575, "DEATH ANGEL", 11);
XDrawString(display, pixmap, gc, 695, 628, "NEW GAME", 8);
XDrawString(display, pixmap, gc, 695, 668, "START WAR", 9);
XDrawString(display, pixmap, gc, 695, 708, "REDEPLOY", 8);
XDrawString(display, pixmap, gc, 695, 748, "PEACE", 5);
XDrawString(display, pixmap, gc, 695, 788, "SURRENDER", 9);
XDrawString(display, pixmap, gc, 695, 828, "QUIT", 4);
XSetLineAttributes(display, gc, 5, LineOnOffDash, CapButt, JoinMiter);
XSetDashes(display, gc, 0, dash_list, 2);
XDrawLine(display, pixmap, gc, P3, P1+50, P3, P6-50);
XDrawLine(display, pixmap, gc, P4, P1+50, P4, P6-50);
XDrawLine(display, pixmap, gc, P1+50, P3, P6-50, P3);
XDrawLine(display, pixmap, gc, P1+50, P4, P6-50, P4);
XDrawLine(display, pixmap, gc, P3, P1+50, P4, P1+50);
XDrawLine(display, pixmap, gc, P3, P2, P4, P2);
XDrawLine(display, pixmap, gc, P3, P5, P4, P5);
XDrawLine(display, pixmap, gc, P3, P6-50, P4, P6-50);
XDrawLine(display, pixmap, gc, P1+50, P3, P1+50, P4);
XDrawLine(display, pixmap, gc, P2, P3, P2, P4);
XDrawLine(display, pixmap, gc, P5, P3, P5, P4);
XDrawLine(display, pixmap, gc, P6-50, P3, P6-50, P4);
XDrawLine(display, pixmap, gc, P2, P3+100, P5, P3+100);
XDrawLine(display, pixmap, gc, P3+100, P2, P3+100, P5);
XDrawArc(display, pixmap, gc, P2-50, P2-50, 100, 100, 0, -90*64);
XDrawArc(display, pixmap, gc, P4, P2-50, 100, 100, 180*64, 90*64);
XDrawArc(display, pixmap, gc, P2-50, P4, 100, 100, 0, 90*64);
XDrawArc(display, pixmap, gc, P4, P4, 100, 100, 90*64, 90*64);
XSetLineAttributes(display, gc, 1, LineSolid, CapButt, JoinRound);
XDrawArc(display, pixmap, gc, P2-52, P2-52, 104, 104, 0, -90*64);
XDrawArc(display, pixmap, gc, P2-48, P2-48, 96, 96, 0, -90*64);
XDrawArc(display, pixmap, gc, P4-2, P2-52, 104, 104, 180*64, 90*64);
XDrawArc(display, pixmap, gc, P4+2, P2-48, 96, 96, 180*64, 90*64);
XDrawArc(display, pixmap, gc, P2-52, P4-2, 104, 104, 0, 90*64);
XDrawArc(display, pixmap, gc, P2-48, P4+2, 96, 96, 0, 90*64);
XDrawArc(display, pixmap, gc, P4-2, P4-2, 104, 104, 90*64, 90*64);
XDrawArc(display, pixmap, gc, P4+2, P4+2, 96, 96, 90*64, 90*64);
XDrawLine(display, pixmap, gc, P3-2, P1+50, P3-2, P6-50);
XDrawLine(display, pixmap, gc, P3+2, P1+50, P3+2, P6-50);
XDrawLine(display, pixmap, gc, P4-2, P1+50, P4-2, P6-50);
XDrawLine(display, pixmap, gc, P4+2, P1+50, P4+2, P6-50);
XDrawLine(display, pixmap, gc, P1+50, P3-2, P6-50, P3-2);
XDrawLine(display, pixmap, gc, P1+50, P3+2, P6-50, P3+2);
XDrawLine(display, pixmap, gc, P1+50, P4-2, P6-50, P4-2);
XDrawLine(display, pixmap, gc, P1+50, P4+2, P6-50, P4+2);
XDrawLine(display, pixmap, gc, P3, P1+48, P4, P1+48);
XDrawLine(display, pixmap, gc, P3, P1+52, P4, P1+52);
XDrawLine(display, pixmap, gc, P3, P2-2, P4, P2-2);
XDrawLine(display, pixmap, gc, P3, P2+2, P4, P2+2);
XDrawLine(display, pixmap, gc, P3, P5-2, P4, P5-2);
XDrawLine(display, pixmap, gc, P3, P5+2, P4, P5+2);
XDrawLine(display, pixmap, gc, P3, P6-52, P4, P6-52);
XDrawLine(display, pixmap, gc, P3, P6-48, P4, P6-48);
XDrawLine(display, pixmap, gc, P1+48, P3, P1+48, P4);
XDrawLine(display, pixmap, gc, P1+52, P3, P1+52, P4);
XDrawLine(display, pixmap, gc, P2-2, P3, P2-2, P4);
XDrawLine(display, pixmap, gc, P2+2, P3, P2+2, P4);
XDrawLine(display, pixmap, gc, P5-2, P3, P5-2, P4);
XDrawLine(display, pixmap, gc, P5+2, P3, P5+2, P4);
XDrawLine(display, pixmap, gc, P6-48, P3, P6-48, P4);
XDrawLine(display, pixmap, gc, P6-52, P3, P6-52, P4);
XDrawLine(display, pixmap, gc, P2, P3+98, P5, P3+98);
XDrawLine(display, pixmap, gc, P2, P3+102, P5, P3+102);
XDrawLine(display, pixmap, gc, P3+98, P2, P3+98, P5);
XDrawLine(display, pixmap, gc, P3+102, P2, P3+102, P5);
for (i=RIP_Y+50; i<RIP_Y+RIP_DIMENSION; i += 50)
XDrawLine(display, pixmap, gc, P1, i, P1+RIP_DIMENSION, i);
for (i=P1+50; i<P1+RIP_DIMENSION; i += 50)
XDrawLine(display, pixmap, gc, i, RIP_Y, i, RIP_Y+RIP_DIMENSION);
for (i=P3+50; i<P4; i += 50)
XDrawLine(display, pixmap, gc, i, P5, i, P6);
for (i=P5+50; i<P6-50; i += 50)
XDrawLine(display, pixmap, gc, P3, i, P4, i);
XDrawLine(display, pixmap, gc, P3, P5, P4, P6-50);
XDrawLine(display, pixmap, gc, P3, P5+100, P3+100, P6-50);
XDrawLine(display, pixmap, gc, P3+100, P5, P4, P5+100);
XDrawLine(display, pixmap, gc, P3, P6-50, P4, P5);
XDrawLine(display, pixmap, gc, P3, P5+100, P3+100, P5);
XDrawLine(display, pixmap, gc, P3+100, P6-50, P4, P5+100);
for (i=P3+50; i<P4; i += 50)
XDrawLine(display, pixmap, gc, i, P1, i, P2);
for (i=P1+100; i<P2; i += 50)
XDrawLine(display, pixmap, gc, P3, i, P4, i);
XDrawLine(display, pixmap, gc, P3, P1+50, P4, P2);
XDrawLine(display, pixmap, gc, P3, P2-100, P3+100, P2);
XDrawLine(display, pixmap, gc, P3+100, P1+50, P4, P2-100);
XDrawLine(display, pixmap, gc, P3, P2-100, P3+100, P1+50);
XDrawLine(display, pixmap, gc, P3, P2, P4, P1+50);
XDrawLine(display, pixmap, gc, P3+100, P2, P4, P2-100);
for (i=P3+50; i<P4; i += 50)
XDrawLine(display, pixmap, gc, P1, i, P2, i);
for (i=P1+100; i<P2; i += 50)
XDrawLine(display, pixmap, gc, i, P3, i, P4);
XDrawLine(display, pixmap, gc, P1+50, P3+100, P2-100, P4);
XDrawLine(display, pixmap, gc, P1+50, P3, P2, P4);
XDrawLine(display, pixmap, gc, P2-100, P3, P2, P3+100);
XDrawLine(display, pixmap, gc, P1+50, P3+100, P2-100, P3);
XDrawLine(display, pixmap, gc, P2, P3, P1+50, P4);
XDrawLine(display, pixmap, gc, P2-100, P4, P2, P3+100);
for (i=P3+50; i<P4; i += 50)
XDrawLine(display, pixmap, gc, P5, i, P6, i);
for (i=P5+50; i<P6-50; i += 50)
XDrawLine(display, pixmap, gc, i, P3, i, P4);
XDrawLine(display, pixmap, gc, P5, P3+100, P5+100, P4);
XDrawLine(display, pixmap, gc, P5, P3, P6-50, P4);
XDrawLine(display, pixmap, gc, P5+100, P3, P6-50, P3+100);
XDrawLine(display, pixmap, gc, P5, P3+100, P5+100, P3);
XDrawLine(display, pixmap, gc, P5, P4, P6-50, P3);
XDrawLine(display, pixmap, gc, P5+100, P4, P6-50, P3+100);
XSetLineAttributes(display, gc, 3, LineSolid, CapButt, JoinRound);
XDrawRectangle(display, pixmap, gc, TALK_L_X,TALK_Y,TALK_WIDTH,TALK_HEIGHT);
XDrawRectangle(display, pixmap, gc, TALK_L_X, TALK_Y+90,
TALK_WIDTH, TALK_HEIGHT);
XDrawRectangle(display, pixmap, gc, TALK_R_X,TALK_Y,TALK_WIDTH,TALK_HEIGHT);
XDrawRectangle(display, pixmap, gc, TALK_R_X, TALK_Y+90,
TALK_WIDTH, TALK_HEIGHT);
XDrawRectangle(display, pixmap, gc, P1, P1, 66, 66);
XDrawRectangle(display, pixmap, gc, MSG_BOX_X, MSG_BOX_Y,
MSG_WIDTH, MSG_HEIGHT);
XDrawLine(display, pixmap, gc, P3-1, P1-1, P3-1, P1+50);
XDrawLine(display, pixmap, gc, P4+1, P1-1, P4+1, P1+50);
XDrawLine(display, pixmap, gc, P3-1, P1-1, P4+1, P1-1);
XDrawLine(display, pixmap, gc, P3-1, P6-50, P3-1, P6+1);
XDrawLine(display, pixmap, gc, P4+1, P6-50, P4+1, P6+1);
XDrawLine(display, pixmap, gc, P3-1, P6+1, P4+1, P6+1);
XDrawLine(display, pixmap, gc, P6-50, P3-1, P6+1, P3-1);
XDrawLine(display, pixmap, gc, P6-50, P4+1, P6+1, P4+1);
XDrawLine(display, pixmap, gc, P6+1, P3-1, P6+1, P4+1);
XDrawLine(display, pixmap, gc, P1-1, P3-1, P1+50, P3-1);
XDrawLine(display, pixmap, gc, P1-1, P4+1, P1+50, P4+1);
XDrawLine(display, pixmap, gc, P1-1, P3-1, P1-1, P4+1);
XDrawRectangle(display, pixmap, gc, P1, RIP_Y,
RIP_DIMENSION-1,RIP_DIMENSION-1);
for (i=NEW_Y; i<=NEW_Y+BUTTON_DIS*5; i += BUTTON_DIS)
XDrawRectangle(display, pixmap, gc, BUTTON_X, i,
BUTTON_WIDTH, BUTTON_HEIGHT);
XSetLineAttributes(display, gc, 2, LineSolid, CapButt, JoinRound);
XFillArc(display, pixmap, undraw_gc, P3+30, P1+80, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P3+30, P1+80, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P4-70, P1+80, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P4-70, P1+80, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P3+80, P2-120, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P3+80, P2-120, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P3+30, P2-70, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P3+30, P2-70, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P4-70, P2-70, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P4-70, P2-70, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P5+30, P3+30, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P5+30, P3+30, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P5+30, P4-70, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P5+30, P4-70, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P5+80, P3+80, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P5+80, P3+80, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P6-120, P3+30, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P6-120, P3+30, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P6-120, P4-70, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P6-120, P4-70, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P1+80, P3+30, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P1+80, P3+30, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P1+80, P4-70, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P1+80, P4-70, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P1+130, P3+80, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P1+130, P3+80, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P2-70, P3+30, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P2-70, P3+30, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P2-70, P4-70, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P2-70, P4-70, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P3+30, P5+30, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P3+30, P5+30, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P3+30, P6-120, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P3+30, P6-120, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P3+80, P5+80, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P3+80, P5+80, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P4-70, P5+30, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P4-70, P5+30, 40, 40, 0, 360*64);
XFillArc(display, pixmap, undraw_gc, P4-70, P6-120, 40, 40, 0, 360*64);
XDrawArc(display, pixmap, gc, P4-70, P6-120, 40, 40, 0, 360*64);
for (i=P3-15; i<P4; i += 100)
for (j=P3-15; j<P4; j += 100) {
XFillRectangle(display, pixmap, undraw_gc, i, j, 30, 30);
XDrawRectangle(display, pixmap, gc, i, j, 29, 29);
}
for (i=P3-20; i<P4; i += 50)
for (j=P5-10; j<P6; j += 50)
if (i==P3+30 && j==P5+40 || i==P4-70 && j==P5+40 ||
i==P3+80 && j==P5+90 ||
i==P3+30 && j==P6-110 || i==P4-70 && j==P6-110 )
;
else {
XFillRectangle(display, pixmap, undraw_gc, i, j, 40, 20);
XDrawRectangle(display, pixmap, gc, i, j, 40, 20);
}
for (i=P3-20; i<P4; i += 50)
for (j=P1-10; j<P2; j += 50)
if (i==P3+30 && j==P1+90 || i==P4-70 && j==P1+90 ||
i==P3+80 && j==P2-110 ||
i==P3+30 && j==P2-60 || i==P4-70 && j==P2-60 )
;
else {
XFillRectangle(display, pixmap, undraw_gc, i, j, 40, 20);
XDrawRectangle(display, pixmap, gc, i, j, 40, 20);
}
for (i=P1-10; i<P2; i += 50)
for (j=P3-20; j<P4; j += 50)
if (i==P1+90 && j==P3+30 || i==P2-60 && j==P3+30 ||
i==P2-110 && j==P3+80 ||
i==P1+90 && j==P4-70 || i==P2-60 && j==P4-70)
;
else {
XFillRectangle(display, pixmap, undraw_gc, i, j, 20, 40);
XDrawRectangle(display, pixmap, gc, i, j, 20, 40);
}
for (i=P5-10; i<P6; i += 50)
for (j=P3-20; j<P4; j += 50)
if (i==P5+40 && j==P3+30 || i==P6-110 && j==P3+30 ||
i==P5+90 && j==P3+80 ||
i==P5+40 && j==P4-70 || i==P6-110 && j==P4-70)
;
else {
XFillRectangle(display, pixmap, undraw_gc, i, j, 20, 40);
XDrawRectangle(display, pixmap, gc, i, j, 20, 40);
}
XFillArc(display, pixmap, undraw_gc, P3+35, P1-14, 30, 30, 210*64, 120*64);
XDrawArc(display, pixmap, gc, P3+35, P1-14, 30, 30, 215*64, 110*64);
XFillArc(display, pixmap, undraw_gc, P4-65, P1-14, 30, 30, 210*64, 120*64);
XDrawArc(display, pixmap, gc, P4-65, P1-14, 30, 30, 215*64, 110*64);
XFillArc(display, pixmap, undraw_gc, P3+35, P6-16, 30, 30, 30*64, 120*64);
XDrawArc(display, pixmap, gc, P3+35, P6-16, 30, 30, 35*64, 110*64);
XFillArc(display, pixmap, undraw_gc, P4-65, P6-16, 30, 30, 30*64, 120*64);
XDrawArc(display, pixmap, gc, P4-65, P6-16, 30, 30, 35*64, 110*64);
XFillArc(display, pixmap, undraw_gc, P1-14, P3+35, 30, 30, 60*64, -120*64);
XDrawArc(display, pixmap, gc, P1-14, P3+35, 30, 30, 55*64, -110*64);
XFillArc(display, pixmap, undraw_gc, P1-14, P4-65, 30, 30, 60*64, -120*64);
XDrawArc(display, pixmap, gc, P1-14, P4-65, 30, 30, 55*64, -110*64);
XFillArc(display, pixmap, undraw_gc, P6-16, P3+35, 30, 30, 120*64, 120*64);
XDrawArc(display, pixmap, gc, P6-16, P3+35, 30, 30, 125*64, 110*64);
XFillArc(display, pixmap, undraw_gc, P6-16, P4-65, 30, 30, 120*64, 120*64);
XDrawArc(display, pixmap, gc, P6-16, P4-65, 30, 30, 125*64, 110*64);
}