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.
 
 
 
 
 
 

102 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 <iostream>
  14. #include <cucul++.h>
  15. #include <caca++.h>
  16. using namespace std;
  17. static char const *pig[]= {
  18. " ",
  19. " _ ",
  20. " _._ _..._ .-', _.._(`)) ",
  21. " '-. ` ' /-._.-' ',/ ",
  22. " ) \\ '. ",
  23. " / _ _ | \\ ",
  24. " | a a / | ",
  25. " \\ .-. ; " ,
  26. " '-('' ).-' ,' ; ",
  27. " '-; | .' ",
  28. " \\ \\ / ",
  29. " | 7 .__ _.-\\ \\ ",
  30. " | | | ``/ /` / ",
  31. " jgs /,_| | /,_/ / ",
  32. " /,_/ '`-' ",
  33. " ",
  34. NULL
  35. };
  36. int main(int argc, char *argv[])
  37. {
  38. Cucul *qq;
  39. Caca *kk;
  40. Event ev;
  41. int x = 0, y = 0, ix = 1, iy = 1;
  42. try {
  43. qq = new Cucul();
  44. }
  45. catch (int e) {
  46. cerr << "Error while initializing cucul (" << e << ")" << endl;
  47. return -1;
  48. }
  49. try {
  50. kk = new Caca(qq);
  51. }
  52. catch(int e) {
  53. cerr << "Error while attaching cucul to caca (" << e << ")" << endl;
  54. return -1;
  55. }
  56. kk->set_delay(20000);
  57. while(!kk->get_event(ev.CACA_EVENT_KEY_PRESS, &ev, 0)) {
  58. /* Draw pig */
  59. qq->set_color(CUCUL_COLOR_LIGHTMAGENTA, CUCUL_COLOR_BLACK);
  60. for(int i = 0; pig[i]; i++)
  61. qq->putstr(x, y+i, (char*)pig[i]);
  62. /* printf works */
  63. qq->set_color(CUCUL_COLOR_LIGHTBLUE, CUCUL_COLOR_BLACK);
  64. qq->printf(30,15, "Powered by libcaca %s", VERSION);
  65. /* Blit */
  66. kk->display();
  67. x+=ix;
  68. y+=iy;
  69. if(x>=(qq->get_width()-35) || x<0 )
  70. ix=-ix;
  71. if(y>=(qq->get_height()-15) || y<0 )
  72. iy=-iy;
  73. }
  74. delete kk;
  75. delete qq;
  76. return 0;
  77. }