1
///////////////////////////////////////////////
3
// Snipe2d ludum dare 48h compo entry
8
///////////////////////////////////////////////
10
///////////////////////////////////////////////
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.
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:
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.
28
// (eg. same as ZLIB license)
30
///////////////////////////////////////////////
32
// Houses are taken from a satellite picture of glasgow.
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 =)
38
extern void fillrect (int x1, int y1, int x2, int y2, int color);
40
void init_logoscreen()
43
printf ("Initializing logo screen\n");
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); */
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);
78
SDL_Surface *logoscreen = IMG_Load(path);
79
SDL_BlitSurface(logoscreen, NULL, Game.Screen, NULL);
81
//fillrect (390, 4, 570, 35, 0x007f00);
82
//fillrect (391, 5, 569, 34, 0x003f00);
84
SDL_Flip(Game.Screen);
87
int startTick = SDL_GetTicks();
92
while ( SDL_PollEvent(&event) )
97
if (event.key.keysym.sym == SDLK_ESCAPE)
99
if (event.key.keysym.sym == SDLK_F12)
102
case SDL_MOUSEBUTTONUP:
103
if ((SDL_GetTicks() - startTick) > 500)
105
if (vertical_buttons)
107
if (hovering (456, 166, 174, 24))
114
if (hovering (456, 328, 174, 24))
116
std::cout<< "Exiting normally\n";
119
if (hovering (456, 274, 174, 24))
122
vertical_buttons = false;
124
if (hovering (456, 220, 174, 24))
129
if (hovering (29, 446, 174, 24))
134
if (hovering (238, 446, 174, 24))
138
if (hovering (437, 446, 174, 24))
140
std::cout<<"Exiting normally\n";
149
if (vertical_buttons)
151
if (!hovering (456, 166, 174, 24))
152
draw_button (gButton.startgame, 440, 160);
154
draw_button (gButton.startgameh, 440, 160);
155
if (!hovering (456, 220, 174, 24))
156
draw_button (gButton.prefs, 440, 214);
158
draw_button (gButton.prefsh, 440, 214);
159
if (!hovering (456, 274, 174, 24))
160
draw_button (gButton.hiscores, 440, 268);
162
draw_button (gButton.hiscoresh, 440, 268);
163
if (!hovering (456, 328, 174, 24))
164
draw_button (gButton.quit, 440, 322);
166
draw_button (gButton.quith, 440, 322);
168
if (!hovering (29, 446, 174, 24))
169
draw_button (gButton.startgame, 13, 440);
171
draw_button (gButton.startgameh, 13, 440);
172
if (!hovering (238, 446, 174, 24))
173
draw_button (gButton.prefs, 222, 440);
175
draw_button (gButton.prefsh, 222, 440);
176
if (!hovering (437, 446, 174, 24))
177
draw_button (gButton.quit, 431, 440);
179
draw_button (gButton.quith, 431, 440);
181
SDL_Flip (Game.Screen);
184
SDL_FreeSurface(logoscreen);