Mercurial > fife-parpg
comparison ext/guichan-0.8.1/examples/allegroaction.cpp @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /** | |
2 * This is an example that demonstrates how to use actions | |
3 * in Guichan. The example uses the Allegro back end. | |
4 */ | |
5 | |
6 #include <guichan.hpp> | |
7 #include <iostream> | |
8 | |
9 // Here we store a global Gui object. We make it global | |
10 // so it's easily accessable. Of course, global variables | |
11 // should normally be avioded when it comes to OOP, but | |
12 // this examples is not an example that shows how to make a | |
13 // good and clean C++ application but merely an example | |
14 // that shows how to use Guichan. | |
15 namespace globals | |
16 { | |
17 gcn::Gui* gui; | |
18 } | |
19 | |
20 // Include code to set up an Allegro application with Guichan. | |
21 // The allegro.hpp file is responsible for creating and deleting | |
22 // the global Gui object. | |
23 #include "allegro.hpp" | |
24 // Include code to set up a Guichan GUI that demonstrates how | |
25 // to use actions in Guichan. The code populates the global Gui object. | |
26 #include "action.hpp" | |
27 | |
28 int main(int argc, char **argv) | |
29 { | |
30 try | |
31 { | |
32 allegro::init(); | |
33 action::init(); | |
34 allegro::run(); | |
35 action::halt(); | |
36 allegro::halt(); | |
37 } | |
38 /* | |
39 * Catch all Guichan exceptions | |
40 */ | |
41 catch (gcn::Exception e) | |
42 { | |
43 std::cerr << e.getMessage() << std::endl; | |
44 return 1; | |
45 } | |
46 /* | |
47 * Catch all Std exceptions | |
48 */ | |
49 catch (std::exception e) | |
50 { | |
51 std::cerr << "Std exception: " << e.what() << std::endl; | |
52 return 1; | |
53 } | |
54 /* | |
55 * Catch all Unknown exceptions | |
56 */ | |
57 catch (...) | |
58 { | |
59 std::cerr << "Unknown exception" << std::endl; | |
60 return 1; | |
61 } | |
62 | |
63 return 0; | |
64 } | |
65 END_OF_MAIN() |