Mercurial > fife-parpg
comparison ext/guichan-0.8.1/examples/sdlaction.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 SDL 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 SDL application with Guichan. | |
21 // The sdl.hpp file is responsible for creating and deleting | |
22 // the global Gui object. | |
23 #include "sdl.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 sdl::init(); | |
33 action::init(); | |
34 sdl::run(); | |
35 action::halt(); | |
36 sdl::halt(); | |
37 } | |
38 // Catch all Guichan exceptions. | |
39 catch (gcn::Exception e) | |
40 { | |
41 std::cerr << e.getMessage() << std::endl; | |
42 return 1; | |
43 } | |
44 // Catch all Std exceptions. | |
45 catch (std::exception e) | |
46 { | |
47 std::cerr << "Std exception: " << e.what() << std::endl; | |
48 return 1; | |
49 } | |
50 // Catch all unknown exceptions. | |
51 catch (...) | |
52 { | |
53 std::cerr << "Unknown exception" << std::endl; | |
54 return 1; | |
55 } | |
56 | |
57 return 0; | |
58 } |