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 --- util.cpp | 89 +++++++++++++++++++++++++++++----------------------------------- 1 file changed, 40 insertions(+), 49 deletions(-) (limited to 'util.cpp') diff --git a/util.cpp b/util.cpp index 9fcdbbd..693d0ad 100644 --- a/util.cpp +++ b/util.cpp @@ -1,71 +1,62 @@ #include "util.h" -#include "mazeoflife.h" + #include -void wrap(int& x, int& y) -{ - if (x < 0) - { - x = WIDTH+x; - } else if (x >= WIDTH) - { - x = x-WIDTH; - } +#include "mazeoflife.h" - if (y < 0) - { - y = HEIGHT+y; - } else if (y >= HEIGHT) - { - y = y-HEIGHT; - } +void wrap(int& x, int& y) { + if (x < 0) { + x = WIDTH + x; + } else if (x >= WIDTH) { + x = x - WIDTH; + } + + if (y < 0) { + y = HEIGHT + y; + } else if (y >= HEIGHT) { + y = y - HEIGHT; + } } -TTF_Font* loadFont(int size) -{ - TTF_Font* tmpfont = TTF_OpenFont("resources/mono.ttf", size); +TTF_Font* loadFont(int size) { + TTF_Font* tmpfont = TTF_OpenFont("resources/mono.ttf", size); - if (tmpfont == NULL) - { - printf("Unable to load font: %s\n", TTF_GetError()); - exit(1); - } + if (tmpfont == NULL) { + printf("Unable to load font: %s\n", TTF_GetError()); + exit(1); + } - return tmpfont; + return tmpfont; } -const char* getDataFile() -{ +const char* getDataFile() { #ifdef WINDOWS - char* dir = getenv("USERPROFILE"); + char* dir = getenv("USERPROFILE"); #else - char* dir = getenv("HOME"); + char* dir = getenv("HOME"); #endif - return (std::string(dir) + "/.molhslist").c_str(); + return (std::string(dir) + "/.molhslist").c_str(); } -SDL_Texture* loadImage(SDL_Renderer* renderer, std::string file) -{ - SDL_Surface* surface = SDL_LoadBMP(file.c_str()); - if (surface == NULL) - { - std::cout << SDL_GetError() << std::endl; - return NULL; - } +SDL_Texture* loadImage(SDL_Renderer* renderer, std::string file) { + SDL_Surface* surface = SDL_LoadBMP(file.c_str()); + if (surface == NULL) { + std::cout << SDL_GetError() << std::endl; + return NULL; + } - SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface); - SDL_FreeSurface(surface); + SDL_Texture* texture = SDL_CreateTextureFromSurface(renderer, surface); + SDL_FreeSurface(surface); - return texture; + return texture; } -void applyTexture(SDL_Renderer* renderer, SDL_Texture* tex, int x, int y) -{ - SDL_Rect pos; - pos.x = x; - pos.y = y; - SDL_QueryTexture(tex, NULL, NULL, &pos.w, &pos.h); +void applyTexture(SDL_Renderer* renderer, SDL_Texture* tex, int x, int y) { + SDL_Rect pos; + pos.x = x; + pos.y = y; + SDL_QueryTexture(tex, NULL, NULL, &pos.w, &pos.h); - SDL_RenderCopy(renderer, tex, NULL, &pos); + SDL_RenderCopy(renderer, tex, NULL, &pos); } \ No newline at end of file -- cgit 1.4.1