home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 November / Chip_2002-11_cd1.bin / oddech / orbital / orbital.exe / src / prints.cpp < prev    next >
C/C++ Source or Header  |  2002-07-14  |  3KB  |  99 lines

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