Skip to content

Commit

Permalink
Merge pull request #104 from KIT-MRT/make_window_resizable
Browse files Browse the repository at this point in the history
Add flag allowing the Pac-Man GUI to be resized
  • Loading branch information
ll-nick authored Feb 11, 2025
2 parents 4762731 + 3b6bd50 commit 41baa3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions demo/include/utils/pacman_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class PacmanWrapper {
bool pause_{false};
bool quit_{false};
bool renderPath_{false};
bool fullscreen_{false};
};

} // namespace utils
12 changes: 11 additions & 1 deletion demo/src/pacman_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SDL::Window createWindow(int scaleFactor) {
SDL_WINDOWPOS_CENTERED,
tilesPx.x * scaleFactor,
tilesPx.y * scaleFactor,
SDL_WINDOW_SHOWN))};
SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE))};
}

SDL::Renderer createRendererAndSetLogicalSize(const SDL::Window& window) {
Expand Down Expand Up @@ -75,6 +75,15 @@ void PacmanWrapper::handleUserInput() {
renderPath_ = !renderPath_;
break;
}
if (event.key.keysym.scancode == SDL_SCANCODE_F) {
fullscreen_ = !fullscreen_;
if (fullscreen_) {
SDL_SetWindowFullscreen(window_.get(), SDL_WINDOW_FULLSCREEN);
} else {
SDL_SetWindowFullscreen(window_.get(), 0);
}
break;
}
}
}
}
Expand Down Expand Up @@ -117,6 +126,7 @@ void PacmanWrapper::printKeybindings() {
<< "\033[1;36m=====================================\033[0m\n"
<< " \033[1;32mESC/Q\033[0m - Quit the demo\n"
<< " \033[1;32mSpace\033[0m - Pause the demo\n"
<< " \033[1;32mF\033[0m - Toggle fullscreen mode\n"
<< " \033[1;32mP\033[0m - Toggle path visualization\n"
<< "\033[1;36m=====================================\033[0m\n"
<< " \033[1;32mGUI\033[0m - Open http://localhost:8080\n"
Expand Down

0 comments on commit 41baa3a

Please sign in to comment.