~ubuntu-branches/ubuntu/raring/libcaca/raring

« back to all changes in this revision

Viewing changes to cxx/cxxtest.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar (Debian packages)
  • Date: 2007-11-25 19:08:40 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071125190840-3r4k9nkxsyo7m3ck
Tags: 0.99.beta13b-1
* New upstream release.

* debian/control:
  + Do not build-depend on the whole texlive suite, but on more fine-grained
    packages. Thanks to Norbert Preining for the hints (latex -recorder, then
    inspect the .fls file).
* Ship libcaca++, libcucul++ and their development files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 *  http://sam.zoy.org/wtfpl/COPYING for more details.
13
13
 */
14
14
 
15
 
#include "config.h"
16
 
 
17
15
#include <iostream>
18
16
 
19
17
#include <cucul++.h>
41
39
 
42
40
int main(int argc, char *argv[])
43
41
{
44
 
    Cucul *qq, *pig;
45
 
    Caca  *kk;
46
 
    Event ev;
 
42
    Cucul *cv, *pig;
 
43
    Caca  *dp;
47
44
 
48
45
    int x = 0, y = 0, ix = 1, iy = 1;
49
46
 
50
47
    try {
51
 
        qq = new Cucul();
 
48
        cv = new Cucul();
52
49
    }
53
50
    catch (int e) {
54
51
        cerr << "Error while initializing cucul (" << e << ")" << endl;
56
53
    }
57
54
 
58
55
    try {
59
 
        kk = new Caca(qq);
 
56
        dp = new Caca(cv);
60
57
    }
61
58
    catch(int e) {
62
59
        cerr << "Error while attaching cucul to caca (" << e << ")" << endl;
74
71
        return -1;
75
72
    }
76
73
 
77
 
    kk->setDisplayTime(20000);
78
 
 
79
 
    while(!kk->getEvent(ev.CACA_EVENT_KEY_PRESS, &ev, 0)) {
80
 
 
 
74
    dp->setDisplayTime(20000);
 
75
 
 
76
    while(!dp->getEvent(Event::CACA_EVENT_KEY_PRESS, NULL, 0))
 
77
    {
81
78
 
82
79
        /* In case of resize ...*/
83
 
        if((x + pig->getWidth())-1 >= qq->getWidth() || x < 0 )
 
80
        if((x + pig->getWidth())-1 >= cv->getWidth() || x < 0 )
84
81
            x = 0;
85
 
        if((y + pig->getHeight())-1 >= qq->getHeight() || y < 0 )
 
82
        if((y + pig->getHeight())-1 >= cv->getHeight() || y < 0 )
86
83
            y = 0;
87
84
 
88
 
 
89
 
 
90
 
 
91
 
        qq->Clear();
 
85
        cv->Clear();
92
86
 
93
87
        /* Draw pig */
94
 
        qq->Blit(x, y, pig, NULL);
 
88
        cv->Blit(x, y, pig, NULL);
95
89
 
96
90
        /* printf works */
97
 
        qq->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK);
98
 
        qq->Printf(qq->getWidth() / 2 - 10, qq->getHeight() / 2,
99
 
                   "Powered by libcaca %s", VERSION);
 
91
        cv->setColorANSI(CUCUL_LIGHTBLUE, CUCUL_BLACK);
 
92
        cv->Printf(cv->getWidth() / 2 - 10, cv->getHeight() / 2,
 
93
                   "Powered by libcaca %s", dp->getVersion());
100
94
 
101
95
        /* Blit */
102
 
        kk->Display();
 
96
        dp->Display();
103
97
 
104
98
        x += ix;
105
99
        y += iy;
106
100
 
107
 
        if(x + pig->getWidth() >= qq->getWidth() || x < 0 )
 
101
        if(x + pig->getWidth() >= cv->getWidth() || x < 0 )
108
102
            ix = -ix;
109
 
        if(y + pig->getHeight() >= qq->getHeight() || y < 0 )
 
103
        if(y + pig->getHeight() >= cv->getHeight() || y < 0 )
110
104
            iy = -iy;
111
105
 
112
106
    }
113
107
 
114
 
    delete kk;
115
 
    delete qq;
 
108
    delete dp;
 
109
    delete pig;
 
110
    delete cv;
116
111
 
117
112
    return 0;
118
113
}