40
# include <OpenGL/glu.h>
37
45
#include "gllist.h"
39
#define MAXSPROING 100
44
int x, y, z, frame, life;
46
#include "sproingies.h"
48
#define MAXSPROING 100
49
#define TARGET_COUNT 40
51
#define NO_FRAME (-10)
52
#define RESET_SPROINGIE_LIFE (-30 + myrand(28))
53
#define NEW_SPROINGIE_LIFE (40 + myrand(200))
60
* The sproingies have six "real" frames, (s1_1 to s1_6) that show a
61
* sproingie jumping off a block, headed down and to the right.
62
* The frames are numbered from 0 (FIRST_FRAME) to 5 (LAST_FRAME).
64
* There are other frame numbers for special cases (e.g. BOOM_FRAME).
66
struct sPosColor { /* Position and color of the sproingie */
67
int x, y, z; /* Position */
68
int frame; /* Current frame (0-5) */
69
int life; /* Life points */
70
GLfloat r, g, b; /* Color RGB */
71
int direction; /* Direction of next hop (left or right) */
49
75
int rotx, roty, dist, wireframe, flatshade, groundlevel,
50
76
maxsproingies, mono;
51
77
int sframe, target_rx, target_ry, target_dist, target_count;
52
struct gllist *sproingies[6];
53
struct gllist *SproingieBoom;
78
const struct gllist *sproingies[6];
79
const struct gllist *SproingieBoom;
55
81
struct sPosColor *positions;
58
84
static sp_instance *si_list = NULL;
59
85
static int active_screens = 0;
61
void SproingieSwap(void);
63
extern struct gllist *s1_1;
64
extern struct gllist *s1_2;
65
extern struct gllist *s1_3;
66
extern struct gllist *s1_4;
67
extern struct gllist *s1_5;
68
extern struct gllist *s1_6;
69
extern struct gllist *s1_b;
87
extern const struct gllist *s1_1;
88
extern const struct gllist *s1_2;
89
extern const struct gllist *s1_3;
90
extern const struct gllist *s1_4;
91
extern const struct gllist *s1_5;
92
extern const struct gllist *s1_6;
93
extern const struct gllist *s1_b;
253
277
if ((thisSproingie->b -= 0.08) < 0.0)
254
278
thisSproingie->b = 0.0;
255
279
if ((--(thisSproingie->life)) < 1) {
256
thisSproingie->life = RESET_SPROINGIE;
280
thisSproingie->life = RESET_SPROINGIE_LIFE;
260
thisSproingie->x += 1;
261
thisSproingie->y -= 2;
262
thisSproingie->z += 1;
263
thisSproingie->frame = 0;
284
thisSproingie->frame = FIRST_FRAME;
286
/* Check for collisions */
265
287
for (t2 = 0; t2 < si->maxsproingies; ++t2) {
266
288
if ((t2 != t) && (thisSproingie->x == S2->x) &&
267
289
(thisSproingie->y == S2->y) && (thisSproingie->z == S2->z) &&
268
(S2->life > 10) && (S2->frame < 6)) {
290
(S2->life > 10) && (S2->frame < LAST_FRAME + 1)) {
270
292
if (thisSproingie->life > S2->life) {
313
/* Time to disappear... */
291
314
if (!((thisSproingie->life == 10) &&
292
(thisSproingie->frame > 0) &&
315
(thisSproingie->frame > FIRST_FRAME) &&
293
316
(thisSproingie->frame < BOOM_FRAME))) {
294
317
if ((--(thisSproingie->life)) < 1) {
295
thisSproingie->life = RESET_SPROINGIE;
318
thisSproingie->life = RESET_SPROINGIE_LIFE;
296
319
} else if (thisSproingie->life < 9) {
297
320
thisSproingie->frame -= 2;
299
} /* else wait here for frame 0 to come about. */
322
} /* ... else wait here for frame FIRST_FRAME to come about. */
300
323
} else if (++(thisSproingie->life) >= 0) {
302
325
g_higher = -3 + myrand(5);
303
326
g_back = -2 + myrand(5);
304
327
} else if (t == 1) {
312
thisSproingie->x = (-g_higher - g_back);
313
thisSproingie->y = (g_higher << 1);
314
thisSproingie->z = (g_back - g_higher);
315
thisSproingie->life = 40 + myrand(200);
316
thisSproingie->frame = -10;
317
thisSproingie->r = (GLfloat) (40 + myrand(200)) / 255.0;
318
thisSproingie->g = (GLfloat) (40 + myrand(200)) / 255.0;
319
thisSproingie->b = (GLfloat) (40 + myrand(200)) / 255.0;
335
thisSproingie->x = (-g_higher - g_back);
336
thisSproingie->y = (g_higher << 1);
337
thisSproingie->z = (g_back - g_higher);
338
thisSproingie->life = NEW_SPROINGIE_LIFE;
339
thisSproingie->frame = NO_FRAME;
340
thisSproingie->r = (GLfloat) (40 + myrand(200)) / 255.0;
341
thisSproingie->g = (GLfloat) (40 + myrand(200)) / 255.0;
342
thisSproingie->b = (GLfloat) (40 + myrand(200)) / 255.0;
321
344
for (t2 = 0; t2 < si->maxsproingies; ++t2) {
322
345
if ((t2 != t) && (thisSproingie->x == S2->x) &&
323
346
(thisSproingie->y == S2->y) && (thisSproingie->z == S2->z) &&
324
(S2->life > 10) && (S2->frame < 0)) {
325
/* If one is already being born, just wait. */
347
(S2->life > 10) && (S2->frame < FIRST_FRAME)) {
348
/* If another is already on this place, wait. */
326
349
thisSproingie->life = -1;
512
540
(si->wireframe ? 0.0 : 0.1);
513
541
glClipPlane(GL_CLIP_PLANE0, clipplane);
514
542
/** glCallList(si->sproingies[0]);*/
515
/**/ renderList(si->sproingies[0]);
543
/**/ renderList(si->sproingies[0], si->wireframe);
516
544
glDisable(GL_CLIP_PLANE0);
517
545
} else if (thisSproingie->frame >= BOOM_FRAME) {
518
546
glTranslatef((GLfloat) (thisSproingie->x) + 0.5,
532
560
* PURIFY 4.0.1 reports an unitialized memory read on the next line when using
533
561
* MesaGL 2.2. This has been tracked to MesaGL 2.2 src/points.c line 313. */
534
562
/** glCallList(si->SproingieBoom);*/
535
/**/ renderList(si->SproingieBoom);
563
/**/ renderList(si->SproingieBoom, si->wireframe);
536
564
glPointSize(1.0);
537
565
if (!si->wireframe) {
538
566
glEnable(GL_LIGHTING);
540
} else if (thisSproingie->frame > 5) {
541
glTranslatef((GLfloat) (thisSproingie->x + 1),
542
(GLfloat) (thisSproingie->y - 1), (GLfloat) (thisSproingie->z - 1));
543
glRotatef((GLfloat) - 90.0, 0.0, 1.0, 0.0);
544
/** glCallList(si->sproingies[thisSproingie->frame - 6]);*/
545
/**/ renderList(si->sproingies[thisSproingie->frame - 6]);
547
glTranslatef((GLfloat) (thisSproingie->x), (GLfloat) (thisSproingie->y),
548
(GLfloat) (thisSproingie->z));
569
if (thisSproingie->direction == JUMP_LEFT) {
570
/* When the sproingie jumps to the left, the frames must be */
571
/* rotated and translated */
572
glTranslatef((GLfloat) (thisSproingie->x ),
573
(GLfloat) (thisSproingie->y ),
574
(GLfloat) (thisSproingie->z - 1));
575
glRotatef((GLfloat) - 90.0, 0.0, 1.0, 0.0);
576
if (thisSproingie->frame == LAST_FRAME) {
577
thisSproingie->x -= 0;
578
thisSproingie->y -= 1;
579
thisSproingie->z += 1;
582
glTranslatef((GLfloat) (thisSproingie->x),
583
(GLfloat) (thisSproingie->y),
584
(GLfloat) (thisSproingie->z));
585
glRotatef((GLfloat) - 0.0, 0.0, 1.0, 0.0);
586
if (thisSproingie->frame == LAST_FRAME) {
587
thisSproingie->x += 1;
588
thisSproingie->y -= 1;
589
thisSproingie->z -= 0;
549
593
/** glCallList(si->sproingies[thisSproingie->frame]);*/
550
/**/ renderList(si->sproingies[thisSproingie->frame]);
594
/**/ renderList(si->sproingies[thisSproingie->frame], si->wireframe);
596
/* Every 6 frame cycle... */
597
if (thisSproingie->frame == LAST_FRAME) {
598
/* ...check if the sproingies have gone out of the bricks */
599
if (((thisSproingie->x - thisSproingie->z == 6) &&
600
(2*thisSproingie->x + thisSproingie->y == 6)) ||
601
((thisSproingie->z - thisSproingie->x == 5) &&
602
(2*thisSproingie->x + thisSproingie->y == -5))) {
603
/* If they have, then they die */
604
if (thisSproingie->life > 0 && thisSproingie->frame < BOOM_FRAME && thisSproingie->frame > FIRST_FRAME) {
605
thisSproingie->frame = BOOM_FRAME;
608
/* If not, they choose a direction for the next hop */
609
if (smart_sproingies) {
610
if ((thisSproingie->x - thisSproingie->z == 5) &&
611
(2*thisSproingie->x + thisSproingie->y == 5)) {
612
thisSproingie->direction = JUMP_LEFT;
613
} else if ((thisSproingie->z - thisSproingie->x == 4) &&
614
(2*thisSproingie->x + thisSproingie->y == -4)) {
615
thisSproingie->direction = JUMP_RIGHT;
617
thisSproingie->direction = myrand(2);
620
thisSproingie->direction = myrand(2);