Improved scrolling.
[supertux.git] / src / leveleditor.c
1 /***************************************************************************
2  *                                                                         *
3  *   This program is free software; you can redistribute it and/or modify  *
4  *   it under the terms of the GNU General Public License as published by  *
5  *   the Free Software Foundation; either version 2 of the License, or     *
6  *   (at your option) any later version.                                   *
7  *                                                                         *
8  ***************************************************************************/
9
10 /*  December 28, 2003 - February 1st, 2004 */
11
12 /* leveleditor.c - A built-in level editor for SuperTux
13  by Ricardo Cruz <rick2@aeiou.pt>                      */
14
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <errno.h>
19 #include <unistd.h>
20 #include <SDL.h>
21 #include <SDL_image.h>
22 #include "leveleditor.h"
23
24 #include "screen.h"
25 #include "defines.h"
26 #include "globals.h"
27 #include "setup.h"
28 #include "menu.h"
29 #include "level.h"
30 #include "badguy.h"
31 #include "scene.h"
32 #include "button.h"
33
34 /* definitions to aid development */
35 #define DONE_LEVELEDITOR 1
36 #define DONE_QUIT        2
37 #define DONE_CHANGELEVEL 3
38
39 /* definitions that affect gameplay */
40 #define KEY_CURSOR_SPEED 32
41 #define KEY_CURSOR_FASTSPEED 64
42 /* when pagedown/up pressed speed:*/
43 #define PAGE_CURSOR_SPEED 13*32
44
45 #define MOUSE_LEFT_MARGIN 80
46 #define MOUSE_RIGHT_MARGIN (560-32)
47 /* right_margin should noticed that the cursor is 32 pixels,
48    so it should subtract that value */
49 #define MOUSE_POS_SPEED 20
50
51 /* gameloop funcs declerations */
52
53 void loadshared(void);
54 void unloadshared(void);
55
56 /* own declerations */
57 /* crutial ones (main loop) */
58 int le_init();
59 void le_quit();
60 void le_drawlevel();
61 void le_checkevents();
62 void le_change(float x, float y, unsigned char c);
63 void le_testlevel();
64 void le_showhelp();
65 void le_set_defaults(void);
66 void le_activate_bad_guys(void);
67
68 /* leveleditor internals */
69 static int le_level_changed;  /* if changes, ask for saving, when quiting*/
70 static int pos_x, cursor_x, cursor_y, cursor_tile, fire;
71 static int le_level;
72 static st_level le_current_level;
73 static st_subset le_level_subset;
74 static int le_show_grid;
75 static int le_frame;
76 static texture_type le_selection;
77 static int done;
78 static char le_current_tile;
79 static int le_mouse_pressed;
80 static button_type le_test_level_bt;
81 static button_type le_next_level_bt;
82 static button_type le_previous_level_bt;
83 static button_type le_rubber_bt;
84
85 static SDL_Event event;
86
87 void le_activate_bad_guys(void)
88 {
89   int x,y;
90
91   /* Activate bad guys: */
92
93   /* as oposed to the gameloop.c func, this one doesn't remove
94   the badguys from tiles                                    */
95
96   for (y = 0; y < 15; ++y)
97     for (x = 0; x < le_current_level.width; ++x)
98       if (le_current_level.tiles[y][x] >= '0' && le_current_level.tiles[y][x] <= '9')
99         add_bad_guy(x * 32, y * 32, le_current_level.tiles[y][x] - '0');
100 }
101
102 void le_set_defaults()
103 {
104   /* Set defaults: */
105
106   if(le_current_level.time_left == 0)
107     le_current_level.time_left = 255;
108 }
109
110 /* FIXME: Needs to be implemented. It should ask the user for the level(file)name and then let him create a new level based on this. */
111 void newlevel()
112 {}
113
114 /* FIXME: It should let select the user a level, which is in the leveldirectory and then load it. */
115 void selectlevel()
116 {}
117
118 int leveleditor(int levelnb)
119 {
120   int last_time, now_time;
121
122   le_level = levelnb;
123   if(le_init() != 0)
124     return 1;
125
126   while(1)
127     {
128       last_time = SDL_GetTicks();
129       le_frame++;
130
131       le_checkevents();
132
133       /* making events results to be in order */
134       if(pos_x < 0)
135         pos_x = 0;
136       if(pos_x > (le_current_level.width * 32) - screen->w)
137         pos_x = (le_current_level.width * 32) - screen->w;
138
139       /* draw the level */
140       le_drawlevel();
141
142       if(show_menu)
143         {
144           menu_process_current();
145           if(current_menu == &leveleditor_menu)
146             {
147               switch (menu_check(&leveleditor_menu))
148                 {
149                 case 0:
150                   show_menu = NO;
151                   break;
152                 case 4:
153                   done = DONE_LEVELEDITOR;
154                   break;
155                 }
156             }
157         }
158
159       if(done)
160         {
161           le_quit();
162           return 0;
163         }
164
165       if(done == DONE_QUIT)
166         {
167           le_quit();
168           return 1;
169         }
170
171       SDL_Delay(25);
172       now_time = SDL_GetTicks();
173       if (now_time < last_time + FPS)
174         SDL_Delay(last_time + FPS - now_time);  /* delay some time */
175
176       flipscreen();
177     }
178
179   return done;
180 }
181
182 int le_init()
183 {
184   subset_load(&le_level_subset,"default");
185   le_show_grid = YES;
186
187 //  level_changed = NO;
188   fire = DOWN;
189   done = 0;
190   menu_reset();
191   menu_set_current(&leveleditor_menu);
192   le_frame = 0; /* support for frames in some tiles, like waves and bad guys */
193
194   arrays_init();
195   loadshared();
196   le_set_defaults();
197
198   le_level_changed = NO;
199   if(level_load(&le_current_level, le_level_subset.name, le_level) != 0)
200     {
201       le_quit();
202       return 1;
203     }
204   if(le_current_level.time_left == 0)
205     le_current_level.time_left = 255;
206
207   level_load_gfx(&le_current_level);
208
209   le_current_tile = '.';
210   le_mouse_pressed = NO;
211   le_activate_bad_guys();
212
213   texture_load(&le_selection,DATA_PREFIX "/images/leveleditor/select.png", USE_ALPHA);
214   button_load(&le_test_level_bt,"/images/icons/test-level.png","Test Level","Press this button to test the level that is currently being edited.",150,screen->h - 64);
215   button_load(&le_next_level_bt,"/images/icons/up.png","Test Level","Press this button to test the level that is currently being edited.",screen->w-32,0);
216   button_load(&le_previous_level_bt,"/images/icons/down.png","Test Level","Press this button to test the level that is currently being edited.",screen->w-32,16);
217   button_load(&le_rubber_bt,"/images/icons/rubber.png","Test Level","Press this button to test the level that is currently being edited.",screen->w-32,32);
218
219   SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
220
221   return 0;
222 }
223
224 void le_quit(void)
225 {
226   /*if(level_changed == YES)
227     if(askforsaving() == CANCEL)
228       return;*/ //FIXME
229
230   SDL_EnableKeyRepeat(0, 0);    // disables key repeating
231
232   button_free(&le_test_level_bt);
233   level_free_gfx();
234   level_free(&le_current_level);
235   unloadshared();
236   arrays_free();
237   texture_free(&le_selection);
238 }
239
240 void le_drawlevel()
241 {
242   int y,x,i,s;
243   static char str[LEVEL_NAME_MAX];
244
245   /* Draw the real background */
246   if(le_current_level.bkgd_image[0] != '\0')
247     {
248       s = pos_x / 30;
249       texture_draw_part(&img_bkgd,s,0,0,0,img_bkgd.w - s - 32, img_bkgd.h, NO_UPDATE);
250       texture_draw_part(&img_bkgd,0,0,screen->w - s - 32 ,0,s,img_bkgd.h, NO_UPDATE);
251     }
252   else
253     {
254       clearscreen(le_current_level.bkgd_red, le_current_level.bkgd_green, le_current_level.bkgd_blue);
255     }
256
257   /*       clearscreen(current_level.bkgd_red, current_level.bkgd_green, current_level.bkgd_blue); */
258
259   for (y = 0; y < 15; ++y)
260     for (x = 0; x < 20; ++x)
261       {
262         drawshape(x * 32 - ((int)pos_x % 32), y * 32, le_current_level.tiles[y][x + (int)(pos_x / 32)]);
263
264   /* draw whats inside stuff when cursor is selecting those */
265   /* (draw them all the time - is this the right behaviour?) */
266   switch(le_current_level.tiles[y][x + (int)(pos_x/32)])
267      {
268     case 'B':
269       texture_draw(&img_mints, x * 32 - ((int)pos_x % 32), y*32, NO_UPDATE);
270       break;
271     case '!':
272       texture_draw(&img_golden_herring, x * 32 - ((int)pos_x % 32), y*32, NO_UPDATE);
273       break;
274     case 'x':
275     case 'y':
276     case 'A':
277       texture_draw(&img_distro[(frame / 5) % 4], x * 32 - ((int)pos_x % 32), y*32, NO_UPDATE);
278       break;
279     default:
280       break;
281       }
282      }
283
284   /* Draw the Bad guys: */
285   for (i = 0; i < num_bad_guys; ++i)
286     {
287       if(bad_guys[i].base.alive == NO)
288         continue;
289       /* to support frames: img_bsod_left[(frame / 5) % 4] */
290       if(bad_guys[i].kind == BAD_BSOD)
291         texture_draw(&img_bsod_left[(le_frame / 5) % 4], bad_guys[i].base.x - pos_x, bad_guys[i].base.y, NO_UPDATE);
292       else if(bad_guys[i].kind == BAD_LAPTOP)
293         texture_draw(&img_laptop_left[(le_frame / 5) % 3], bad_guys[i].base.x - pos_x, bad_guys[i].base.y, NO_UPDATE);
294       else if (bad_guys[i].kind == BAD_MONEY)
295         texture_draw(&img_money_left[(le_frame / 5) % 2], bad_guys[i].base.x - pos_x, bad_guys[i].base.y, NO_UPDATE);
296     }
297
298 /* Draw the player: */
299 // for now, the position is fixed at (0, 240)
300 texture_draw(&tux_right[(frame / 5) % 3], 0 - pos_x, 240, NO_UPDATE);
301
302   /* draw a grid (if selected) */
303   if(le_show_grid)
304     {
305       for(x = 0; x < 20; x++)
306         fillrect(x*32 - ((int)pos_x % 32), 0, 1, screen->h, 225, 225, 225,255);
307       for(y = 0; y < 15; y++)
308         fillrect(0, y*32, screen->w - 32, 1, 225, 225, 225,255);
309     }
310
311   texture_draw(&le_selection, cursor_x - pos_x, cursor_y, NO_UPDATE);
312
313   /* draw button bar */
314   fillrect(screen->w - 32, 0, 32, screen->h, 50, 50, 50,255);
315   drawshape(19 * 32, 14 * 32, le_current_tile);
316
317   button_draw(&le_test_level_bt);
318   button_draw(&le_next_level_bt);
319   button_draw(&le_previous_level_bt);
320   button_draw(&le_rubber_bt);
321
322   sprintf(str, "%d", le_current_level.time_left);
323   text_draw(&white_text, "TIME", 324, 0, 1, NO_UPDATE);
324   text_draw(&gold_text, str, 404, 0, 1, NO_UPDATE);
325
326   text_draw(&white_text, "NAME", 0, 0, 1, NO_UPDATE);
327   text_draw(&gold_text, le_current_level.name, 80, 0, 1, NO_UPDATE);
328
329   sprintf(str, "%d/%d", le_level,le_level_subset.levels);
330   text_draw(&white_text, "NUMB", 0, 20, 1, NO_UPDATE);
331   text_draw(&gold_text, str, 80, 20, 1, NO_UPDATE);
332
333   text_draw(&white_small_text, "F1 for Help", 10, 430, 1, NO_UPDATE);
334   text_draw(&white_small_text, "F2 for Testing", 150, 430, 1, NO_UPDATE);
335 }
336
337 void le_checkevents()
338 {
339   SDLKey key;
340   SDLMod keymod;
341   int x,y;
342
343   keymod = SDL_GetModState();
344
345   while(SDL_PollEvent(&event))
346     {
347       /* testing SDL_KEYDOWN, SDL_KEYUP and SDL_QUIT events*/
348       switch(event.type)
349         {
350         case SDL_KEYDOWN:       // key pressed
351           key = event.key.keysym.sym;
352           if(show_menu)
353             {
354               menu_event(&event.key.keysym);
355               break;
356             }
357           switch(key)
358             {
359             case SDLK_ESCAPE:
360               if(!show_menu)
361                 show_menu = YES;
362               else
363                 show_menu = NO;
364               break;
365             case SDLK_LEFT:
366               if(fire == DOWN)
367                 cursor_x -= KEY_CURSOR_SPEED;
368               else
369                 cursor_x -= KEY_CURSOR_FASTSPEED;
370
371               if(cursor_x < pos_x + MOUSE_LEFT_MARGIN)
372                 pos_x = cursor_x - MOUSE_LEFT_MARGIN;
373
374               break;
375             case SDLK_RIGHT:
376               if(fire == DOWN)
377                 cursor_x += KEY_CURSOR_SPEED;
378               else
379                 cursor_x += KEY_CURSOR_FASTSPEED;
380
381               if(cursor_x > pos_x + MOUSE_RIGHT_MARGIN-32)
382                 pos_x = cursor_x - MOUSE_RIGHT_MARGIN+32;
383
384               break;
385             case SDLK_UP:
386               if(fire == DOWN)
387                 cursor_y -= KEY_CURSOR_SPEED;
388               else
389                 cursor_y -= KEY_CURSOR_FASTSPEED;
390
391               if(cursor_y < 0)
392                 cursor_y = 0;
393               break;
394             case SDLK_DOWN:
395               if(fire == DOWN)
396                 cursor_y += KEY_CURSOR_SPEED;
397               else
398                 cursor_y += KEY_CURSOR_FASTSPEED;
399
400               if(cursor_y > screen->h-32)
401                 cursor_y = screen->h-32;
402               break;
403             case SDLK_LCTRL:
404               fire =UP;
405               break;
406             case SDLK_F1:
407               le_showhelp();
408               break;
409             case SDLK_F2:
410               level_save(&le_current_level,"test",le_level);
411               gameloop("test",le_level, ST_GL_TEST);
412               menu_set_current(&leveleditor_menu);
413               arrays_init();
414               level_load_gfx(&le_current_level);
415               loadshared();
416               le_activate_bad_guys();
417               break;
418             case SDLK_HOME:
419               cursor_x = 0;
420               pos_x = cursor_x;
421               break;
422             case SDLK_END:
423               cursor_x = (le_current_level.width * 32) - 32;
424               pos_x = cursor_x;
425               break;
426             case SDLK_PAGEUP:
427               cursor_x -= PAGE_CURSOR_SPEED;
428
429               if(cursor_x < pos_x + MOUSE_LEFT_MARGIN)
430                 pos_x = cursor_x - MOUSE_LEFT_MARGIN;
431
432               break;
433             case SDLK_PAGEDOWN:
434               cursor_x += PAGE_CURSOR_SPEED;
435
436               if(cursor_x > pos_x + MOUSE_RIGHT_MARGIN-32)
437                 pos_x = cursor_x - MOUSE_RIGHT_MARGIN+32;
438
439               break;
440             case SDLK_F9:
441               le_show_grid = !le_show_grid;
442               break;
443             case SDLK_PERIOD:
444               le_change(cursor_x, cursor_y, '.');
445               break;
446             case SDLK_a:
447               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
448                 le_change(cursor_x, cursor_y, 'A');
449               else
450                 le_change(cursor_x, cursor_y, 'a');
451               break;
452             case SDLK_b:
453               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
454                 le_change(cursor_x, cursor_y, 'B');
455               break;
456             case SDLK_c:
457               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
458                 le_change(cursor_x, cursor_y, 'C');
459               else
460                 le_change(cursor_x, cursor_y, 'c');
461               break;
462             case SDLK_d:
463               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
464                 le_change(cursor_x, cursor_y, 'D');
465               else
466                 le_change(cursor_x, cursor_y, 'd');
467               break;
468             case SDLK_e:
469               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
470                 le_change(cursor_x, cursor_y, 'E');
471               else
472                 le_change(cursor_x, cursor_y, 'e');
473               break;
474             case SDLK_f:
475               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
476                 le_change(cursor_x, cursor_y, 'F');
477               else
478                 le_change(cursor_x, cursor_y, 'f');
479               break;
480             case SDLK_g:
481               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
482                 le_change(cursor_x, cursor_y, 'G');
483               else
484                 le_change(cursor_x, cursor_y, 'g');
485               break;
486             case SDLK_h:
487               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
488                 le_change(cursor_x, cursor_y, 'H');
489               else
490                 le_change(cursor_x, cursor_y, 'h');
491               break;
492             case SDLK_i:
493               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
494                 le_change(cursor_x, cursor_y, 'I');
495               else
496                 le_change(cursor_x, cursor_y, 'i');
497               break;
498             case SDLK_j:
499               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
500                 le_change(cursor_x, cursor_y, 'J');
501               else
502                 le_change(cursor_x, cursor_y, 'j');
503               break;
504             case SDLK_x:
505               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
506                 le_change(cursor_x, cursor_y, 'X');
507               else
508                 le_change(cursor_x, cursor_y, 'x');
509               break;
510             case SDLK_y:
511               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
512                 le_change(cursor_x, cursor_y, 'Y');
513               else
514                 le_change(cursor_x, cursor_y, 'y');
515               break;
516             case SDLK_LEFTBRACKET:
517               le_change(cursor_x, cursor_y, '[');
518               break;
519             case SDLK_RIGHTBRACKET:
520               le_change(cursor_x, cursor_y, ']');
521               break;
522             case SDLK_HASH:
523             case SDLK_3:
524               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
525                 le_change(cursor_x, cursor_y, '#');
526               break;
527             case SDLK_DOLLAR:
528             case SDLK_4:
529               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
530                 le_change(cursor_x, cursor_y, '$');
531               break;
532             case SDLK_BACKSLASH:
533               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
534                 le_change(cursor_x, cursor_y, '|');
535               else
536                 le_change(cursor_x, cursor_y, '\\');
537               break;
538             case SDLK_CARET:
539               le_change(cursor_x, cursor_y, '^');
540               break;
541             case SDLK_AMPERSAND:
542             case SDLK_6:
543               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
544                 le_change(cursor_x, cursor_y, '&');
545               break;
546             case SDLK_EQUALS:
547             case SDLK_0:
548               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
549                 le_change(cursor_x, cursor_y, '=');
550               else              /* let's add a bad guy */
551                 le_change(cursor_x, cursor_y, '0');
552
553               add_bad_guy((((int)cursor_x/32)*32), (((int)cursor_y/32)*32), BAD_BSOD);
554               break;
555             case SDLK_1:
556               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
557                 le_change(cursor_x, cursor_y, '!');
558               else              /* let's add a bad guy */
559                 le_change(cursor_x, cursor_y, '1');
560
561               add_bad_guy((((int)cursor_x/32)*32), (((int)cursor_y/32)*32), BAD_LAPTOP);
562               break;
563             case SDLK_2:
564               le_change(cursor_x, cursor_y, '2');
565
566               add_bad_guy((((int)cursor_x/32)*32), (((int)cursor_y/32)*32), BAD_MONEY);
567               break;
568             case SDLK_PLUS:
569               if(keymod == KMOD_LSHIFT || keymod == KMOD_RSHIFT || keymod == KMOD_CAPS)
570                 le_change(cursor_x, cursor_y, '*');
571               break;
572             default:
573               break;
574             }
575           break;
576         case SDL_KEYUP: // key released
577           switch(event.key.keysym.sym)
578             {
579             case SDLK_LCTRL:
580               fire = DOWN;
581               break;
582             default:
583               break;
584             }
585           break;
586         case SDL_MOUSEBUTTONDOWN:
587           if(event.button.button == SDL_BUTTON_LEFT)
588             {
589               le_mouse_pressed = YES;
590             }
591           break;
592         case SDL_MOUSEBUTTONUP:
593           if(event.button.button == SDL_BUTTON_LEFT)
594             {
595               le_mouse_pressed = NO;
596             }
597           break;
598         case SDL_MOUSEMOTION:
599           if(!show_menu)
600             {
601               x = event.motion.x;
602               y = event.motion.y;
603
604               cursor_x = ((int)(pos_x + x) / 32) * 32;
605               cursor_y = ((int) y / 32) * 32;
606             }
607           break;
608         case SDL_QUIT:  // window closed
609           done = DONE_QUIT;
610           break;
611         default:
612           break;
613         }
614     }
615
616   if(le_mouse_pressed)
617     {
618       le_change(cursor_x, cursor_y, le_current_tile);
619       if(button_pressed(&le_test_level_bt,x,y))
620         le_testlevel();
621     }
622
623 if(!show_menu)  /* scroll screen when mouse is in a margin */
624  {
625  if(event.motion.x > MOUSE_RIGHT_MARGIN && event.motion.x < screen->w-32)
626   pos_x += MOUSE_POS_SPEED;
627  else if(event.motion.x > 0 && event.motion.x < MOUSE_LEFT_MARGIN)
628   pos_x -= MOUSE_POS_SPEED;
629  }
630 }
631
632 void le_change(float x, float y, unsigned char c)
633 {
634   int i;
635   int xx, yy;
636
637   level_change(&le_current_level,x,y,c);
638
639   yy = ((int)y / 32);
640   xx = ((int)x / 32);
641
642   /* if there is a bad guy over there, remove it */
643   for(i = 0; i < num_bad_guys; ++i)
644     if (bad_guys[i].base.alive)
645       if(xx == bad_guys[i].base.x/32 && yy == bad_guys[i].base.y/32)
646         bad_guys[i].base.alive = NO;
647 }
648
649 void le_testlevel()
650 {
651 level_save(&le_current_level,"test",le_level);
652 gameloop("test",le_level, ST_GL_TEST);
653 menu_set_current(&leveleditor_menu);
654 arrays_init();
655 level_load_gfx(&le_current_level);
656 loadshared();
657 le_activate_bad_guys();
658 }
659
660 void le_showhelp()
661 {
662   SDL_Event event;
663   int i, done;
664   char *text[] = {
665                    "X/x - Brick0",
666                    "Y/y - Brick1",
667                    "A/B/! - Box full",
668                    "a - Box empty",
669                    "C-F - Cloud0",
670                    "c-f - Cloud1",
671                    "G-J - Bkgd0",
672                    "g-j - Bkgd1",
673                    "# - Solid0",
674                    "[ - Solid1",
675                    "= - Solid2",
676                    "] - Solid3",
677                    "$ - Distro",
678                    "^ - Waves",
679                    "* - Poletop",
680                    "| - Pole",
681                    "\\ - Flag",
682                    "& - Water",
683                    "0-2 - BadGuys",
684                    "./Del - Remove tile",
685                    "F9 - Show/Hide Grid",
686                    "Esc - Menu"};
687
688
689   text_drawf(&blue_text, "- Help -", 0, 30, A_HMIDDLE, A_TOP, 2, NO_UPDATE);
690   text_draw(&gold_text, "Keys:", 80, 60, 1, NO_UPDATE);
691
692   for(i = 0; i < sizeof(text)/sizeof(char *); i++)
693     text_draw(&white_text, text[i], 40, 90+(i*16), 1, NO_UPDATE);
694
695   text_drawf(&gold_text, "Press Any Key to Continue", 0, 460, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
696
697   flipscreen();
698
699   done = 0;
700
701   while(done == 0)
702     while(SDL_PollEvent(&event))
703       switch(event.type)
704         {
705         case SDL_MOUSEBUTTONDOWN:               // mouse pressed
706         case SDL_KEYDOWN:               // key pressed
707           done = 1;
708           break;
709         default:
710           break;
711         }
712 }