diff --git a/build/BeagleRescue b/build/BeagleRescue index bbd7827..cc20496 100755 Binary files a/build/BeagleRescue and b/build/BeagleRescue differ diff --git a/src/ecs/KeyboardController.h b/src/ecs/KeyboardController.h index f0e31bb..155d572 100644 --- a/src/ecs/KeyboardController.h +++ b/src/ecs/KeyboardController.h @@ -83,6 +83,9 @@ public: break; } } +// =============================================== +// ON KEY UP +// =============================================== else if (Game::event.type == SDL_KEYUP) { switch (Game::event.key.keysym.sym) @@ -128,6 +131,13 @@ public: case SDLK_u: break; case SDLK_i: + break; + case SDLK_d: + if (Game::debugMenu == false){ + Game::debugMenu = true;} + else { + Game::debugMenu = false; + } break; case SDLK_ESCAPE: // exit the game when Escape pressed Game::isRunning = false; diff --git a/src/game/Game.cpp b/src/game/Game.cpp index 529281d..cd28403 100644 --- a/src/game/Game.cpp +++ b/src/game/Game.cpp @@ -28,6 +28,10 @@ UIText* text; UINineSlice* my9Slice; UIText* scoreboardText; UINineSlice* scoreboard9Slice; +UINineSlice* debugBox; +UIText* debugStaticText; +UIText* debugdynamicText; + GameStateManager* Game::gsm = new GameStateManager(); SDL_Renderer* Game::renderer = nullptr; @@ -38,6 +42,7 @@ SDL_Rect Game::camera; AssetManager* Game::assets = new AssetManager(&manager); bool Game::isRunning = false; +bool Game::debugMenu = false; auto& player(manager.addEntity()); @@ -48,9 +53,7 @@ auto& puppy(manager.addEntity()); auto& uiInfo(manager.addEntity()); bool Game::debugCollisionBoxes = false; - bool Game::gravityOnPlayer = true; - bool Game::playerIsGrounded = false; int gScale = 0; @@ -134,6 +137,18 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g my9Slice = new UINineSlice("textBox"); my9Slice->MakeSlices("textBox",32,32,14,16,14,16,myDestRect,globalScale); + // debug UI box + std::string debugStaticString = "Debug info"; + debugStaticText = new UIText(debugStaticString, "font", 0,0,8,12,1); + text->ParseString(debugStaticString,240*globalScale,44,1,"debug"); + SDL_Rect debugBoxRect = SDL_Rect(); + debugBoxRect.x = 240*globalScale; + debugBoxRect.y = 8*globalScale; + debugBoxRect.w = 80*globalScale; + debugBoxRect.h = 80*globalScale; + debugBox = new UINineSlice("textBox"); + debugBox->MakeSlices("textBox",32,32,14,16,14,16,debugBoxRect,1); + //ecs implementation map->LoadMap("assets/maps/br-map-color.txt",70,45, globalScale); diff --git a/src/game/Game.hpp b/src/game/Game.hpp index 5176e0c..9c7c1b8 100644 --- a/src/game/Game.hpp +++ b/src/game/Game.hpp @@ -36,6 +36,7 @@ public: static SDL_Renderer *renderer; static SDL_Event event; // static std::vector colliders; + static bool debugMenu; static bool isRunning; static bool debugCollisionBoxes; static bool gravityOnPlayer; diff --git a/src/ui/UIText.cpp b/src/ui/UIText.cpp index 9305483..5f7daed 100644 --- a/src/ui/UIText.cpp +++ b/src/ui/UIText.cpp @@ -31,7 +31,7 @@ UIText::~UIText() { } -void UIText::ParseString(std::string inputText, int x, int y, int scale, std::string tag) +void UIText::ParseString(std::string inputText, int x, int y, int letterScale, std::string tag) { //Parse input text into an array of char int posX = x; @@ -64,18 +64,18 @@ void UIText::ParseString(std::string inputText, int x, int y, int scale, std::st posX = x; posY += letterHeight; } - UIText::AddLetter(posX, posY, current, tag); + UIText::AddLetter(posX, posY, current, tag, letterScale); current = inputText[i]; } while ((strcmp(¤t,"\0"))!=0); } -void UIText::AddLetter(int xpos, int ypos, char crnt, std::string tag) +void UIText::AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrScale) { auto& letter(manager.addEntity()); - letter.addComponent(xpos*scale, ypos*scale, letterWidth, letterHeight, 1); + letter.addComponent(xpos*lttrScale, ypos*lttrScale, letterWidth, letterHeight, 1); // printf("Scale: %d\n",scale); - letter.addComponent("font", SpriteComponent::spriteText, crnt, letterWidth, letterHeight, scale); + letter.addComponent("font", SpriteComponent::spriteText, crnt, letterWidth, letterHeight, lttrScale); letter.setTag(tag); letter.addGroup(Game::groupUI_Layer1); } diff --git a/src/ui/UIText.h b/src/ui/UIText.h index 2df464c..19dcbb8 100644 --- a/src/ui/UIText.h +++ b/src/ui/UIText.h @@ -24,8 +24,8 @@ public: ~UIText(); // void SetCharClips(SDL_Texture* fontTex, int x, int y, int letterW, int letterH); - void AddLetter(int xpos, int ypos, char crnt, std::string tag); - void ParseString(std::string inputText, int x, int y, int scale, std::string tag); + void AddLetter(int xpos, int ypos, char crnt, std::string tag, int lttrScale); + void ParseString(std::string inputText, int x, int y, int letterScale, std::string tag); int scale; };