Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print the keybindings used in the demo #73

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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