home *** CD-ROM | disk | FTP | other *** search
-
- #include "swar.h"
-
- InitDebris()
- {
- extern DEBRISREC gDebrisRecs[MAX_DEBRIS], gOldDebrisRecs[MAX_DEBRIS];
- short i;
-
- for (i = 0; i < MAX_DEBRIS; i++) {
- gDebrisRecs[i].where.v = -1;
- gDebrisRecs[i].where.h = -1;
- gDebrisRecs[i].vel.v = -1;
- gDebrisRecs[i].vel.h = -1;
- gDebrisRecs[i].countdown = 0;
- } /* for */
-
- } /* InitDebris() */
-
- CreateDebris(number, tics, h, v, hv, vv)
- short number, tics, h, v, hv, vv;
- {
- short i;
-
- for (i = 0; i < MAX_DEBRIS; i++)
- if (gDebrisRecs[i].countdown == 0) {
- gDebrisRecs[i].where.v = v + RngRnd(-3, 3);
- gDebrisRecs[i].where.h = h + RngRnd(-3, 3);
- gDebrisRecs[i].vel.v = vv + RngRnd(-3, 3);
- gDebrisRecs[i].vel.h = hv + RngRnd(-3, 3);
- gDebrisRecs[i].countdown = tics;
- gDebrisRecs[i].color.red = RngRnd(0, 256) * 256;
- gDebrisRecs[i].color.green = RngRnd(0, 256) * 256;
- gDebrisRecs[i].color.blue = RngRnd(0, 256) * 256;
- if (--number == 0)
- return;
- } /* if */
-
-
- } /* CreateDebris() */
-
- MoveDebris()
- {
- short i;
-
- for (i = 0; i < MAX_DEBRIS; i++)
- if (gDebrisRecs[i].countdown) {
- gDebrisRecs[i].countdown--;
- gDebrisRecs[i].where.h += gDebrisRecs[i].vel.h;
- gDebrisRecs[i].where.v += gDebrisRecs[i].vel.v;
- if (gDebrisRecs[i].where.v < 0)
- gDebrisRecs[i].vel.v *= -1;
- if (gDebrisRecs[i].where.v > 479)
- gDebrisRecs[i].vel.v *= -1;
- if (gDebrisRecs[i].where.h < 0)
- gDebrisRecs[i].vel.h *= -1;
- if (gDebrisRecs[i].where.h > 639)
- gDebrisRecs[i].vel.h *= -1;
- } /* if */
-
- } /* MoveDebris() */
-
- DrawDebris()
- {
- short hloc;
- extern short gXv;
- short i;
- GrafPtr savePort;
- extern CGrafPort *gOSPtr;
- extern RGBColor myBlack;
-
- GetPort(&savePort);
- SetPort((GrafPtr)gOSPtr);
- for (i = 0; i < MAX_DEBRIS; i++) {
- if (gOldDebrisRecs[i].countdown)
- SetCPixel(gOldDebrisRecs[i].where.h, gOldDebrisRecs[i].where.v, &myBlack);
- if (gDebrisRecs[i].countdown)
- SetCPixel(gDebrisRecs[i].where.h, gDebrisRecs[i].where.v, &(gDebrisRecs[i].color));
- gOldDebrisRecs[i] = gDebrisRecs[i];
- } /* for */
- SetPort(savePort);
-
- } /* DrawDebris() */
-