1 | /* |
---|
2 | * cpptest libcaca++ rendering test |
---|
3 | * Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * $Id: cxxtest.cpp 1269 2006-10-31 14:04:22Z sam $ |
---|
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 | |
---|
14 | #include "config.h" |
---|
15 | |
---|
16 | #include <iostream> |
---|
17 | |
---|
18 | #include <cucul++.h> |
---|
19 | #include <caca++.h> |
---|
20 | |
---|
21 | using namespace std; |
---|
22 | |
---|
23 | |
---|
24 | static char const *pig[]= { |
---|
25 | " ", |
---|
26 | " _ ", |
---|
27 | " _._ _..._ .-', _.._(`)) ", |
---|
28 | " '-. ` ' /-._.-' ',/ ", |
---|
29 | " ) \\ '. ", |
---|
30 | " / _ _ | \\ ", |
---|
31 | " | a a / | ", |
---|
32 | " \\ .-. ; " , |
---|
33 | " '-('' ).-' ,' ; ", |
---|
34 | " '-; | .' ", |
---|
35 | " \\ \\ / ", |
---|
36 | " | 7 .__ _.-\\ \\ ", |
---|
37 | " | | | ``/ /` / ", |
---|
38 | " jgs /,_| | /,_/ / ", |
---|
39 | " /,_/ '`-' ", |
---|
40 | " ", |
---|
41 | NULL |
---|
42 | }; |
---|
43 | |
---|
44 | int main(int argc, char *argv[]) |
---|
45 | { |
---|
46 | Cucul *qq; |
---|
47 | Caca *kk; |
---|
48 | Event ev; |
---|
49 | |
---|
50 | int x = 0, y = 0, ix = 1, iy = 1; |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | try { |
---|
55 | qq = new Cucul(); |
---|
56 | } |
---|
57 | catch (int e) { |
---|
58 | cerr << "Error while initializing cucul (" << e << ")" << endl; |
---|
59 | return -1; |
---|
60 | } |
---|
61 | |
---|
62 | try { |
---|
63 | kk = new Caca(qq); |
---|
64 | } |
---|
65 | catch(int e) { |
---|
66 | cerr << "Error while attaching cucul to caca (" << e << ")" << endl; |
---|
67 | return -1; |
---|
68 | } |
---|
69 | |
---|
70 | kk->setDisplayTime(20000); |
---|
71 | |
---|
72 | while(!kk->getEvent(ev.CACA_EVENT_KEY_PRESS, &ev, 0)) { |
---|
73 | |
---|
74 | /* Draw pig */ |
---|
75 | qq->setColorANSI(CUCUL_LIGHTMAGENTA, CUCUL_BLACK); |
---|
76 | |
---|
77 | for(int i = 0; pig[i]; i++) |
---|
78 | qq->putStr(x, y+i, (char*)pig[i]); |
---|
79 | |
---|
80 | /* printf works */ |
---|
81 | qq->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK); |
---|
82 | qq->Printf(30,15, "Powered by libcaca %s", VERSION); |
---|
83 | |
---|
84 | /* Blit */ |
---|
85 | kk->Display(); |
---|
86 | |
---|
87 | x+=ix; |
---|
88 | y+=iy; |
---|
89 | |
---|
90 | if(x>=(qq->getWidth()-35) || x<0 ) |
---|
91 | ix=-ix; |
---|
92 | if(y>=(qq->getHeight()-15) || y<0 ) |
---|
93 | iy=-iy; |
---|
94 | |
---|
95 | |
---|
96 | } |
---|
97 | |
---|
98 | |
---|
99 | delete kk; |
---|
100 | delete qq; |
---|
101 | |
---|
102 | return 0; |
---|
103 | } |
---|