| 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 | #include <stdarg.h> |
| 39 | |
| 40 | void print(int aXofs, int aYofs, int aColor, const char *aString, ...) |
| 41 | { |
| 42 | va_list arglist; |
| 43 | char cbuf[4096]; |
| 44 | char *cp = cbuf; |
| 45 | va_start(arglist,aString); |
| 46 | vsprintf(cbuf,aString,arglist); |
| 47 | va_end(arglist); |
| 48 | |
| 49 | SDL_Rect srcRect, tgtRect; |
| 50 | tgtRect.x = aXofs; |
| 51 | tgtRect.y = aYofs; |
| 52 | tgtRect.w = srcRect.w = 4; |
| 53 | tgtRect.h = srcRect.h = 6; |
| 54 | srcRect.x = 0; |
| 55 | while (*cp) |
| 56 | { |
| 57 | srcRect.y = (*cp - 32) * 6; |
| 58 | SDL_BlitSurface(Game.Font[aColor], &srcRect, Game.Screen, &tgtRect); |
| 59 | cp++; |
| 60 | tgtRect.x += 4; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | void printShadow(int aXofs, int aYofs, const char *aString, ...) |
| 65 | { |
| 66 | va_list arglist; |
| 67 | char cbuf[4096]; |
| 68 | char *cp = cbuf; |
| 69 | va_start(arglist,aString); |
| 70 | vsprintf(cbuf,aString,arglist); |
| 71 | va_end(arglist); |
| 72 | |
| 73 | SDL_Rect srcRect, tgtRect; |
| 74 | tgtRect.x = aXofs + 1; |
| 75 | tgtRect.y = aYofs + 1; |
| 76 | tgtRect.w = srcRect.w = 4; |
| 77 | tgtRect.h = srcRect.h = 6; |
| 78 | srcRect.x = 0; |
| 79 | while (*cp) |
| 80 | { |
| 81 | srcRect.y = (*cp - 32) * 6; |
| 82 | SDL_BlitSurface(Game.Font[0], &srcRect, Game.Screen, &tgtRect); |
| 83 | cp++; |
| 84 | tgtRect.x += 4; |
| 85 | } |
| 86 | tgtRect.x = aXofs; |
| 87 | tgtRect.y = aYofs; |
| 88 | cp = cbuf; |
| 89 | while (*cp) |
| 90 | { |
| 91 | srcRect.y = (*cp - 32) * 6; |
| 92 | SDL_BlitSurface(Game.Font[1], &srcRect, Game.Screen, &tgtRect); |
| 93 | cp++; |
| 94 | tgtRect.x += 4; |
| 95 | } |
| 96 | |
| 97 | } |
| 98 | |
| 99 |