+static void *
+blaster_init (Display *d, Window w)
+{
+ struct state *st = (struct state *) calloc (1, sizeof(*st));
+ XGCValues gcv;
+ Colormap cmap;
+ unsigned long bg;
+
+ st->dpy = d;
+ st->window = w;
+ XGetWindowAttributes(st->dpy, st->window, &st->xgwa);
+ cmap = st->xgwa.colormap;
+
+ st->NUM_ROBOTS=5;
+ st->NUM_LASERS=3;
+
+ st->MOTHER_SHIP_WIDTH=25;
+ st->MOTHER_SHIP_HEIGHT=7;
+ st->MOTHER_SHIP_LASER=15;
+ st->MOTHER_SHIP_PERIOD=150;
+ st->MOTHER_SHIP_HITS=10;
+
+ st->RANDOM_MOVE_STYLE=1;
+ st->NUM_MOVE_STYLES=2;
+
+ st->EXPLODE_SIZE_1=27;
+ st->EXPLODE_SIZE_2=19;
+ st->EXPLODE_SIZE_3=7;
+
+
+ st->delay = get_integer_resource(st->dpy, "delay", "Integer");
+ if(st->delay==0) {
+ st->delay=10000;
+ }
+ st->NUM_ROBOTS = get_integer_resource(st->dpy, "num_robots","Integer");
+ if(st->NUM_ROBOTS==0) {
+ st->NUM_ROBOTS=5;
+ }
+ st->NUM_LASERS = get_integer_resource(st->dpy, "num_lasers","Integer");
+ st->EXPLODE_SIZE_1 = get_integer_resource(st->dpy, "explode_size_1","Integer");
+ st->EXPLODE_SIZE_2 = get_integer_resource(st->dpy, "explode_size_2","Integer");
+ st->EXPLODE_SIZE_3 = get_integer_resource(st->dpy, "explode_size_3","Integer");
+
+ st->NUM_STARS = get_integer_resource(st->dpy, "num_stars","Integer");
+ if(get_boolean_resource(st->dpy, "move_stars","Boolean")) {
+ st->MOVE_STARS = 1;
+ st->MOVE_STARS_X = get_integer_resource(st->dpy, "move_stars_x","Integer");
+ st->MOVE_STARS_Y = get_integer_resource(st->dpy, "move_stars_y","Integer");
+ st->MOVE_STARS_RANDOM = get_integer_resource(st->dpy, "move_stars_random","Integer");
+ }
+ else {
+ st->MOVE_STARS = 0;
+ }
+
+
+ bg = get_pixel_resource(st->dpy, cmap, "background","Background");
+ gcv.function = GXcopy;
+
+#define make_gc(color,name) \
+ gcv.foreground = get_pixel_resource (st->dpy, cmap, (name), "Foreground"); \
+ color = XCreateGC (st->dpy, st->window, GCForeground|GCFunction, &gcv)
+
+ if(mono_p) {
+ gcv.foreground = bg;
+ st->black = XCreateGC(st->dpy, st->window, GCForeground|GCFunction, &gcv);
+ gcv.foreground = get_pixel_resource(st->dpy, cmap, "foreground", "Foreground");
+ st->r_color0 = st->r_color1 = st->r_color2 = st->r_color3 = st->r_color4 = st->r_color5 = st->l_color0 = st->l_color1 = st->s_color=
+ XCreateGC(st->dpy, st->window, GCForeground|GCFunction, &gcv);
+ if(get_boolean_resource(st->dpy, "mother_ship","Boolean")) {
+ st->MOTHER_SHIP_WIDTH=get_integer_resource(st->dpy, "mother_ship_width","Integer");
+ st->MOTHER_SHIP_HEIGHT=get_integer_resource(st->dpy, "mother_ship_height","Integer");
+ st->MOTHER_SHIP_LASER=get_integer_resource(st->dpy, "mother_ship_laser","Integer");
+ st->MOTHER_SHIP_PERIOD=get_integer_resource(st->dpy, "mother_ship_period","Integer");
+ st->MOTHER_SHIP_HITS=get_integer_resource(st->dpy, "mother_ship_hits","Integer");
+ st->MOTHER_SHIP=1;
+ st->mother = (struct mother_ship_state *) malloc(sizeof(struct mother_ship_state));
+ st->mother->lasers = (struct laser_state *) malloc(8*sizeof(struct laser_state));
+ st->mother->active = 0;
+ st->mother->death = 0;
+ st->mother->ship_color = st->r_color0;
+ st->mother->laser_color = st->r_color0;
+ }
+ }
+ else {
+ if(get_boolean_resource(st->dpy, "mother_ship","Boolean")) {
+ st->MOTHER_SHIP_WIDTH=get_integer_resource(st->dpy, "mother_ship_width","Integer");
+ st->MOTHER_SHIP_HEIGHT=get_integer_resource(st->dpy, "mother_ship_height","Integer");
+ st->MOTHER_SHIP_LASER=get_integer_resource(st->dpy, "mother_ship_laser","Integer");
+ st->MOTHER_SHIP_PERIOD=get_integer_resource(st->dpy, "mother_ship_period","Integer");
+ st->MOTHER_SHIP_HITS=get_integer_resource(st->dpy, "mother_ship_hits","Integer");
+ st->MOTHER_SHIP=1;
+ st->mother = (struct mother_ship_state *) malloc(sizeof(struct mother_ship_state));
+ st->mother->lasers = (struct laser_state *) malloc(8*sizeof(struct laser_state));
+ st->mother->active = 0;
+ st->mother->death = 0;
+ make_gc(st->mother->ship_color,"mother_ship_color0");
+ make_gc(st->mother->laser_color,"mother_ship_color1");
+ }