Debian Codegraph @

src/logoscreen.cpp

raw symbols SCIP
1 ///////////////////////////////////////////////
2 //
3 // Snipe2d ludum dare 48h compo entry
4 //
5 // Jari Komppa aka Sol
6 // http://iki.fi/sol
7 //
8 ///////////////////////////////////////////////
9 // License
10 ///////////////////////////////////////////////
11 //
12 // This software is provided 'as-is', without any express or implied
13 // warranty. In no event will the authors be held liable for any damages
14 // arising from the use of this software.
15 //
16 // Permission is granted to anyone to use this software for any purpose,
17 // including commercial applications, and to alter it and redistribute it
18 // freely, subject to the following restrictions:
19 //
20 // 1. The origin of this software must not be misrepresented; you must not
21 // claim that you wrote the original software. If you use this software
22 // in a product, an acknowledgment in the product documentation would be
23 // appreciated but is not required.
24 // 2. Altered source versions must be plainly marked as such, and must not be
25 // misrepresented as being the original software.
26 // 3. This notice may not be removed or altered from any source distribution.
27 //
28 // (eg. same as ZLIB license)
29 //
30 ///////////////////////////////////////////////
31 //
32 // Houses are taken from a satellite picture of glasgow.
33 //
34 // The sources are a mess, as I didn't even try to do anything
35 // really organized here.. and hey, it's a 48h compo =)
36 //
37 #include "snipe2d.h"
38 extern void fillrect (int x1, int y1, int x2, int y2, int color);
39
40 void init_logoscreen()
41 {
42 /* char path[256];
43 printf ("Initializing logo screen\n");
44
45 // Note the lack of error checking. Bad, bad, bad.
46 snprintf (path, 256, "%s/1.png", mediaPath);
47 pbut.lv[0] = IMG_Load (path);
48 snprintf (path, 256, "%s/2.png", mediaPath);
49 pbut.lv[1] = IMG_Load (path);
50 snprintf (path, 256, "%s/3.png", mediaPath);
51 pbut.lv[2] = IMG_Load (path);
52 snprintf (path, 256, "%s/easy.png", mediaPath);
53 pbut.easy = IMG_Load (path);
54 snprintf (path, 256, "%s/medium.png", mediaPath);
55 pbut.med = IMG_Load (path);
56 snprintf (path, 256, "%s/hard.png", mediaPath);
57 pbut.hard = IMG_Load (path);
58 snprintf (path, 256, "%s/audio.png", mediaPath);
59 pbut.audio = IMG_Load (path);
60 snprintf (path, 256, "%s/fullscreen.png", mediaPath);
61 pbut.fullscreen = IMG_Load (path);
62 snprintf (path, 256, "%s/newgame.png", mediaPath);
63 pbut.newgame = IMG_Load (path);
64 snprintf (path, 256, "%s/quit.png", mediaPath);
65 pbut.quit = IMG_Load (path);
66 snprintf (path, 256, "%s/resumegame.png", mediaPath);
67 pbut.resumegame = IMG_Load (path); */
68 }
69
70 #if 0
71 void logoscreen()
72 {
73 bool vertical_buttons = true;
74 const char *logoscreen_img = "logoscreen.png";
75 char path[ strlen(mediaPath) + 1 + strlen(logoscreen_img) + 1 ];
76 sprintf(path, "%s/%s", mediaPath, logoscreen_img);
77
78 SDL_Surface *logoscreen = IMG_Load(path);
79 SDL_BlitSurface(logoscreen, NULL, Game.Screen, NULL);
80
81 //fillrect (390, 4, 570, 35, 0x007f00);
82 //fillrect (391, 5, 569, 34, 0x003f00);
83
84 SDL_Flip(Game.Screen);
85 init();
86 int go = 0;
87 int startTick = SDL_GetTicks();
88 SDL_ShowCursor(1);
89 while (!go)
90 {
91 SDL_Event event;
92 while ( SDL_PollEvent(&event) )
93 {
94 switch (event.type)
95 {
96 case SDL_KEYUP:
97 if (event.key.keysym.sym == SDLK_ESCAPE)
98 exit(0);
99 if (event.key.keysym.sym == SDLK_F12)
100 show_hiscores();
101 break;
102 case SDL_MOUSEBUTTONUP:
103 if ((SDL_GetTicks() - startTick) > 500)
104 {
105 if (vertical_buttons)
106 {
107 if (hovering (456, 166, 174, 24))
108 {
109 go = 1;
110 SDL_ShowCursor(0);
111 }
112 else go = 0;
113 SDL_ShowCursor(1);
114 if (hovering (456, 328, 174, 24))
115 {
116 std::cout<< "Exiting normally\n";
117 exit (0);
118 }
119 if (hovering (456, 274, 174, 24))
120 {
121 show_hiscores();
122 vertical_buttons = false;
123 }
124 if (hovering (456, 220, 174, 24))
125 {
126 prefs();
127 }
128 } else {
129 if (hovering (29, 446, 174, 24))
130 {
131 go = 1;
132 SDL_ShowCursor(0);
133 }
134 if (hovering (238, 446, 174, 24))
135 {
136 prefs();
137 }
138 if (hovering (437, 446, 174, 24))
139 {
140 std::cout<<"Exiting normally\n";
141 exit (0);
142 }
143 }
144 }
145 break;
146 case SDL_QUIT:
147 exit(0);
148 }
149 if (vertical_buttons)
150 {
151 if (!hovering (456, 166, 174, 24))
152 draw_button (gButton.startgame, 440, 160);
153 else
154 draw_button (gButton.startgameh, 440, 160);
155 if (!hovering (456, 220, 174, 24))
156 draw_button (gButton.prefs, 440, 214);
157 else
158 draw_button (gButton.prefsh, 440, 214);
159 if (!hovering (456, 274, 174, 24))
160 draw_button (gButton.hiscores, 440, 268);
161 else
162 draw_button (gButton.hiscoresh, 440, 268);
163 if (!hovering (456, 328, 174, 24))
164 draw_button (gButton.quit, 440, 322);
165 else
166 draw_button (gButton.quith, 440, 322);
167 } else {
168 if (!hovering (29, 446, 174, 24))
169 draw_button (gButton.startgame, 13, 440);
170 else
171 draw_button (gButton.startgameh, 13, 440);
172 if (!hovering (238, 446, 174, 24))
173 draw_button (gButton.prefs, 222, 440);
174 else
175 draw_button (gButton.prefsh, 222, 440);
176 if (!hovering (437, 446, 174, 24))
177 draw_button (gButton.quit, 431, 440);
178 else
179 draw_button (gButton.quith, 431, 440);
180 }
181 SDL_Flip (Game.Screen);
182 }
183 }
184 SDL_FreeSurface(logoscreen);
185 }
186 #endif /* 0 */