-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathintro.c
491 lines (404 loc) · 13.1 KB
/
intro.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
/*
* XBoing - An X11 blockout style computer game
*
* (c) Copyright 1993, 1994, 1995, Justin C. Kibell, All Rights Reserved
*
* The X Consortium, and any party obtaining a copy of these files from
* the X Consortium, directly or indirectly, is granted, free of charge, a
* full and unrestricted irrevocable, world-wide, paid up, royalty-free,
* nonexclusive right and license to deal in this software and
* documentation files (the "Software"), including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons who receive
* copies from any such party to do so. This license includes without
* limitation a license to do the foregoing actions under any patents of
* the party supplying this software to the X Consortium.
*
* In no event shall the author be liable to any party for direct, indirect,
* special, incidental, or consequential damages arising out of the use of
* this software and its documentation, even if the author has been advised
* of the possibility of such damage.
*
* The author specifically disclaims any warranties, including, but not limited
* to, the implied warranties of merchantability and fitness for a particular
* purpose. The software provided hereunder is on an "AS IS" basis, and the
* author has no obligation to provide maintenance, support, updates,
* enhancements, or modifications.
*/
/*
* =========================================================================
*
* $Id: intro.c,v 1.1.1.1 1994/12/16 01:36:44 jck Exp $
* $Source: /usr5/legends/jck/xb/master/xboing/intro.c,v $
* $Revision: 1.1.1.1 $
* $Date: 1994/12/16 01:36:44 $
*
* $Log: intro.c,v $
* Revision 1.1.1.1 1994/12/16 01:36:44 jck
* The XBoing distribution requires configuration management. This is why the
* cvs utility is being used. This is the initial import of all source etc..
*
*
* =========================================================================
*/
/*
* Include file dependencies:
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
//#include <X11/Xlib.h>
//#include <X11/Xutil.h>
//#include <X11/Xos.h>
//#include <xpm.h>
#include "error.h"
#include "misc.h"
#include "gun.h"
#include "main.h"
#include "init.h"
#include "inst.h"
#include "stage.h"
#include "blocks.h"
#include "sfx.h"
#include "special.h"
#include "ball.h"
#include "score.h"
#include "paddle.h"
#include "level.h"
#include "mess.h"
#include "audio.h"
#include "version.h"
#include "bitmaps/presents/titleBig.xpm"
#include "bitmaps/stars/star1.xpm"
#include "bitmaps/stars/star2.xpm"
#include "bitmaps/stars/star3.xpm"
#include "bitmaps/stars/star4.xpm"
#include "bitmaps/stars/star5.xpm"
#include "bitmaps/stars/star6.xpm"
#include "bitmaps/stars/star7.xpm"
#include "bitmaps/stars/star8.xpm"
#include "bitmaps/stars/star9.xpm"
#include "bitmaps/stars/star10.xpm"
#include "bitmaps/stars/star11.xpm"
#include "intro.h"
/*
* Internal macro definitions:
*/
#define GAP 10
#define BLINK_GAP 1000
#define BLINK_RATE 25
/*
* Internal type declarations:
*/
void SetIntroWait(enum IntroStates newMode, int waitFrame);
void DoIntroWait(void);
/*
* Internal variable declarations:
*/
static int endFrame = 0;
static int startFrame = 0;
int nextBlink = 0;
enum IntroStates IntroState;
Pixmap bigtitlePixmap, bigtitlePixmapM;
Pixmap stars[12], starsM[12];
static int waitingFrame;
enum IntroStates waitMode;
void SetUpIntroduction(Display *display, Window window, Colormap colormap)
{
XpmAttributes attributes;
int XpmErrorStatus;
attributes.valuemask = XpmColormap;
attributes.colormap = colormap;
XpmErrorStatus = XpmCreatePixmapFromData(display, window, titleBig_xpm,
&bigtitlePixmap, &bigtitlePixmapM, &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro()");
/* Create the stars for the letter shine */
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star1_xpm,
&stars[0], &starsM[0], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star1)");
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star2_xpm,
&stars[1], &starsM[1], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star2)");
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star3_xpm,
&stars[2], &starsM[2], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star3)");
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star4_xpm,
&stars[3], &starsM[3], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star4)");
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star5_xpm,
&stars[4], &starsM[4], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star5)");
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star6_xpm,
&stars[5], &starsM[5], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star6)");
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star7_xpm,
&stars[6], &starsM[6], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star7)");
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star8_xpm,
&stars[7], &starsM[7], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star8)");
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star9_xpm,
&stars[8], &starsM[8], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star9)");
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star10_xpm,
&stars[9], &starsM[9], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star10)");
XpmErrorStatus = XpmCreatePixmapFromData(display, window, star11_xpm,
&stars[10], &starsM[10], &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseIntro(star11)");
/* Free the xpm pixmap attributes */
XpmFreeAttributes(&attributes);
ResetIntroduction();
}
void DrawIntroTitle(Display *display, Window window, int x, int y)
{
RenderShape(display, window, bigtitlePixmap, bigtitlePixmapM,
x, y, 474, 74, True);
}
void DoIntroTitle(Display *display, Window window)
{
/* Clear and draw background pattern */
DrawStageBackground(display, window, BACKGROUND_0, True);
/* Draw the intro title bitmap XBOING */
DrawIntroTitle(display, window, 10, 10);
}
static void DoBlocks(Display *display, Window window)
{
int y = 120;
int x = 40;
/* Be very friendly */
SetCurrentMessage(display, messWindow, "Welcome to XBoing", False);
/* Now draw the blocks on the screen */
DrawTheBlock(display, window, x, y, RED_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Normal block", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+6, y, ROAMER_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Roamer dude", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x, y, PAD_EXPAND_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Paddle sizer", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+5, y, BONUSX2_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- x2 scores", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x, y, MAXAMMO_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Full Ammo", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x, y, DROP_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Dropper", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x, y, BULLET_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Ammunition", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+5, y-5, HYPERSPACE_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Teleport", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+5, y+5, REVERSE_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Reverse Control", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+5, y+5, MGUN_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Machine Gun", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x, y, MULTIBALL_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Multi Balls", x + 60, y, green);
y += 40;
/* New line from top again on right */
y = 120;
x = 260;
DrawTheBlock(display, window, x+5, y, BONUS_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- 3000 points", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x, y, COUNTER_BLK, 5, 0, 0);
DrawShadowText(display, window, textFont,
"- 200 points", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+10, y, TIMER_BLK, 5, 0, 0);
DrawShadowText(display, window, textFont,
"- Extra Time", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x, y, BLACK_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Solid wall", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+9, y, BOMB_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Bomb!", x + 60, y, green);
y += 40;
DrawPaddle(display, window, x+20, y, PADDLE_SMALL);
DrawShadowText(display, window, textFont,
"- The Paddle", x + 60, y, green);
y += 40;
DrawTheBullet(display, window, x+20, y+5);
DrawShadowText(display, window, textFont,
"- Bullet", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+8, y, DEATH_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Instant Death!", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+10, y, EXTRABALL_BLK, 1, 0, 0);
DrawShadowText(display, window, textFont,
"- Extra Ball", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+10, y, WALLOFF_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Walls Off", x + 60, y, green);
y += 40;
DrawTheBlock(display, window, x+10, y - 5, STICKY_BLK, 0, 0, 0);
DrawShadowText(display, window, textFont,
"- Sticky Ball", x + 60, y, green);
y += 40;
}
static void DoText(Display *display, Window window)
{
char string[80];
int y;
y = PLAY_HEIGHT - 27;
strcpy(string, "Insert coin to start the game");
DrawShadowCentredText(display, window, textFont,
string, y, tann, PLAY_WIDTH);
}
static void DoSparkle(Display *display, Window window)
{
static Pixmap store;
static int x = 100;
static int y = 20;
static int in = 0;
if (!store)
{
store = XCreatePixmap(display, window, 20, 20,
DefaultDepth(display, XDefaultScreen(display)));
}
if (in == 0)
XCopyArea(display, window, store, gc, x, y, 20, 20, 0, 0);
if (frame == endFrame)
IntroState = INTRO_FINISH;
if (frame == startFrame)
{
XCopyArea(display, store, window, gc, 0, 0, 20, 20, x, y);
RenderShape(display, window, stars[in], starsM[in],
x, y, 20, 20, False);
in++;
startFrame = frame + 15;
if (in == 11)
{
XCopyArea(display, store, window, gc, 0, 0, 20, 20, x, y);
in = 0;
startFrame = frame + 500;
x = (rand() % 474) + 5;
y = (rand() % 74) + 5;
}
}
}
static void DoFinish(Display *display, Window window)
{
ResetInstructions();
mode = MODE_INSTRUCT;
if (noSound == False)
playSoundFile("whoosh", 50);
}
void HandleBlink(Display *display, Window window)
{
if (frame == nextBlink)
{
if (BlinkDevilEyes(display, playWindow) == False)
nextBlink = frame + BLINK_GAP;
else
nextBlink = frame + BLINK_RATE;
}
}
void Introduction(Display *display, Window window)
{
static int firstTime = True;
switch (IntroState)
{
case INTRO_TITLE:
if (getSpecialEffects(display) == True && !firstTime)
DoIntroTitle(display, bufferWindow);
else
DoIntroTitle(display, window);
IntroState = INTRO_BLOCKS;
break;
case INTRO_BLOCKS:
if (getSpecialEffects(display) == True && !firstTime)
DoBlocks(display, bufferWindow);
else
DoBlocks(display, window);
IntroState = INTRO_TEXT;
break;
case INTRO_TEXT:
if (getSpecialEffects(display) == True && !firstTime)
{
DoText(display, bufferWindow);
while (WindowShatterEffect(display, window));
}
else
DoText(display, window);
if (firstTime) firstTime = False;
IntroState = INTRO_EXPLODE;
break;
case INTRO_EXPLODE:
DoSparkle(display, window);
if ((frame % FLASH) == 0)
RandomDrawSpecials(display);
BorderGlow(display, window);
HandleBlink(display, window);
break;
case INTRO_FINISH:
DoFinish(display, window);
break;
case INTRO_WAIT:
DoIntroWait();
break;
default:
break;
}
}
void RedrawIntroduction(Display *display, Window window)
{
DoIntroTitle(display, window);
DoBlocks(display, window);
DoText(display, window);
}
void FreeIntroduction(Display *display)
{
int i;
for (i = 0; i < 10; i++)
{
if (stars[i]) XFreePixmap(display, stars[i]);
if (starsM[i]) XFreePixmap(display, starsM[i]);
}
if (bigtitlePixmap) XFreePixmap(display, bigtitlePixmap);
if (bigtitlePixmapM) XFreePixmap(display, bigtitlePixmapM);
}
void ResetIntroduction(void)
{
IntroState = INTRO_TITLE;
startFrame = frame + 10;
endFrame = frame + 3000;
nextBlink = frame + 10;
DEBUG("Reset Introduction mode.")
}
void SetIntroWait(enum IntroStates newMode, int waitFrame)
{
waitingFrame = waitFrame;
waitMode = newMode;
IntroState = INTRO_WAIT;
}
void DoIntroWait(void)
{
if (frame == waitingFrame)
IntroState = waitMode;
}