~ubuntu-branches/ubuntu/saucy/dd2/saucy-proposed

« back to all changes in this revision

Viewing changes to src/menu.c

  • Committer: Bazaar Package Importer
  • Author(s): Gürkan Sengün
  • Date: 2006-04-23 14:52:00 UTC
  • Revision ID: james.westby@ubuntu.com-20060423145200-wr4obk2gvkcishho
Tags: upstream-0.2.1
Import upstream version 0.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
    Dodgin' Diamond 2, a shot'em up arcade
 
4
    Copyright (C) 2003,2004 Juan J. Martinez <jjm@usebox.net>
 
5
 
 
6
    This program is free software; you can redistribute it and/or modify
 
7
    it under the terms of the GNU General Public License Version 2 as
 
8
    published by the Free Software Foundation.
 
9
 
 
10
    This program is distributed in the hope that it will be useful,
 
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with this program; if not, write to the Free Software
 
17
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
 
 
19
*/
 
20
#include"SDL.h"
 
21
#include"SDL_mixer.h"
 
22
#include"menu.h"
 
23
#include"engine.h"
 
24
#include"cfg.h"
 
25
#include"control.h"
 
26
#include"SDL_plus.h"
 
27
 
 
28
extern SDL_Surface *screen, *gfx;
 
29
extern SDL_Joystick *joy[2];
 
30
extern Mix_Chunk *efx[8];
 
31
extern Mix_Music *bgm;
 
32
extern int sound;
 
33
 
 
34
extern pDesc player[2];
 
35
 
 
36
extern score hiscore[10];
 
37
extern cfg conf;
 
38
 
 
39
extern float scroll,scroll2;
 
40
 
 
41
void soundLoad(void);
 
42
 
 
43
void
 
44
drawGetName(char *name, int place, int playern)
 
45
{
 
46
        char buffer[64];
 
47
 
 
48
        /* erase the screen */
 
49
        SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0));
 
50
 
 
51
        writeCString(gfx, screen, 90, 40, "congratulations", 0);
 
52
 
 
53
        sprintf(buffer,"player %i with score %.6li",playern,player[playern-1].score);
 
54
        writeCString(gfx, screen, 10, 80, buffer, 1);
 
55
 
 
56
        switch(place) {
 
57
                default:
 
58
                        sprintf(buffer,"you got %ith place",place);
 
59
                break;
 
60
                case 1:
 
61
                        sprintf(buffer,"you got %ist place",place);
 
62
                break;
 
63
                case 2:
 
64
                        sprintf(buffer,"you got %ind place",place);
 
65
                break;
 
66
                case 3:
 
67
                        sprintf(buffer,"you got %ird place",place);
 
68
                break;
 
69
        }
 
70
        writeCString(gfx, screen, 10, 97, buffer, 1);
 
71
 
 
72
        writeCString(gfx, screen, 10, 131, "enter your name", 0);
 
73
 
 
74
        if(name[0])
 
75
                sprintf(buffer,"%s+",name);
 
76
        else
 
77
                strcpy(buffer,"+");
 
78
 
 
79
        writeCString(gfx, screen, 175, 131, buffer, 1);
 
80
 
 
81
        SDL_Flip(screen);
 
82
}
 
83
 
 
84
int
 
85
getName(char *name, int place, int playern)
 
86
{
 
87
        Uint32 tick;
 
88
        SDL_Event mevent;
 
89
        int pos=0, i=0;
 
90
        char ckey='a';
 
91
 
 
92
        if(joy[playern-1] && player[playern-1].joy)
 
93
        {
 
94
                name[pos]=ckey;
 
95
                name[pos+1]=0;
 
96
        }
 
97
 
 
98
        drawGetName(name,place,playern);
 
99
 
 
100
        tick=SDL_GetTicks();
 
101
        while(1) {
 
102
                while(SDL_PollEvent(&mevent)) {
 
103
                        if (mevent.type==SDL_QUIT)
 
104
                                return 0;
 
105
 
 
106
                        /* joystick control */
 
107
                        if(joy[playern-1] && player[playern-1].joy)
 
108
                        {
 
109
                                SDL_JoystickUpdate();
 
110
 
 
111
                                i=SDL_JoystickGetAxis(joy[playern-1],1);
 
112
                                if(i>4200)
 
113
                                {
 
114
                                        mevent.type=SDL_KEYDOWN;
 
115
                                        mevent.key.keysym.sym=SDLK_DOWN;
 
116
                                }
 
117
                                if(i<-4200)
 
118
                                {
 
119
                                        mevent.type=SDL_KEYDOWN;
 
120
                                        mevent.key.keysym.sym=SDLK_UP;
 
121
                                }
 
122
                                i=SDL_JoystickGetAxis(joy[playern-1],0);
 
123
                                if(i>4200)
 
124
                                {
 
125
                                        mevent.type=SDL_KEYDOWN;
 
126
                                        mevent.key.keysym.sym=SDLK_RIGHT;
 
127
                                }
 
128
 
 
129
                                if(SDL_JoystickGetButton(joy[playern-1], 0))
 
130
                                {
 
131
                                        mevent.type=SDL_KEYDOWN;
 
132
                                        mevent.key.keysym.sym=SDLK_RETURN;
 
133
                                }
 
134
 
 
135
                                if(SDL_JoystickGetButton(joy[playern-1], 1))
 
136
                                {
 
137
                                        pos++;
 
138
                                        mevent.type=SDL_KEYDOWN;
 
139
                                        mevent.key.keysym.sym=SDLK_BACKSPACE;
 
140
                                }
 
141
                        }
 
142
 
 
143
                
 
144
                        if(mevent.type==SDL_KEYDOWN) {
 
145
                                if(mevent.key.keysym.sym==SDLK_ESCAPE) {
 
146
                                        if(!name[0])
 
147
                                                strcpy(name,"nobody");
 
148
                                        return 1;
 
149
                                }
 
150
 
 
151
                                if(mevent.key.keysym.sym==SDLK_DOWN)
 
152
                                {
 
153
                                        ckey--;
 
154
 
 
155
                                        if(ckey<'0')
 
156
                                                ckey='z';
 
157
                                        if(ckey+1=='a')
 
158
                                                ckey='9';
 
159
 
 
160
                                        name[pos]=ckey;
 
161
                                        name[pos+1]=0;
 
162
                                        drawGetName(name,place,playern);
 
163
 
 
164
                                        continue;
 
165
                                }
 
166
 
 
167
                                if(mevent.key.keysym.sym==SDLK_UP)
 
168
                                {
 
169
                                        ckey++;
 
170
 
 
171
                                        if(ckey>'z')
 
172
                                                ckey='0';
 
173
                                        if(ckey-1=='9')
 
174
                                                ckey='a';
 
175
 
 
176
                                        name[pos]=ckey;
 
177
                                        name[pos+1]=0;
 
178
                                        drawGetName(name,place,playern);
 
179
 
 
180
                                        continue;
 
181
                                }
 
182
                        
 
183
                                if(mevent.key.keysym.sym==SDLK_RIGHT)
 
184
                                {
 
185
                                        if(pos<8) {
 
186
                                                name[pos]=ckey;
 
187
                                                pos++;
 
188
                                                name[pos]=0;
 
189
                                                drawGetName(name,place,playern);
 
190
 
 
191
                                                ckey='a';
 
192
                                                continue;
 
193
                                        }
 
194
                                }
 
195
                                
 
196
                                if(mevent.key.keysym.sym==SDLK_RETURN)
 
197
                                        if(name[0]) {
 
198
                                                /* pirutupiiii */
 
199
                                                if(sound && efx[7])
 
200
                                                        Mix_PlayChannel(-1,efx[7],0);
 
201
                                                return 1;
 
202
                                        }
 
203
 
 
204
                                if(mevent.key.keysym.sym==SDLK_BACKSPACE) {
 
205
                                                if(pos>0) {
 
206
                                                        pos--;
 
207
                                                        name[pos]=0;
 
208
                                                        drawGetName(name,place,playern);
 
209
                                                }
 
210
                                                continue;
 
211
                                }
 
212
 
 
213
                                /* I don't know if this will work ever, in my system does */
 
214
                                if((mevent.key.keysym.sym>=SDLK_a &&
 
215
                                        mevent.key.keysym.sym<=SDLK_z) ||
 
216
                                        (mevent.key.keysym.sym>=SDLK_0 &&
 
217
                                        mevent.key.keysym.sym<=SDLK_9)) {
 
218
                                                if(pos<8) {
 
219
                                                        name[pos]=SDLK2ascii(mevent.key.keysym.sym);
 
220
                                                        pos++;
 
221
                                                        name[pos]=0;
 
222
                                                        drawGetName(name,place,playern);
 
223
 
 
224
                                                        ckey='a';
 
225
                                                }
 
226
                                }
 
227
                        }
 
228
                }
 
229
        }
 
230
 
 
231
        return 0;
 
232
}
 
233
 
 
234
void
 
235
drawHiscores(int max)
 
236
{
 
237
        int i;
 
238
        SDL_Rect a,b;
 
239
 
 
240
        /* erase the screen */
 
241
        SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0));
 
242
 
 
243
        /* DD2 characters */
 
244
        a.x=60;
 
245
        a.y=5;
 
246
        b.x=450;
 
247
        b.y=43;
 
248
        b.w=211;
 
249
        b.h=190;
 
250
        SDL_BlitSurface(gfx, &b, screen, &a);
 
251
 
 
252
        /* header */
 
253
        writeCString(gfx, screen, 80, 2, "the hall of fame", 1);
 
254
 
 
255
        for(i=0;i<max;i++) {
 
256
                writeNumber(gfx, screen, 10, 23+i*17, i+1, 2);
 
257
                writeCString(gfx, screen, 30, 20+i*17, hiscore[i].name, 0);
 
258
                writeCString(gfx, screen, 180, 20+i*17, "st",0);
 
259
                writeNumber(gfx, screen, 200, 23+i*17, hiscore[i].stage,2);
 
260
                writeCString(gfx, screen, 236, 20+i*17, "sc",0);
 
261
                writeNumber(gfx, screen, 260, 23+i*17, hiscore[i].score,6);
 
262
        }
 
263
 
 
264
        SDL_Flip(screen);
 
265
}
 
266
 
 
267
int
 
268
hiscores()
 
269
{
 
270
        Uint32 tick;
 
271
        SDL_Event mevent;
 
272
        int i;
 
273
 
 
274
        for(i=0;i<10;i++) {
 
275
                drawHiscores(i+1);
 
276
                SDL_Delay(300);
 
277
        }
 
278
 
 
279
        tick=SDL_GetTicks();
 
280
        while(1) {
 
281
                while(SDL_PollEvent(&mevent)) {
 
282
                if (mevent.type==SDL_QUIT)
 
283
                        return 0;
 
284
                        if(mevent.type==SDL_KEYDOWN) {
 
285
                                return 1;
 
286
                        }
 
287
                }
 
288
                /* wait some time and return */
 
289
                if(SDL_GetTicks()-tick>10000) {
 
290
                        /* pirutupiiii */
 
291
                        if(sound && efx[7])
 
292
                                Mix_PlayChannel(-1,efx[7],0);
 
293
                        return 1;
 
294
                }
 
295
        }
 
296
 
 
297
        return 0;
 
298
}
 
299
 
 
300
void
 
301
drawConfigure(int option)
 
302
{
 
303
        /* erase the screen */
 
304
        SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0));
 
305
 
 
306
        /* options */
 
307
        writeCString(gfx, screen, 20, 20,  "player 1", 0);
 
308
        if(conf.control[0]==KEYBOARD)
 
309
                writeCString(gfx, screen, 20, 37,  "   keyboard", (option==1));
 
310
        else
 
311
                writeCString(gfx, screen, 20, 37,  "   joystick 1", (option==1));
 
312
        writeCString(gfx, screen, 20, 54,  "player 2", 0);
 
313
        if(conf.control[1]==KEYBOARD)
 
314
                writeCString(gfx, screen, 20, 71,  "   keyboard", (option==2));
 
315
        else
 
316
                writeCString(gfx, screen, 20, 71,  "   joystick 2", (option==2));
 
317
        writeCString(gfx, screen, 20, 105,  "sound", 0);
 
318
        switch(conf.sound) {
 
319
                default:
 
320
                case SOUND_HI:
 
321
                        writeCString(gfx, screen, 20, 122,  "   high quality", (option==3));
 
322
                break;
 
323
                case SOUND_MED:
 
324
                        writeCString(gfx, screen, 20, 122,  "   medium quality", (option==3));
 
325
                break;
 
326
                case SOUND_LOW:
 
327
                        writeCString(gfx, screen, 20, 122,  "   low quality", (option==3));
 
328
                break;
 
329
                case NO_SOUND:
 
330
                        writeCString(gfx, screen, 20, 122,  "   no sound", (option==3));
 
331
                break;
 
332
        }
 
333
        writeCString(gfx, screen, 20, 139,  "graphic mode", 0);
 
334
        if(conf.fullscreen)
 
335
                writeCString(gfx, screen, 20, 156,  "   fullscreen", (option==4));
 
336
        else
 
337
                writeCString(gfx, screen, 20, 156,  "   windowed", (option==4));
 
338
 
 
339
        SDL_Flip(screen);
 
340
}
 
341
 
 
342
int
 
343
configure()
 
344
{
 
345
        SDL_Event mevent;
 
346
        int option=1,i;
 
347
 
 
348
        drawConfigure(option);
 
349
 
 
350
        while(1) {
 
351
                while(SDL_PollEvent(&mevent)) {
 
352
                        if (mevent.type==SDL_QUIT)
 
353
                                return 0;
 
354
 
 
355
                        /* joystick control for the menu */
 
356
                        if(joy[0])
 
357
                        {
 
358
                                SDL_JoystickUpdate();
 
359
 
 
360
                                i=SDL_JoystickGetAxis(joy[0],1);
 
361
                                if(i>4200)
 
362
                                {
 
363
                                        mevent.type=SDL_KEYDOWN;
 
364
                                        mevent.key.keysym.sym=SDLK_DOWN;
 
365
                                }
 
366
                                if(i<-4200)
 
367
                                {
 
368
                                        mevent.type=SDL_KEYDOWN;
 
369
                                        mevent.key.keysym.sym=SDLK_UP;
 
370
                                }
 
371
 
 
372
                                if(SDL_JoystickGetButton(joy[0], 0))
 
373
                                {
 
374
                                        mevent.type=SDL_KEYDOWN;
 
375
                                        mevent.key.keysym.sym=SDLK_RETURN;
 
376
                                }
 
377
 
 
378
                                if(SDL_JoystickGetButton(joy[0], 1))
 
379
                                {
 
380
                                        mevent.type=SDL_KEYDOWN;
 
381
                                        mevent.key.keysym.sym=SDLK_ESCAPE;
 
382
                                }
 
383
                        }
 
384
 
 
385
                        if(mevent.type==SDL_KEYDOWN) {
 
386
                                if(mevent.key.keysym.sym==SDLK_ESCAPE)
 
387
                                        return 1;
 
388
                                if(mevent.key.keysym.sym==SDLK_DOWN ||
 
389
                                        mevent.key.keysym.sym==SDLK_s) {
 
390
                                        option++;
 
391
                                        if(option>4)
 
392
                                                option=1;
 
393
                                        drawConfigure(option);
 
394
                                }
 
395
                                if(mevent.key.keysym.sym==SDLK_UP ||
 
396
                                        mevent.key.keysym.sym==SDLK_w) {
 
397
                                        option--;
 
398
                                        if(option<1)
 
399
                                                option=4;
 
400
                                        drawConfigure(option);
 
401
                                }
 
402
                                if(mevent.key.keysym.sym==SDLK_RETURN) {
 
403
                                        switch(option) {
 
404
                                                default:
 
405
                                                break;
 
406
                                                case 1:
 
407
                                                        if(joy[0]) {
 
408
                                                                conf.control[0]=conf.control[0] ? 0 : 1;
 
409
                                                                drawConfigure(option);
 
410
                                                        }
 
411
                                                break;
 
412
                                                case 2:
 
413
                                                        if(joy[1]) {
 
414
                                                                conf.control[1]=conf.control[1] ? 0 : 1;
 
415
                                                                drawConfigure(option);
 
416
                                                        }
 
417
                                                break;
 
418
                                                case 3:
 
419
                                                        conf.sound--;
 
420
                                                        if(conf.sound<0)
 
421
                                                                conf.sound=3;
 
422
 
 
423
                                                        if(sound) {
 
424
                                                                if(bgm) {
 
425
                                                                        Mix_FreeMusic(bgm);
 
426
                                                                        bgm=NULL;
 
427
                                                                }
 
428
 
 
429
                                                                for(i=0;i<NUM_EFX;i++)
 
430
                                                                        if(efx[i]) {
 
431
                                                                                Mix_FreeChunk(efx[i]);
 
432
                                                                                efx[i]=NULL;
 
433
                                                                        }
 
434
                                                                Mix_CloseAudio();
 
435
                                                        }
 
436
 
 
437
                                                        if(conf.sound!=NO_SOUND) {
 
438
                                                                switch(conf.sound) {
 
439
                                                                                default:
 
440
                                                                                case SOUND_HI:
 
441
                                                                                        i=44100;
 
442
                                                                                break;
 
443
                                                                                case SOUND_MED:
 
444
                                                                                        i=22050;
 
445
                                                                                break;
 
446
                                                                                case SOUND_LOW:
 
447
                                                                                        i=16000;
 
448
                                                                                break;
 
449
                                                                }
 
450
                                                                if(Mix_OpenAudio(i, MIX_DEFAULT_FORMAT, 2, 2048)<0) {
 
451
                                                                        fprintf(stderr, "Unable to set audio: %s\n", SDL_GetError());
 
452
                                                                        sound=0;
 
453
                                                                } else {
 
454
                                                                        soundLoad();
 
455
                                                                        if(efx[7])
 
456
                                                                                Mix_PlayChannel(-1,efx[7],0);
 
457
                                                                        sound=1;
 
458
                                                                }
 
459
                                                        }
 
460
                                                        drawConfigure(option);
 
461
                                                break;
 
462
                                                case 4:
 
463
                                                        conf.fullscreen=conf.fullscreen ? 0 : 1;
 
464
                                                        drawConfigure(option);
 
465
                                                break;
 
466
                                        }
 
467
                                }
 
468
                        }
 
469
                }
 
470
        }
 
471
 
 
472
        return 0;
 
473
}
 
474
 
 
475
void
 
476
drawMenu(int option)
 
477
{
 
478
        SDL_Rect a,b;
 
479
 
 
480
        /* erase the screen */
 
481
        SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0));
 
482
 
 
483
        /* BETA */
 
484
        a.x=77;
 
485
        a.y=20;
 
486
        b.x=100;
 
487
        b.y=46;
 
488
        b.w=166;
 
489
        b.h=15;
 
490
        SDL_BlitSurface(gfx, &b, screen, &a);
 
491
 
 
492
        /* options */
 
493
        writeCString(gfx, screen, 105, 50,  "one player", (option==1));
 
494
        writeCString(gfx, screen, 105, 67,  "two players", (option==2));
 
495
        writeCString(gfx, screen, 105, 94, "hall of fame", (option==3));
 
496
        writeCString(gfx, screen, 105, 111, "configure", (option==4));
 
497
        writeCString(gfx, screen, 105, 138, "about", (option==5));
 
498
        writeCString(gfx, screen, 105, 155, "exit game", (option==6));
 
499
 
 
500
        /* some credit */
 
501
        a.x=154;
 
502
        a.y=184;
 
503
        b.x=268;
 
504
        b.y=57;
 
505
        b.w=166;
 
506
        b.h=16;
 
507
        SDL_BlitSurface(gfx, &b, screen, &a);
 
508
 
 
509
        SDL_Flip(screen);
 
510
}
 
511
 
 
512
int
 
513
menu()
 
514
{
 
515
        SDL_Event mevent;
 
516
        int option=1, i;
 
517
 
 
518
        /* pirutupiiii */
 
519
        if(efx[7])
 
520
                Mix_PlayChannel(-1,efx[7],0);
 
521
 
 
522
        drawMenu(option);
 
523
 
 
524
        /* some dirty init */
 
525
        scroll=scroll2=0;
 
526
 
 
527
        while(1) {
 
528
                while(SDL_PollEvent(&mevent)) {
 
529
                        if (mevent.type==SDL_QUIT)
 
530
                                return 0;
 
531
 
 
532
                        /* joystick control for the menu */
 
533
                        if(joy[0])
 
534
                        {
 
535
                                SDL_JoystickUpdate();
 
536
 
 
537
                                i=SDL_JoystickGetAxis(joy[0],1);
 
538
                                if(i>4200)
 
539
                                {
 
540
                                        mevent.type=SDL_KEYDOWN;
 
541
                                        mevent.key.keysym.sym=SDLK_DOWN;
 
542
                                }
 
543
                                if(i<-4200)
 
544
                                {
 
545
                                        mevent.type=SDL_KEYDOWN;
 
546
                                        mevent.key.keysym.sym=SDLK_UP;
 
547
                                }
 
548
 
 
549
                                if(SDL_JoystickGetButton(joy[0], 0))
 
550
                                {
 
551
                                        mevent.type=SDL_KEYDOWN;
 
552
                                        mevent.key.keysym.sym=SDLK_RETURN;
 
553
                                }
 
554
 
 
555
                                if(SDL_JoystickGetButton(joy[0], 1))
 
556
                                {
 
557
                                        mevent.type=SDL_KEYDOWN;
 
558
                                        mevent.key.keysym.sym=SDLK_ESCAPE;
 
559
                                }
 
560
                        }
 
561
                        
 
562
                        if(mevent.type==SDL_KEYDOWN) {
 
563
                                if(mevent.key.keysym.sym==SDLK_ESCAPE)
 
564
                                        return 0;
 
565
                                if(mevent.key.keysym.sym==SDLK_DOWN ||
 
566
                                        mevent.key.keysym.sym==SDLK_s) {
 
567
                                        option++;
 
568
                                        if(option>6)
 
569
                                                option=1;
 
570
                                        drawMenu(option);
 
571
                                }
 
572
                                if(mevent.key.keysym.sym==SDLK_UP ||
 
573
                                        mevent.key.keysym.sym==SDLK_w) {
 
574
                                        option--;
 
575
                                        if(option<1)
 
576
                                                option=6;
 
577
                                        drawMenu(option);
 
578
                                }
 
579
                                if(mevent.key.keysym.sym==SDLK_RETURN) {
 
580
                                        switch(option) {
 
581
                                                default:
 
582
                                                break;
 
583
                                                case 1:
 
584
                                                        player[0].shield=10;
 
585
                                                        player[1].shield=0;
 
586
                                                        player[0].score=player[1].score=0;
 
587
                                                        player[0].stage=player[1].stage=0;
 
588
                                                        return 1;
 
589
                                                case 2:
 
590
                                                        player[0].shield=10;
 
591
                                                        player[1].shield=10;
 
592
                                                        player[0].score=player[1].score=0;
 
593
                                                        player[0].stage=player[1].stage=0;
 
594
                                                        return 1;
 
595
                                                case 3:
 
596
                                                        if(!hiscores())
 
597
                                                                return 0;
 
598
                                                        drawMenu(option);
 
599
                                                break;
 
600
                                                case 4:
 
601
                                                        if(!configure())
 
602
                                                                return 0;
 
603
                                                        drawMenu(option);
 
604
                                                break;
 
605
                                                case 5:
 
606
                                                        if(!credits())
 
607
                                                                return 0;
 
608
                                                        drawMenu(option);
 
609
                                                break;
 
610
                                                case 6:
 
611
                                                        return 0;
 
612
                                                break;
 
613
                                        }
 
614
                                }
 
615
                        }
 
616
                }
 
617
        }
 
618
 
 
619
        return 0;
 
620
}
 
621
 
 
622
void
 
623
drawCredits()
 
624
{
 
625
        SDL_Rect a,b;
 
626
        
 
627
        /* erase the screen */
 
628
        SDL_FillRect(screen,NULL,SDL_MapRGB(screen->format,0,0,0));
 
629
 
 
630
        /* BETA */
 
631
        a.x=77;
 
632
        a.y=20;
 
633
        b.x=100;
 
634
        b.y=46;
 
635
        b.w=166;
 
636
        b.h=15;
 
637
        SDL_BlitSurface(gfx, &b, screen, &a);
 
638
 
 
639
        writeCString(gfx, screen, 20, 50, "this is dd2 version " VERSION ".", 0);
 
640
        writeCString(gfx, screen, 20, 80, "main author", 1);
 
641
        writeCString(gfx, screen, 40, 105, "juan j. martinez", 0);
 
642
        writeCString(gfx, screen, 40, 140, "thanks you for playing...", 0);
 
643
        
 
644
        SDL_Flip(screen);
 
645
}
 
646
 
 
647
int
 
648
credits()
 
649
{
 
650
        Uint32 tick;
 
651
        SDL_Event mevent;
 
652
 
 
653
        drawCredits();
 
654
 
 
655
        tick=SDL_GetTicks();
 
656
        while(1) {
 
657
                while(SDL_PollEvent(&mevent)) {
 
658
                if (mevent.type==SDL_QUIT)
 
659
                        return 0;
 
660
                        if(mevent.type==SDL_KEYDOWN) {
 
661
                                return 1;
 
662
                        }
 
663
                }
 
664
                /* wait some time and return */
 
665
                if(SDL_GetTicks()-tick>10000) {
 
666
                        /* pirutupiiii */
 
667
                        if(sound && efx[7])
 
668
                                Mix_PlayChannel(-1,efx[7],0);
 
669
                        return 1;
 
670
                }
 
671
        }
 
672
 
 
673
        return 0;
 
674
}
 
675