From 45d6e635c880a7fae8711fba366519dd314d9faf Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 2 Nov 2023 09:17:25 -0400 Subject: Formatted source code --- mazeoflife.cpp | 100 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 49 insertions(+), 51 deletions(-) (limited to 'mazeoflife.cpp') diff --git a/mazeoflife.cpp b/mazeoflife.cpp index cf21d2a..952fbdb 100644 --- a/mazeoflife.cpp +++ b/mazeoflife.cpp @@ -1,61 +1,59 @@ #include "mazeoflife.h" + #include -#include #include +#include + #include #include #include + #include "state.h" #include "titlestate.h" -int main(int argc, char *argv[]) -{ - srand(time(NULL)); - - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) - { - printf("Could not initialize SDL: %s.\n", SDL_GetError()); - exit(-1); - } - - if (TTF_Init() == -1) - { - printf("Could not initialize SDL_ttf: %s.\n", TTF_GetError()); - exit(-1); - } - - if (SDLNet_Init() == -1) - { - printf("Cound not initalize SDL_net: %s.\n", SDLNet_GetError()); - exit(-1); - } - - SDL_Window* window = SDL_CreateWindow("Maze of Life", 100, 100, 480, 480, SDL_WINDOW_SHOWN); - if (window == NULL) - { - std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl; - return 1; - } - - SDL_Surface* icon = SDL_LoadBMP("resources/icon.bmp"); - SDL_SetWindowIcon(window, icon); - - SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); - if (renderer == NULL) - { - std::cout << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl; - return 1; - } - - State* state = new TitleState(); - while (state != NULL) - { - state = (*state)(window, renderer); - } - - SDL_DestroyRenderer(renderer); - SDL_DestroyWindow(window); - SDLNet_Quit(); - TTF_Quit(); - SDL_Quit(); +int main(int argc, char* argv[]) { + srand(time(NULL)); + + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) { + printf("Could not initialize SDL: %s.\n", SDL_GetError()); + exit(-1); + } + + if (TTF_Init() == -1) { + printf("Could not initialize SDL_ttf: %s.\n", TTF_GetError()); + exit(-1); + } + + if (SDLNet_Init() == -1) { + printf("Cound not initalize SDL_net: %s.\n", SDLNet_GetError()); + exit(-1); + } + + SDL_Window* window = + SDL_CreateWindow("Maze of Life", 100, 100, 480, 480, SDL_WINDOW_SHOWN); + if (window == NULL) { + std::cout << "SDL_CreateWindow Error: " << SDL_GetError() << std::endl; + return 1; + } + + SDL_Surface* icon = SDL_LoadBMP("resources/icon.bmp"); + SDL_SetWindowIcon(window, icon); + + SDL_Renderer* renderer = SDL_CreateRenderer( + window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); + if (renderer == NULL) { + std::cout << "SDL_CreateRenderer Error: " << SDL_GetError() << std::endl; + return 1; + } + + State* state = new TitleState(); + while (state != NULL) { + state = (*state)(window, renderer); + } + + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + SDLNet_Quit(); + TTF_Quit(); + SDL_Quit(); } \ No newline at end of file -- cgit 1.4.1