1 /***************************************************************************
2 *                          Pachi el marciano                               *
3 *                          -----------------                               *
4 *                     (c) Santiago Radeff (coding)                         *
5 *                     (c) Nicolas Radeff  (graphics)                       *
6 *                     (c) Peter Hajba     (music)                          *
7 *                                                                          *
8 *                          T-1000@Bigfoot.com                              *
9 ****************************************************************************
10     *******************************************************************
11     *                                                                 *
12     *   This program is free software; you can redistribute it and/or *
13     *   modify it under the terms of the GNU General Public License   *
14     *   as published by the Free Software Foundation; either version  *
15     *   2 of the License, or (at your option) any later version.      *
16     *                                                                 *
17     *******************************************************************/
18 
show_hiscores()19 void show_hiscores()
20 {
21     SDL_SetColorKey(scorefont,SDL_SRCCOLORKEY,SDL_MapRGB(scorefont->format,0,0,0));
22     SDL_SetColorKey(scorefont1,SDL_SRCCOLORKEY,SDL_MapRGB(scorefont1->format,0,0,0));
23     SDL_SetColorKey(scorefont1,SDL_SRCCOLORKEY,SDL_MapRGB(scorefont1->format,0,0,0));
24     char plyername[]="          ";
25     char diflevel[] ="      ";
26     print_text(scorefont1,screen,16,16,30, 55,"         PACHI EL MARCIANO    TOP TEN         ");//scorename[a]);
27     print_text(scorefont1,screen,16,16,30, 95,"NAME         STAGE    TIME    LEVEL     SCORE ");//scorename[a]);
28     print_text(scorefont1,screen,16,16,30,120,"----------------------------------------------");//scorename[a]);
29     print_text(scorefont1,screen,16,16,30,535,"----------------------------------------------");//scorename[a]);
30 
31     for(int a=0; a < 10;a++)
32     {
33 	strncpy(playername,scorename[a],10);
34 	print_text(scorefont,screen,16,16,30,170+(35*a),"%s",playername);//scorename[a]);
35 	print_text(scorefont,screen,16,16,268,170+(35*a),"%d",scorestage[a]);
36 	int mins=int(scoretime[a]/60);
37 	int secs=int(scoretime[a]-(mins*60));
38 	if(secs>9)
39 	    print_text(scorefont,screen,16,16,386,170+(35*a),"%d:%d",mins,secs);
40 	else
41 	    print_text(scorefont,screen,16,16,386,170+(35*a),"%d:0%d",mins,secs);
42 
43 	if(scoredif[a]==1)
44 	    strcpy(diflevel," EASY ");
45 	if(scoredif[a]==2)
46 	    strcpy(diflevel,"NORMAL");
47 	if(scoredif[a]==3)
48 	    strcpy(diflevel," HARD ");
49 	print_text(scorefont,screen,16,16,502,170+(35*a),"%s",diflevel);
50 	print_text(scorefont,screen,16,16,672,170+(35*a),"%d",scorescore[a]);
51     }
52     SDL_Flip(screen);
53 }
54 
do_hiscores()55 void do_hiscores()
56 {
57     load_hiscoredata();
58     setback();
59     show_hiscores();
60     escape_exit=0;
61 
62     while(escape_exit==0)
63     {
64 	credits_events();
65 	SDL_Delay(1);
66     }
67     unload_hiscoredata();
68 }
69 
do_gameover()70 void do_gameover()
71 {
72     load_hiscoredata();
73 
74     char nameplayer[]="          ";
75     strncpy(playername,nameplayer,10);
76     namechar=0;
77     int highscore=0;
78     for(int a=9; a>=0;a--)
79     {
80 	if(score>scorescore[a])
81 	{
82 	    highscore=1;
83 	    scorepos=a;
84 	}
85     }
86     if(highscore==1) // si se hizo una buena puntuacion
87     {
88 	for(int b=8;b>=scorepos;b--)
89 	{
90 	    strncpy(scorename[b+1],scorename[b],10);
91 	    scorescore[b+1]=scorescore[b];
92 	    scorestage[b+1]=scorestage[b];
93 	    scoretime [b+1]=scoretime [b];
94 	    scoredif  [b+1]=scoredif  [b];
95 	}
96 	inputloop=1;
97 	SDL_Rect box;
98 	box.x=270;box.y=220;box.w=260;box.h=52;
99 	SDL_FillRect(screen,&box,SDL_MapRGB(screen->format,255,255,255));
100 	box.x=273;box.y=223;box.w=254;box.h=46;
101 	while(inputloop==1)
102 	{
103 	    hiscore_events();
104 	    SDL_FillRect(screen,&box,SDL_MapRGB(screen->format,0,0,0));
105 	    print_text(scorefont1,screen,16,16,box.x+10,box.y+5,"ENTER YOUR NAME");
106 	    print_text(scorefont1,screen,16,16,box.x+51+(namechar*16),box.y+29,".");
107 	    print_text(scorefont,screen,16,16,box.x+51,box.y+24,"%s",playername);
108 	    SDL_Flip(screen);
109 	}
110 	strncpy(scorename[scorepos],playername,10);
111 	scorescore[scorepos]=score;
112 	scorestage[scorepos]=stage;
113 	scoredif[scorepos]=dificulty;
114 	scoretime[scorepos]=int(playtime/1000);
115 	save_hiscoredata();
116     }
117 
118     unload_hiscoredata();
119 }
120 
game_over()121 void game_over()
122 {
123     do_gameover();
124     do_hiscores();
125 }
126