Skip to content

Commit

Permalink
Merge pull request #73 from KIT-MRT/print_demo_keybindings
Browse files Browse the repository at this point in the history
Print the keybindings when launching the demo #patch
  • Loading branch information
ll-nick authored Nov 15, 2024
2 parents 58c1ff0 + ae89071 commit 8e86842
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions demo/include/utils/pacman_wrapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class PacmanWrapper {
return game_;
}

void printKeybindings();

private:
void handleUserInput();
void renderPath(const demo::Positions& path);
Expand Down
2 changes: 2 additions & 0 deletions demo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ using namespace arbitration_graphs;
int main() {
try {
PacmanWrapper demo;
demo.printKeybindings();

PacmanAgent agent(demo.game());

gui::WebServer server(8080, true);
Expand Down
14 changes: 14 additions & 0 deletions demo/src/pacman_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "utils/pacman_wrapper.hpp"

#include <iostream>

#include <SDL2/SDL_main.h>

#include <pacman/core/constants.hpp>
Expand Down Expand Up @@ -108,6 +110,18 @@ void PacmanWrapper::progressGame(const demo::Command& command,
FrameCap sync{fps};
}

void PacmanWrapper::printKeybindings() {
std::cout << "\n"
<< "\033[1;36m=====================================\033[0m\n"
<< "\033[1;37m CONTROLS \033[0m\n"
<< "\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;32mP\033[0m - Toggle path visualization\n"
<< "\033[1;36m=====================================\033[0m\n"
<< std::endl;
}

void PacmanWrapper::renderPath(const demo::Positions& path) {
// Set path color and transparency
SDL_CHECK(SDL_SetRenderDrawColor(renderer_.get(), 0, 255, 0, 90));
Expand Down

0 comments on commit 8e86842

Please sign in to comment.