Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Two examples of how your Main.cpp could look for assignment 2.
- This is all you need in the "main" file - our entry point:
- */
- //Main.cpp, example 1
- #include "Pong.h"
- int main(int argc, char* argv[]) {
- try {
- Pong game; //init sdl, holds and inits all game objects
- game.run(); //Pong::run implements entire game loop, returns when player quit
- } //game, and all things in it (incl. sdl), destroyed via dtor
- catch (const std::runtime_error& e) {
- std::cerr << e.what() << std::endl;
- return 1;
- }
- catch(...){
- std::cerr << "terribad error" << std::endl;
- return 1;
- }
- return 0
- }
- /*or perhaps, if it makes your Pong-class cleaner: */
- //Main.cpp, example2
- #include "Pong.h"
- int main(int argc, char* argv[]) {
- try {
- Pong game; //init sdl, init game objects, in ctor
- while (!game.doQuit()) { //controls the game-loop
- game.update(); //Pong::update implements our game-loop *body*
- }
- } //quit sdl and destroy everything game owns, via dtor
- catch (const std::runtime_error& e) {
- std::cerr << e.what() << std::endl;
- return 1;
- }
- catch(...){
- std::cerr << "terribad error" << std::endl;
- return 1;
- }
- return 0
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement