1 --- xasteroids-5.0.orig/xast.c
2 +++ xasteroids-5.0/xast.c
7 + Changes after version 5.0:
9 + Improved cursor-hiding.
12 + Use usleep() instead of a delay loop, when available.
14 Changes from version 4.3:
18 Pat Ryan <pat@jaameri.gsfc.nasa.gov>
19 Craig Smith <csmith@cscs.UUCP>
20 Doug Merritt <doug@netcom.com>
21 + Stephen McCamant <alias@mcs.com>
22 Makefile by James Berg <berg@plains>
23 Hi score script by Chris Moore <moore@src.bae.co.uk>
24 Man page by David Partain <dpl@ida.liu.se>
26 #include <stdio.h> /* For NULL */
27 +#include <stdlib.h> /* For malloc(), rand() etc */
28 +#include <time.h> /* For time() */
30 #include <X11/Xutil.h>
31 -#include <X11/cursorfont.h> /* For erasing cursor - not important */
32 +#include <X11/keysym.h>
43 +#define rand(rndint) rand() /* ??? */
45 /* Indexes for 1st dimension of obj */
46 /* The order they are in is important */
53 -#define PAUSE 27 /* escape */
57 +#define PAUSE XK_Escape /* escape */
58 +#define SHIELD XK_grave /* ` */
61 #define BMAX 300 /* Max particles in a "boom" + 1 */
62 #define letheight 20 /* height of font */
64 shapesize[LASTSHAPE+1] = {44, 21, 10, 2, 1, SHIPSIZE+1, 35, 20},
70 extern Objtype obj[SHIP+1];
72 obj[i].mass = M_BULLET;
78 extern Objtype obj[SHIP+1];
81 obj[i].y = (double) a;
82 else obj[i].y = (double) height - a;
83 - a = rand(rndint); a = 4 - a>>5;
84 + a = rand(rndint); a = 4 - (a>>5);
85 obj[i].rot = (double) a;
87 obj[i].rotvel = ((double) a)/2048;
93 makeenemy() /* Start an enemy ship */
94 { extern Objtype obj[SHIP+1];
95 extern int height, level, rndint;
101 blastpair(i, j) /* Generate random velocity vector v. */
102 int i, j ; /* Add v to i, -v to j. */
107 /* c = 4 - c>>5; if you need angles from -3 to 4 */
108 - c>>2; /* possibly save some time on sin/cos */
109 + c >>= 2; /* possibly save some time on sin/cos */
110 vx = cos((double) c); vy = sin((double) c);
111 obj[i].xvel = obj[i].xvel + vx;
112 obj[i].yvel = obj[i].yvel + vy;
114 #define rotinert(i) (double) (obj[i].mass*shapesize[obj[i].shape]*shapesize[obj[i].shape])
116 /* cause two objects to collide elastically */
122 obj[j].rotvel = temp;
126 botline(disp, window, gc) /* Print status line text */
134 printss(disp, window, gc) /* Print ships and score */
138 XClearArea(disp, window, 340+(energy>>1), height+8, 8, 10, False);
142 upscore(killer, up) /* Only award score for things the player shot */
148 /* boom, movebooms, drawbooms all by Peter Phillips */
150 boom(ob, particles, duration)
156 /* move the various booms that are active */
164 /* Draw the various booms */
166 drawbooms(disp, window, gc)
174 deletebooms() /* delete all booms */
177 @@ -490,11 +522,12 @@
183 int killer, i; /* i = Asteroid # to kill */
184 { extern Objtype obj[SHIP+1];
187 + int k, na = 0, oldna;
189 if (obj[i].shape == ASTSHAPE1)
190 { na = nextast(); /* Could put 6 lines in a sub */
193 obj[i].alive = 0; upscore(killer, 500);}
199 { extern Objtype obj[SHIP+1];
206 { extern Objtype obj[SHIP+1];
207 extern int width, nextbul;
209 nextbul++; if (nextbul == LASTBUL+1) nextbul = FBUL;
214 { extern Objtype obj[SHIP+1];
215 extern int width, height, rndint;
217 obj[SHIP].y = (double) i;
221 vdraw(disp, window, gc, shape, x, y, rot)
225 XDrawLines (disp, window, gc, figure, numpairs[shape], CoordModePrevious);
233 extern int level, numasts, rndint, ships, score, oldscore;
234 extern Objtype obj[SHIP+1];
235 unsigned char c; /* for rand */
236 - double *temp, dx, dy, dist;
237 - int crashed, flashon, len, pause = 0, delay = 64,
238 + double dx, dy, dist;
239 + int crashed, flashon, pause = 0, delay = 64,
240 enemycount, counter, counterstart = 1,
241 i, /* index for drawing objs, counting bullets */
242 r; /* radius of shield circle */
243 @@ -704,11 +743,30 @@
244 KeyPressMask | KeyReleaseMask | StructureNotifyMask);
245 XMapRaised (disp, window);
247 - /* Erase cursor. Just delete next 5 lines if any error. */
248 + /* Make cursor invisible. Just delete chunk if any error. */
249 cmap = XDefaultColormap(disp, screen);
250 XAllocNamedColor(disp, cmap, "Black", &exact, &black);
251 +#if 0 /* Easy way, but can leave a black spot */
252 +#include <X11/cursorfont.h>
253 cursor = XCreateFontCursor(disp, XC_dot);
254 XRecolorCursor(disp, cursor, &black, &black);
255 +#else /* Hard, good way */
259 + XQueryBestCursor(disp, window, 1, 1, &wd, &ht);
260 + pm = XCreatePixmap(disp, window, wd, ht, 1);
261 + maskpm = XCreatePixmap(disp, window, wd, ht, 1);
262 + cleargc = XCreateGC(disp, pm, 0, 0);
263 + XFillRectangle(disp, pm, cleargc, 0, 0, wd, ht);
264 + XFillRectangle(disp, maskpm, cleargc, 0, 0, wd, ht);
265 + cursor = XCreatePixmapCursor(disp, pm, maskpm,
266 + &black, &black, 1, 1);
267 + XFreePixmap(disp, pm);
268 + XFreePixmap(disp, maskpm);
269 + XFreeGC(disp, cleargc);
272 XDefineCursor(disp, window, cursor);
274 XFillRectangle (disp, pixmap, pmgc, 0, 0, width, height);
276 { XNextEvent(disp, &event);
278 { case MappingNotify:
279 - XRefreshKeyboardMapping (&event);
280 + XRefreshKeyboardMapping ((XMappingEvent *)&event);
282 case ConfigureNotify:
283 width = event.xconfigure.width;
284 @@ -757,28 +815,29 @@
285 botline(disp, window, gc);
288 - len = XLookupString (&event, text, 10, &key, 0);
289 - if (len == 1 && !shield_on) switch (text[0])
291 + key = XLookupKeysym ((XKeyEvent *)&event, 0);
292 + if (!shield_on) switch (key)
293 + { case XK_Left: case XK_e:
294 obj[SHIP].rotvel = obj[SHIP].rotvel - .1; break;
296 + case XK_Right: case XK_r:
297 obj[SHIP].rotvel = obj[SHIP].rotvel + .1; break;
300 obj[SHIP].rot -= pi/4; break;
303 obj[SHIP].rot += pi/4; break;
306 obj[SHIP].rotvel = obj[SHIP].rotvel - .02; break;
309 obj[SHIP].rotvel = obj[SHIP].rotvel + .02; break;
311 + case XK_Up: case THRUST:
312 obj[SHIP].xvel += cos(obj[SHIP].rot);
313 obj[SHIP].yvel += sin(obj[SHIP].rot);
314 obj[SHIP].shape = SHIPTHRSHAPE;
316 + case XK_Control_L: case XK_Control_R:
318 if (obj[SHIP].alive) fire(); break;
322 { hyper(); flashon = 1;
323 /* NOT XSetForeground (disp, gc, bg);
324 @@ -787,35 +846,37 @@
325 XFillRectangle (disp, pixmap, pmgc, 0, 0, width, height);
329 + case XK_Down: case SHIELD:
332 obj[SHIP].shape = SHIPSHAPE;}
334 - case '.': /* decrease delay */
335 + case XK_period: /* decrease delay */
336 if (delay > 1) delay >>=1; break;
337 - case ',': /* increase delay */
338 + case XK_comma: /* increase delay */
340 - case 'm': /* decrease drawscale - may go negative */
341 + case XK_m: /* decrease drawscale - may go negative */
342 drawscale -= .1; break;
343 - case 'n': /* increase drawscale */
344 + case XK_n: /* increase drawscale */
345 drawscale += .1; break;
346 - case '2': /* increase speedscale */
347 + case XK_2: /* increase speedscale */
348 speedscale += .1; break;
349 - case '1': /* decrease speedscale */
350 + case XK_1: /* decrease speedscale */
351 speedscale -= .1; break;
352 - case 'b': /* increase moves/update */
353 + case XK_b: /* increase moves/update */
354 counterstart++; break;
355 - case 'v': /* decrease moves/update */
356 + case XK_v: /* decrease moves/update */
357 if (counterstart > 1) counterstart--;
359 case PAUSE: /* pause */
360 pause = 1 - pause; break;
361 - case '+': /* cheat */
362 + case XK_plus: /* cheat */
363 ships++; botline(disp, window, gc); break;
364 - case 'Q': /* quit */
366 - case 's': /* start new ship */
367 + case XK_q: /* quit */
368 + if (event.xkey.state & ShiftMask)
371 + case XK_s: /* start new ship */
372 if (!obj[SHIP].alive)
373 if (ships < 1) goto Newgame;
375 @@ -823,16 +884,16 @@
379 - len = XLookupString(&event, text, 10, &key, 0);
380 - if (len == 1) switch (text[0])
382 + key = XLookupKeysym((XKeyEvent *)&event, 0);
384 + { case XK_Left: case XK_e:
385 obj[SHIP].rotvel = 0; break;
387 + case XK_Right: case XK_r:
388 obj[SHIP].rotvel = 0; break;
390 + case XK_Up: case THRUST:
391 obj[SHIP].shape = SHIPSHAPE;
394 + case XK_Down: case SHIELD:
395 shield_on = 0; break;
399 botline(disp, window, gc);
401 /* Write copyright notice */
402 - if (!ships && blist == NULL)
404 { sprintf(text, "Xasteroids");
405 XDrawImageString (disp, pixmap, gc,
406 width/2-50, height/2-2*letheight,
409 else obj[ENEMYBUL].alive = 0;
414 for (i = 0; i < delay; i++);
419 --- xasteroids-5.0.orig/xast.docs
420 +++ xasteroids-5.0/xast.docs
425 - e Rotate counterclockwise ("left")
426 - r Rotate clockwise ("right")
427 + e / <- Rotate counterclockwise ("left")
428 + r / -> Rotate clockwise ("right")
429 w Rotate 45 degrees counterclockwise
430 t Rotate 45 degrees clockwise
431 d Increase counterclockwise rotational velocity
432 f Increase clockwise rotational velocity
435 + o / Up Arrow Thrust
439 + ` / Down Arrow Shields
440 s Start new ship in center of playing field
441 (Also used to start a new game)
445 Resize the window with your window manager
446 at any time for a different playing field.
448 -Use the command-line option -s on the xasteroids script
449 -to see the high score list.
450 --- xasteroids-5.0.orig/xast.man
451 +++ xasteroids-5.0/xast.man
456 xasteroids - X windows based asteroids style arcade game
461 +\fBxasteroids\fP [-s]
464 Make big rocks into little ones.
469 - e Rotate counterclockwise ("left")
470 - r Rotate clockwise ("right")
471 - w Rotate 45 degrees counterclockwise
472 - t Rotate 45 degrees clockwise
473 - d Increase counterclockwise rotational velocity
474 - f Increase clockwise rotational velocity
479 - s Start new ship in center of playing field
480 - (Also used to start a new game)
484 + e Left Arrow Rotate counterclockwise ("left")
485 + r Right Arrow Rotate clockwise ("right")
486 + w Rotate 45 degrees counterclockwise
487 + t Rotate 45 degrees clockwise
488 + d Increase CCWise rotational velocity
489 + f Increase clockwise rotational velocity
492 + ` Down Arrow Shields
494 + s Start new ship in center of playing field
495 + (Also used to start a new game)
500 Speed commands: Key associated with faster speed is to the right of its
501 - corresponding key associated with slower speed.
502 +corresponding key associated with slower speed.
504 - . Decrease delay: Speed game up
505 - , Increase delay: Slow the game down
506 - m Decrease size ("Minimize")
508 - b Increase # of moves/frame
509 - v Decrease # of moves/frame
510 - 2 Increase scale of movement
511 - 1 Decrease scale of movement
513 + . Decrease delay: Speed game up
514 + , Increase delay: Slow the game down
515 + m Decrease size ("Minimize")
517 + b Increase # of moves/frame
518 + v Decrease # of moves/frame
519 + 2 Increase scale of movement
520 + 1 Decrease scale of movement
524 - Big asteroid 25, or 2000*level if it is the last asteroid remaining
525 - Medium asteroid 50, or 500*level if it is the last asteroid remaining
526 + Big asteroid 25, or
527 + 2000*level if last asteroid remaining
528 + Medium asteroid 50, or
529 + 500*level if last asteroid remaining
535 Commands can only be entered when the mouse pointer is in the
538 Resize the window with your window manager
539 at any time for a different playing field.
543 --s Display high scores without running game.
550 -Peter Phillips pphillip@cs.ubc.ca
551 -Pat Ryan pat@jaameri.gsfc.nasa.gov
552 -Craig Smith csmith@cscs.UUCP
553 -Doug Merritt doug@netcom.com
554 -James Berg berg@plains (makefile)
555 -Chris Moore moore@src.bae.co.uk (hi score script)
556 -David Partain dlp@ida.liu.se (original man page)
557 +Peter Phillips <pphillip@cs.ubc.ca>
559 +Pat Ryan <pat@jaameri.gsfc.nasa.gov>
561 +Craig Smith <csmith@cscs.UUCP>
563 +Doug Merritt <doug@netcom.com>
565 +Stephen McCamant <alias@mcs.com>
567 +James Berg <berg@plains> (makefile)
569 +Chris Moore <moore@src.bae.co.uk> (hi score script)
571 +David Partain <dlp@ida.liu.se> (original man page)