1 /*
2 * XBoing - An X11 blockout style computer game
3 *
4 * (c) Copyright 1993, 1994, 1995, Justin C. Kibell, All Rights Reserved
5 *
6 * The X Consortium, and any party obtaining a copy of these files from
7 * the X Consortium, directly or indirectly, is granted, free of charge, a
8 * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
9 * nonexclusive right and license to deal in this software and
10 * documentation files (the "Software"), including without limitation the
11 * rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons who receive
13 * copies from any such party to do so. This license includes without
14 * limitation a license to do the foregoing actions under any patents of
15 * the party supplying this software to the X Consortium.
16 *
17 * In no event shall the author be liable to any party for direct, indirect,
18 * special, incidental, or consequential damages arising out of the use of
19 * this software and its documentation, even if the author has been advised
20 * of the possibility of such damage.
21 *
22 * The author specifically disclaims any warranties, including, but not limited
23 * to, the implied warranties of merchantability and fitness for a particular
24 * purpose. The software provided hereunder is on an "AS IS" basis, and the
25 * author has no obligation to provide maintenance, support, updates,
26 * enhancements, or modifications.
27 */
28
29 /*
30 * =========================================================================
31 *
32 * $Id: stage.c,v 1.1.1.1 1994/12/16 01:36:45 jck Exp $
33 * $Source: /usr5/legends/jck/xb/master/xboing/stage.c,v $
34 * $Revision: 1.1.1.1 $
35 * $Date: 1994/12/16 01:36:45 $
36 *
37 * $Log: stage.c,v $
38 * Revision 1.1.1.1 1994/12/16 01:36:45 jck
39 * The XBoing distribution requires configuration management. This is why the
40 * cvs utility is being used. This is the initial import of all source etc..
41 *
42 *
43 * =========================================================================
44 */
45
46 /*
47 * Include file dependencies:
48 */
49
50 #include <stdio.h>
51 #include <stdlib.h>
52 #include <stddef.h>
53 #include <X11/Xlib.h>
54 #include <X11/Xutil.h>
55 #include <X11/Xos.h>
56 #include <xpm.h>
57
58 #include "bitmaps/bgrnds/mnbgrnd.xpm"
59 #include "bitmaps/bgrnds/space.xpm"
60 #include "bitmaps/bgrnds/bgrnd.xpm"
61 #include "bitmaps/bgrnds/bgrnd2.xpm"
62 #include "bitmaps/bgrnds/bgrnd3.xpm"
63 #include "bitmaps/bgrnds/bgrnd4.xpm"
64 #include "bitmaps/bgrnds/bgrnd5.xpm"
65 #include "bitmaps/icon.xpm"
66 #include "bitmaps/eyes/deveyes.xpm"
67 #include "bitmaps/eyes/deveyes1.xpm"
68 #include "bitmaps/eyes/deveyes2.xpm"
69 #include "bitmaps/eyes/deveyes3.xpm"
70 #include "bitmaps/eyes/deveyes4.xpm"
71 #include "bitmaps/eyes/deveyes5.xpm"
72
73 #include "error.h"
74 #include "blocks.h"
75 #include "editor.h"
76 #include "sfx.h"
77 #include "ball.h"
78 #include "misc.h"
79 #include "paddle.h"
80 #include "dialogue.h"
81 #include "version.h"
82 #include "init.h"
83
84 #include "stage.h"
85
86 /*
87 * Internal macro definitions:
88 */
89
90 #define LEFT_OFFSET 10
91 #define RIGHT_OFFSET 10
92 #define TOP_OFFSET 10
93 #define MIDDLE_OFFSET 10
94
95 #define DEVILEYE_WIDTH 57
96 #define DEVILEYE_HEIGHT 16
97 #define DEVILEYE_WC (DEVILEYE_WIDTH / 2)
98 #define DEVILEYE_HC (DEVILEYE_HEIGHT / 2)
99
100 /*
101 * Internal type declarations:
102 */
103
104 #if NeedFunctionPrototypes
105 static Window SetWMIcon(Display *display);
106 #else
107 static Window SetWMIcon();
108 #endif
109
110 /*
111 * Internal variable declarations:
112 */
113
114 Window iconWindow;
115 Window inputWindow;
116 Window mainWindow;
117 Window scoreWindow;
118 Window levelWindow;
119 Window playWindow;
120 Window bufferWindow;
121 Window messWindow;
122 Window specialWindow;
123 Window timeWindow;
124 Window blockWindow;
125 Window typeWindow;
126 Pixmap mainBackPixmap, iconPixmap, spacePixmap;
127 Pixmap back1Pixmap, back2Pixmap, back3Pixmap, back4Pixmap, back5Pixmap;
128 Pixmap devilblink[6], devilblinkM[6];
129 int devilx, devily;
130 int blinkslides[] = { 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 0, 0,
131 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0 };
132
133
134 #if NeedFunctionPrototypes
InitialiseMainBackPixmap(Display * display,Window window,Colormap colormap)135 void InitialiseMainBackPixmap(Display *display, Window window,
136 Colormap colormap)
137 #else
138 void InitialiseMainBackPixmap(display, window, colormap)
139 Display *display;
140 Window window;
141 Colormap colormap;
142 #endif
143 {
144 XpmAttributes attributes;
145 int XpmErrorStatus;
146
147 attributes.valuemask = XpmColormap;
148 attributes.colormap = colormap;
149
150 /* Create the playfield background pixmaps */
151
152 XpmErrorStatus = XpmCreatePixmapFromData(display, window,
153 mainbackground_xpm, &mainBackPixmap, NULL, &attributes);
154 HandleXPMError(display, XpmErrorStatus, "InitialiseMainBackPixmap()");
155
156 XpmErrorStatus = XpmCreatePixmapFromData(display, window,
157 space_xpm, &spacePixmap, NULL, &attributes);
158 HandleXPMError(display, XpmErrorStatus, "InitialiseMainBackPixmap(space)");
159
160 XpmErrorStatus = XpmCreatePixmapFromData(display, window, background_xpm,
161 &back1Pixmap, NULL, &attributes);
162 HandleXPMError(display, XpmErrorStatus, "InitialiseMainBackPixmap()");
163
164 XpmErrorStatus = XpmCreatePixmapFromData(display, window, background2_xpm,
165 &back2Pixmap, NULL, &attributes);
166 HandleXPMError(display, XpmErrorStatus, "InitialiseMainBackPixmap()");
167
168 XpmErrorStatus = XpmCreatePixmapFromData(display, window, background3_xpm,
169 &back3Pixmap, NULL, &attributes);
170 HandleXPMError(display, XpmErrorStatus, "InitialiseMainBackPixmap()");
171
172 XpmErrorStatus = XpmCreatePixmapFromData(display, window, background4_xpm,
173 &back4Pixmap, NULL, &attributes);
174 HandleXPMError(display, XpmErrorStatus, "InitialiseMainBackPixmap()");
175
176 XpmErrorStatus = XpmCreatePixmapFromData(display, window, background5_xpm,
177 &back5Pixmap, NULL, &attributes);
178 HandleXPMError(display, XpmErrorStatus, "InitialiseMainBackPixmap()");
179
180 /* Devil blink animation */
181
182 XpmErrorStatus = XpmCreatePixmapFromData(display, window, devileyes_xpm,
183 &devilblink[0], &devilblinkM[0], &attributes);
184 HandleXPMError(display, XpmErrorStatus,
185 "InitialiseMainBackPixmap(devilblink[0])");
186
187 XpmErrorStatus = XpmCreatePixmapFromData(display, window, devileyes1_xpm,
188 &devilblink[1], &devilblinkM[1], &attributes);
189 HandleXPMError(display, XpmErrorStatus,
190 "InitialiseMainBackPixmap(devilblink[1])");
191
192 XpmErrorStatus = XpmCreatePixmapFromData(display, window, devileyes2_xpm,
193 &devilblink[2], &devilblinkM[2], &attributes);
194 HandleXPMError(display, XpmErrorStatus,
195 "InitialiseMainBackPixmap(devilblink[2])");
196
197 XpmErrorStatus = XpmCreatePixmapFromData(display, window, devileyes3_xpm,
198 &devilblink[3], &devilblinkM[3], &attributes);
199 HandleXPMError(display, XpmErrorStatus,
200 "InitialiseMainBackPixmap(devilblink[3])");
201
202 XpmErrorStatus = XpmCreatePixmapFromData(display, window, devileyes4_xpm,
203 &devilblink[4], &devilblinkM[4], &attributes);
204 HandleXPMError(display, XpmErrorStatus,
205 "InitialiseMainBackPixmap(devilblink[4])");
206
207 XpmErrorStatus = XpmCreatePixmapFromData(display, window, devileyes5_xpm,
208 &devilblink[5], &devilblinkM[5], &attributes);
209 HandleXPMError(display, XpmErrorStatus,
210 "InitialiseMainBackPixmap(devilblink[5])");
211
212 /* Free the xpm pixmap attributes */
213 XpmFreeAttributes(&attributes);
214 }
215
216 #if NeedFunctionPrototypes
ClearMainWindow(Display * display,Window window)217 void ClearMainWindow(Display *display, Window window)
218 #else
219 void ClearMainWindow(display, window)
220 Display *display;
221 Window window;
222 #endif
223 {
224 /* Make sure that it is drawn */
225 XSetWindowBackgroundPixmap(display, mainWindow, spacePixmap);
226 XClearWindow(display, mainWindow);
227 }
228
229 #if NeedFunctionPrototypes
SetWindowSizeHints(Display * display,int w,int h)230 void SetWindowSizeHints(Display *display, int w, int h)
231 #else
232 void SetWindowSizeHints(display, w, h)
233 Display *display;
234 int w, h;
235 #endif
236 {
237 XSizeHints sizehints;
238
239 /* Setup the max and minimum size that the window will be */
240 sizehints.flags = PPosition | PSize | PMinSize | PMaxSize;
241 sizehints.min_width = w;
242 sizehints.min_height = h;
243 sizehints.max_width = w;
244 sizehints.max_height = h;
245
246 /* Now set the window manager size hints properties */
247 XSetWMNormalHints(display, mainWindow, &sizehints);
248 }
249
250 #if NeedFunctionPrototypes
CreateAllWindows(Display * display,Colormap colormap,char ** argv,int argc)251 void CreateAllWindows(Display *display, Colormap colormap,
252 char **argv, int argc)
253 #else
254 void CreateAllWindows(display, colormap, argv, argc)
255 Display *display;
256 Colormap colormap;
257 char **argv;
258 int argc;
259 #endif
260 {
261 char title[80];
262 int offsetX, offsetY, scoreWidth;
263 XWMHints wmhints;
264 XClassHint classhints;
265 XSizeHints sizehints;
266 XTextProperty windowName, iconName;
267 XSetWindowAttributes winattr;
268 unsigned long valuemask;
269 int temp;
270
271 char *window_Name = "- XBoing II -";
272 char *icon_Name = "XBoing II";
273
274 offsetX = MAIN_WIDTH / 2;
275 offsetY = MAIN_HEIGHT / 2;
276 scoreWidth = 224;
277
278 DEBUG("Creating windows ....");
279
280 /* Create the main window */
281 mainWindow = XCreateSimpleWindow(display,
282 RootWindow(display, DefaultScreen(display)), 0, 0,
283 PLAY_WIDTH + MAIN_WIDTH + 10, PLAY_HEIGHT + MAIN_HEIGHT + 10, 2,
284 red, black);
285
286 /* Create the score window */
287 scoreWindow = XCreateSimpleWindow(display, mainWindow,
288 offsetX, 10, scoreWidth, 42, 0, white, black);
289
290 /* Create the level window */
291 levelWindow = XCreateSimpleWindow(display, mainWindow,
292 scoreWidth + offsetX + 25, 5,
293 PLAY_WIDTH + offsetX - 20 - scoreWidth, 52, 0, white, black);
294
295 /* Create the playing area window */
296 playWindow = XCreateSimpleWindow(display, mainWindow,
297 offsetX, 60, PLAY_WIDTH, PLAY_HEIGHT, 2, red, black);
298
299 /* Create the buffer playing area window NON VISIBLE */
300 bufferWindow = XCreateSimpleWindow(display, mainWindow,
301 offsetX, 60, PLAY_WIDTH, PLAY_HEIGHT, 2, red, black);
302
303 /* Create the message area window */
304 messWindow = XCreateSimpleWindow(display, mainWindow,
305 offsetX, 65 + PLAY_HEIGHT + 10, PLAY_WIDTH / 2, MESS_HEIGHT, 0,
306 white, black);
307
308 /* Create the special bonus area window */
309 specialWindow = XCreateSimpleWindow(display, mainWindow,
310 offsetX + PLAY_WIDTH / 2 + 10, 65 + PLAY_HEIGHT + 10,
311 180, MESS_HEIGHT + 5, 0, white, black);
312
313 /* Create the timer area window */
314 timeWindow = XCreateSimpleWindow(display, mainWindow,
315 offsetX + PLAY_WIDTH / 2 + 10 + 180 + 5,
316 65 + PLAY_HEIGHT + 10, PLAY_WIDTH / 8, MESS_HEIGHT + 5,
317 0, white, black);
318
319 /* Create the blocks window for editor */
320 blockWindow = XCreateSimpleWindow(display, mainWindow,
321 offsetX + PLAY_WIDTH + 15, 60, EDITOR_TOOL_WIDTH, PLAY_HEIGHT,
322 2, red, black);
323
324 /* Create the type of blocks currently active window for editor */
325 typeWindow = XCreateSimpleWindow(display, mainWindow,
326 offsetX + PLAY_WIDTH + 15, 65 + PLAY_HEIGHT + 5,
327 EDITOR_TOOL_WIDTH, TYPE_HEIGHT,
328 2, red, black);
329
330 /* Create the input dialogue window */
331 inputWindow = XCreateSimpleWindow(display, mainWindow,
332 ((PLAY_WIDTH + MAIN_WIDTH) / 2) - (DIALOGUE_WIDTH / 2),
333 ((PLAY_HEIGHT + MAIN_HEIGHT) / 2) - (DIALOGUE_HEIGHT / 2),
334 DIALOGUE_WIDTH, DIALOGUE_HEIGHT,
335 4, red, black);
336
337 DEBUG("Creating windows finished.");
338
339 /* Set window manager properties */
340 sprintf(title, "XBoing V%d.%d", VERSION, REVNUM + buildNum);
341
342 if (XStringListToTextProperty(&window_Name, 1, &windowName) == 0)
343 ShutDown(display, 1, "Cannot create window name resource.");
344
345 if (XStringListToTextProperty(&icon_Name, 1, &iconName) == 0)
346 ShutDown(display, 1, "Cannot create icon name resource.");
347
348 if (noicon == False)
349 iconWindow = SetWMIcon(display);
350
351 /* Various window manager settings */
352 wmhints.initial_state = NormalState;
353 wmhints.input = True;
354
355 if (noicon == False)
356 {
357 /* Don't create an icon if the user doesn't want it */
358 wmhints.icon_pixmap = iconPixmap;
359 wmhints.icon_window = iconWindow;
360 wmhints.flags = StateHint | InputHint | IconPixmapHint | IconWindowHint;
361 }
362 else
363 wmhints.flags = StateHint | InputHint;
364
365 /* Set the class for XBoing */
366 classhints.res_name = "XBoing";
367 classhints.res_class = "XBoing";
368
369 /* Setup the max and minimum size that the window will be */
370 sizehints.flags = PPosition | PSize | PMinSize | PMaxSize;
371 sizehints.min_width = PLAY_WIDTH + MAIN_WIDTH + 10;
372 sizehints.min_height = PLAY_HEIGHT + MAIN_HEIGHT + 10;
373 sizehints.max_width = PLAY_WIDTH + MAIN_WIDTH + 10;
374 sizehints.max_height = PLAY_HEIGHT + MAIN_HEIGHT + 10;
375
376 /* Now set the window manager properties */
377 XSetWMProperties(display, mainWindow, &windowName, &iconName,
378 argv, argc, &sizehints, &wmhints, &classhints);
379
380 DEBUG("Setting WM properties.");
381
382 if (noicon == False)
383 {
384 /* Set the current icon as the window's background pixmap */
385 XSetWindowBackgroundPixmap(display, iconWindow, iconPixmap);
386 XClearWindow(display, iconWindow);
387 }
388
389 valuemask = CWColormap;
390 winattr.colormap = colormap;
391
392 /* Check if the server allows backing store */
393 if (DoesBackingStore(XDefaultScreenOfDisplay(display)) == Always)
394 {
395 /* Ok we want backing store as it is very useful */
396 valuemask |= CWBackingStore;
397 winattr.backing_store = Always;
398 }
399
400 DEBUG("Changing window attributes.");
401
402 XChangeWindowAttributes(display, mainWindow, valuemask, &winattr);
403 XChangeWindowAttributes(display, playWindow, valuemask, &winattr);
404 XChangeWindowAttributes(display, bufferWindow, valuemask, &winattr);
405 XChangeWindowAttributes(display, levelWindow, valuemask, &winattr);
406 XChangeWindowAttributes(display, scoreWindow, valuemask, &winattr);
407 XChangeWindowAttributes(display, messWindow, valuemask, &winattr);
408 XChangeWindowAttributes(display, specialWindow, valuemask, &winattr);
409 XChangeWindowAttributes(display, timeWindow, valuemask, &winattr);
410 XChangeWindowAttributes(display, inputWindow, valuemask, &winattr);
411 XChangeWindowAttributes(display, blockWindow, valuemask, &winattr);
412 XChangeWindowAttributes(display, typeWindow, valuemask, &winattr);
413 }
414
415 #if NeedFunctionPrototypes
SetBackgrounds(Display * display,Colormap colormap)416 void SetBackgrounds(Display *display, Colormap colormap)
417 #else
418 void SetBackgrounds(display, colormap)
419 Display *display;
420 Colormap colormap;
421 #endif
422 {
423 InitialiseMainBackPixmap(display, mainWindow, colormap);
424
425 ClearMainWindow(display, mainWindow);
426 XSetWindowBackgroundPixmap(display, levelWindow, ParentRelative);
427 XClearWindow(display, levelWindow);
428 XSetWindowBackgroundPixmap(display, scoreWindow, ParentRelative);
429 XClearWindow(display, scoreWindow);
430 XSetWindowBackgroundPixmap(display, specialWindow, ParentRelative);
431 XClearWindow(display, specialWindow);
432 XSetWindowBackgroundPixmap(display, timeWindow, ParentRelative);
433 XClearWindow(display, timeWindow);
434
435 XClearWindow(display, inputWindow);
436 }
437
438 #if NeedFunctionPrototypes
MapAllWindows(Display * display)439 void MapAllWindows(Display *display)
440 #else
441 void MapAllWindows(display)
442 Display *display;
443 #endif
444 {
445 /* Actually make everything visible */
446 XMapWindow(display, specialWindow);
447 XMapWindow(display, timeWindow);
448 XMapWindow(display, messWindow);
449 XMapWindow(display, playWindow);
450 XMapWindow(display, levelWindow);
451 XMapWindow(display, scoreWindow);
452 XMapWindow(display, mainWindow);
453 XFlush(display);
454 }
455
456 #if NeedFunctionPrototypes
RedrawPlayWindow(Display * display,Window window)457 void RedrawPlayWindow(Display *display, Window window)
458 #else
459 void RedrawPlayWindow(display, window)
460 Display *display;
461 Window window;
462 #endif
463 {
464 /* Redraw the main playfield */
465 XClearWindow(display, playWindow);
466 RedrawAllBlocks(display, window);
467 RedrawPaddle(display, window);
468 RedrawBall(display, window);
469 }
470
471 #if NeedFunctionPrototypes
FreeBackgroundPixmaps(Display * display)472 void FreeBackgroundPixmaps(Display *display)
473 #else
474 void FreeBackgroundPixmaps(display)
475 Display *display;
476 #endif
477 {
478 int i;
479
480 /* Free all the backgound pixmaps */
481 if (back1Pixmap) XFreePixmap(display, back1Pixmap);
482 if (back2Pixmap) XFreePixmap(display, back2Pixmap);
483 if (back3Pixmap) XFreePixmap(display, back3Pixmap);
484 if (back4Pixmap) XFreePixmap(display, back4Pixmap);
485 if (back5Pixmap) XFreePixmap(display, back5Pixmap);
486
487 /* Free the icon and main background pixmaps */
488 if (iconPixmap) XFreePixmap(display, iconPixmap);
489 if (mainBackPixmap) XFreePixmap(display, mainBackPixmap);
490 if (spacePixmap) XFreePixmap(display, spacePixmap);
491
492 for (i = 0; i < 6; i++)
493 {
494 /* Free all devil blink eyes */
495 if (devilblink[i]) XFreePixmap(display, devilblink[i]);
496 if (devilblinkM[i]) XFreePixmap(display, devilblinkM[i]);
497 }
498 }
499
500 #if NeedFunctionPrototypes
SetWMIcon(Display * display)501 static Window SetWMIcon(Display *display)
502 #else
503 static Window SetWMIcon(display)
504 Display *display;
505 #endif
506 {
507 XpmAttributes attributes;
508 Window win, root;
509 Colormap iconcolormap;
510 int XpmErrorStatus;
511
512 /* Suss out the root window */
513 root = RootWindow(display, DefaultScreen(display));
514
515 if (!(win = XCreateSimpleWindow(display, root,
516 0, 0, 50, 50, 0, CopyFromParent, CopyFromParent)))
517 {
518 /* Well, what a bummer. Just use default icon then. */
519 ErrorMessage("Cannot create icon pixmap.");
520 return ((Window) NULL);
521 }
522
523 /* Create a new colourmap for the icon window */
524 iconcolormap = XDefaultColormap(display, XDefaultScreen(display));
525
526 /* Create all xpm pixmap blocks from the files */
527 attributes.colormap = iconcolormap;
528 attributes.valuemask = XpmColormap;
529 XpmErrorStatus = XpmCreatePixmapFromData(display, win,
530 icon_xpm, &iconPixmap, NULL, &attributes);
531 HandleXPMError(display, XpmErrorStatus, "InitialiseWMIcon()");
532
533 /* Make the new window have the new colourmap */
534 XSetWindowColormap(display, win, iconcolormap);
535
536 /* Free the background pixmap attributes */
537 XpmFreeAttributes(&attributes);
538
539 return win;
540 }
541
542 #if NeedFunctionPrototypes
DrawStageBackground(Display * display,Window window,int stageType,int clear)543 void DrawStageBackground(Display *display, Window window, int stageType,
544 int clear)
545 #else
546 void DrawStageBackground(display, window, stageType, clear)
547 Display *display;
548 Window window;
549 int stageType;
550 int clear;
551 #endif
552 {
553 char type[80];
554
555 if (debug == True)
556 {
557 sprintf(type, "Changing background to type %d.", stageType);
558 DEBUG(type);
559 }
560
561 switch (stageType)
562 {
563 case BACKGROUND_SPACE:
564 XSetWindowBackgroundPixmap(display, window, spacePixmap);
565 break;
566
567 case BACKGROUND_SEE_THRU:
568 XSetWindowBackgroundPixmap(display, window, ParentRelative);
569 break;
570
571 case BACKGROUND_BLACK:
572 XSetWindowBackground(display, window, black);
573 break;
574
575 case BACKGROUND_WHITE:
576 XSetWindowBackground(display, window, white);
577 break;
578
579 case BACKGROUND_0:
580 XSetWindowBackgroundPixmap(display, window, mainBackPixmap);
581 break;
582
583 case BACKGROUND_1:
584 XSetWindowBackgroundPixmap(display, window, back1Pixmap);
585 break;
586
587 case BACKGROUND_2:
588 XSetWindowBackgroundPixmap(display, window, back2Pixmap);
589 break;
590
591 case BACKGROUND_3:
592 XSetWindowBackgroundPixmap(display, window, back3Pixmap);
593 break;
594 case BACKGROUND_4:
595 XSetWindowBackgroundPixmap(display, window, back4Pixmap);
596 break;
597
598 case BACKGROUND_5:
599 XSetWindowBackgroundPixmap(display, window, back5Pixmap);
600 break;
601
602 default:
603 ErrorMessage("Unknown background type requested.");
604 }
605
606 /* Flush the new background */
607 if (clear == True)
608 XClearWindow(display, window);
609 }
610
611 #if NeedFunctionPrototypes
ClearDevilEyes(Display * display,Window window)612 void ClearDevilEyes(Display *display, Window window)
613 #else
614 void ClearDevilEyes(display, window)
615 Display *display;
616 Window window;
617 #endif
618 {
619 /* Clear the devil eyes from current location */
620 XClearArea(display, window,
621 devilx - DEVILEYE_WC, devily - DEVILEYE_HC,
622 DEVILEYE_WIDTH, DEVILEYE_HEIGHT, False);
623 }
624
625 #if NeedFunctionPrototypes
DrawTheDevilEye(Display * display,Window window,int x,int y,int slide)626 static void DrawTheDevilEye(Display *display, Window window, int x, int y,
627 int slide)
628 #else
629 static void DrawTheDevilEye(display, window, x, y, slide)
630 Display *display;
631 Window window;
632 int x;
633 int y;
634 int slide;
635 #endif
636 {
637 /* Draw a frame of the devil eyes */
638 RenderShape(display, window, devilblink[slide], devilblinkM[slide],
639 x - DEVILEYE_WC, y - DEVILEYE_HC, DEVILEYE_WIDTH, DEVILEYE_HEIGHT,
640 False);
641 }
642
643 #if NeedFunctionPrototypes
BlinkDevilEyes(Display * display,Window window)644 int BlinkDevilEyes(Display *display, Window window)
645 #else
646 int BlinkDevilEyes(display, window)
647 Display *display;
648 Window window;
649 #endif
650 {
651 static int slide = 0;
652 static int first = True;
653
654 if (first)
655 {
656 /* Setup the eyes */
657 devilx = PLAY_WIDTH - DEVILEYE_WC - 5;
658 devily = PLAY_HEIGHT - DEVILEYE_HC - 5;
659 first = False;
660 slide = 0;
661 }
662
663 /*ClearDevilEyes(display, playWindow);*/
664 DrawTheDevilEye(display, playWindow, devilx, devily, blinkslides[slide]);
665
666 slide++;
667 if (slide == 26)
668 {
669 first = True;
670 slide = 0;
671 return False;
672 }
673
674 return True;
675 }
676