You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

104 lines
2.3 KiB

  1. /*
  2. * cpptest libcaca++ rendering test
  3. * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the Do What The Fuck You Want To
  10. * Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. #include "config.h"
  14. #include <iostream>
  15. #include <cucul++.h>
  16. #include <caca++.h>
  17. using namespace std;
  18. static char const *pig[]= {
  19. " ",
  20. " _ ",
  21. " _._ _..._ .-', _.._(`)) ",
  22. " '-. ` ' /-._.-' ',/ ",
  23. " ) \\ '. ",
  24. " / _ _ | \\ ",
  25. " | a a / | ",
  26. " \\ .-. ; " ,
  27. " '-('' ).-' ,' ; ",
  28. " '-; | .' ",
  29. " \\ \\ / ",
  30. " | 7 .__ _.-\\ \\ ",
  31. " | | | ``/ /` / ",
  32. " jgs /,_| | /,_/ / ",
  33. " /,_/ '`-' ",
  34. " ",
  35. NULL
  36. };
  37. int main(int argc, char *argv[])
  38. {
  39. Cucul *qq;
  40. Caca *kk;
  41. Event ev;
  42. int x = 0, y = 0, ix = 1, iy = 1;
  43. try {
  44. qq = new Cucul();
  45. }
  46. catch (int e) {
  47. cerr << "Error while initializing cucul (" << e << ")" << endl;
  48. return -1;
  49. }
  50. try {
  51. kk = new Caca(qq);
  52. }
  53. catch(int e) {
  54. cerr << "Error while attaching cucul to caca (" << e << ")" << endl;
  55. return -1;
  56. }
  57. kk->setDisplayTime(20000);
  58. while(!kk->getEvent(ev.CACA_EVENT_KEY_PRESS, &ev, 0)) {
  59. /* Draw pig */
  60. qq->setColor(CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);
  61. for(int i = 0; pig[i]; i++)
  62. qq->putStr(x, y+i, (char*)pig[i]);
  63. /* printf works */
  64. qq->setColor(CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_BLACK);
  65. qq->Printf(30,15, "Powered by libcaca %s", VERSION);
  66. /* Blit */
  67. kk->Display();
  68. x+=ix;
  69. y+=iy;
  70. if(x>=(qq->getWidth()-35) || x<0 )
  71. ix=-ix;
  72. if(y>=(qq->getHeight()-15) || y<0 )
  73. iy=-iy;
  74. }
  75. delete kk;
  76. delete qq;
  77. return 0;
  78. }