Fixed UIText class for non-uniform scale

This commit is contained in:
2021-07-29 08:21:45 -04:00
parent 31e16585d1
commit 363f28cb9c
6 changed files with 35 additions and 9 deletions

View File

@ -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);

View File

@ -36,6 +36,7 @@ public:
static SDL_Renderer *renderer;
static SDL_Event event;
// static std::vector<ColliderComponent*> colliders;
static bool debugMenu;
static bool isRunning;
static bool debugCollisionBoxes;
static bool gravityOnPlayer;