Skip to content

Commit

Permalink
Move printKeybindings into PacmanWrapper class
Browse files Browse the repository at this point in the history
  • Loading branch information
ll-nick committed Nov 15, 2024
1 parent 838b797 commit bcc4961
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 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: 0 additions & 2 deletions demo/include/utils/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ int dotsInRadius(const Position& center,
const demo::EnvironmentModel::ConstPtr& environmentModel,
int pathEndNeighborhoodRadius);

void printKeybindings();

} // namespace utils
5 changes: 2 additions & 3 deletions demo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
#include "demo/pacman_agent.hpp"
#include "demo/types.hpp"
#include "utils/pacman_wrapper.hpp"
#include "utils/utils.hpp"

using namespace demo;
using namespace utils;
using namespace arbitration_graphs;

int main() {
try {
printKeybindings();

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"
<< '\n';
}

void PacmanWrapper::renderPath(const demo::Positions& path) {
// Set path color and transparency
SDL_CHECK(SDL_SetRenderDrawColor(renderer_.get(), 0, 255, 0, 90));
Expand Down
14 changes: 0 additions & 14 deletions demo/src/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <iostream>

#include "utils/utils.hpp"

namespace utils {
Expand Down Expand Up @@ -33,16 +31,4 @@ int dotsInRadius(const Position& center,
return nDots;
}

void 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"
<< '\n';
}

} // namespace utils

0 comments on commit bcc4961

Please sign in to comment.