home *** CD-ROM | disk | FTP | other *** search
- ///////////////////////////////////////////////
- //
- // Snipe2d ludum dare 48h compo entry
- //
- // Jari Komppa aka Sol
- // http://iki.fi/sol
- //
- ///////////////////////////////////////////////
- // License
- ///////////////////////////////////////////////
- //
- // This software is provided 'as-is', without any express or implied
- // warranty. In no event will the authors be held liable for any damages
- // arising from the use of this software.
- //
- // Permission is granted to anyone to use this software for any purpose,
- // including commercial applications, and to alter it and redistribute it
- // freely, subject to the following restrictions:
- //
- // 1. The origin of this software must not be misrepresented; you must not
- // claim that you wrote the original software. If you use this software
- // in a product, an acknowledgment in the product documentation would be
- // appreciated but is not required.
- // 2. Altered source versions must be plainly marked as such, and must not be
- // misrepresented as being the original software.
- // 3. This notice may not be removed or altered from any source distribution.
- //
- // (eg. same as ZLIB license)
- //
- ///////////////////////////////////////////////
- //
- // Houses are taken from a satellite picture of glasgow.
- //
- // The sources are a mess, as I didn't even try to do anything
- // really organized here.. and hey, it's a 48h compo =)
- //
- #include "snipe2d.h"
-
- void fillrect(int x1, int y1, int x2, int y2, int color)
- {
- SDL_Rect r;
- r.x = x1;
- r.y = y1;
- r.w = x2-x1;
- r.h = y2-y1;
- int sdlcolor = SDL_MapRGB(gScreen->format,
- (color >> 16) & 0xff,
- (color >> 8) & 0xff,
- (color >> 0) & 0xff);
- SDL_FillRect(gScreen, &r, sdlcolor);
- }
-
- void gameoverscreen(int aReason)
- {
- gGameState = 0;
- fillrect(0,0,640,480,0);
- fillrect(159,59,461,421,0x007f00);
- fillrect(160,60,460,420,0x003f00);
- fillrect(159,80,461,81,0x007f00);
- print(290, 68, COLOR_GREEN, "game over");
- print(260 + 8, 400, COLOR_GREEN, "click to play again");
- print(260 + 12, 412, COLOR_GREEN, "press ESC to quit");
- int row = 88 + 40;
- switch (aReason)
- {
- case 0:
- printShadow(240, row, "You left your post!"); row += 8;
- break;
- case 1:
- printShadow(240, row, "You shot a VIP!"); row += 8;
- break;
- case 2:
- printShadow(240, row, "You let a VIP die!"); row += 8;
- break;
- }
- row += 8;
- printShadow(240, row, "The VIP protection bureau has found your "); row += 8;
- printShadow(240, row, "actions unacceptable, and thus has decided"); row += 8;
- printShadow(240, row, "to let you go."); row += 8;
- row += 8;
- print(240, row, (gScore<=0)?COLOR_RED:COLOR_GREEN, "Your final score was: %d", gScore); row += 8;
- row += 8;
- row += 8;
- row += 8;
- printShadow(240, row, "Based on your score, your retirement will be:"); row += 8;
- row += 8;
- if (gScore < -10000)
- printShadow(240, row, "Slow and extremely painful.");
- else
- if (gScore < 0)
- printShadow(240, row, "Quick and painless.");
- else
- if (gScore < 25000)
- printShadow(240, row, "Poor.");
- else
- if (gScore < 50000)
- printShadow(240, row, "Decent.");
- else
- if (gScore < 100000)
- printShadow(240, row, "Above average.");
- else
- printShadow(240, row, "Welcome to heaven, baby!");
- row += 8;
- row += 8;
- row += 8;
- row += 8;
- printShadow(240, row, "Stats:"); row += 8;
- row += 8;
- printShadow(240, row, "Threats neutralized:%4d", gBadGuisKilled); row += 8;
- printShadow(240, row, "VIPs with safe trip:%4d", gVIPsGottenToSafety); row += 8;
- printShadow(240, row, "Pedestrians wasted: %4d", gPedestriansKilled); row += 8;
- printShadow(240, row, "Game time: %02d:%02d", ((GetTickCount() - gGameStartTick) / 60000), ((GetTickCount() - gGameStartTick) / 1000)%60); row += 8;
-
-
-
-
- int i = 0;
- for (i = 0; i < 56; i++)
- print(162, 83 + i * 6, COLOR_YELLOW, "%u%u", rand(), rand());
- SDL_UpdateRect(gScreen, 0, 0, 640, 480);
- int go = 0;
- int startTick = GetTickCount();
- while (1)
- {
- SDL_Event event;
- while ( SDL_PollEvent(&event) )
- {
- switch (event.type)
- {
- case SDL_KEYUP:
- if (event.key.keysym.sym == SDLK_ESCAPE)
- exit(0);
- break;
- case SDL_MOUSEBUTTONUP:
- if ((GetTickCount() - startTick) > 500)
- return;
- break;
- case SDL_QUIT:
- exit(0);
- }
- }
- }
- }