refactored Text, box UI and reconfigured config.json
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
{
|
||||
"GameName":"Beagle Rescue",
|
||||
"WindowName":"Beagle Rescue",
|
||||
"WindowSize":{"w":427,"h":240},
|
||||
"GameName":"Kaiju Save Earth",
|
||||
"WindowName":"Kaiju Save Earth",
|
||||
"WindowSize":{"w":64,"h":64},
|
||||
"WindowFullScreen": 0,
|
||||
"GlobalScale": 2
|
||||
"GlobalScale": 12
|
||||
}
|
||||
|
@ -46,6 +46,13 @@ bool Game::debugMenu = false;
|
||||
auto& player(manager.addEntity());
|
||||
Vector2D Game::playerPosition;
|
||||
Vector2D Game::pVel;
|
||||
Vector2D Game::fontSize;
|
||||
Vector2D Game::nineSliceSize;
|
||||
|
||||
int Game::nineSliceX0 = 4;
|
||||
int Game::nineSliceX1 = 12;
|
||||
int Game::nineSliceY0 = 4;
|
||||
int Game::nineSliceY1 = 12;
|
||||
|
||||
// auto& enemy(manager.addEntity());
|
||||
auto& puppy(manager.addEntity());
|
||||
@ -136,8 +143,8 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
}
|
||||
|
||||
assets->AddTexture("player", "assets/textures/actors/firefighter.png");
|
||||
assets->AddTexture("font", "assets/textures/ui/ui-font-cloud-sans.png");
|
||||
assets->AddTexture("textBox", "assets/textures/ui/ui-element-cloud.png");
|
||||
assets->AddTexture("font", "assets/textures/ui/ui-font-lorez5.png");
|
||||
assets->AddTexture("textBox", "assets/textures/ui/ui-element-bubble.png");
|
||||
assets->AddTexture("puppy","assets/textures/actors/beaglepuppy.png");
|
||||
assets->AddTexture("collider","assets/textures/ColTex.png");
|
||||
|
||||
@ -151,9 +158,13 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
// map = new Map("terrain",globalScale,16);
|
||||
// std::string myText = "Find lost puppies!\nThey need your help!";
|
||||
std::string myText = "Press U to Start";
|
||||
|
||||
|
||||
//Set Font and UI NineSlice Sizes here
|
||||
fontSize = Vector2D(5,5);
|
||||
nineSliceSize = Vector2D(16,16);
|
||||
|
||||
uiTextInstructions.addComponent<TransformComponent>(18,22,138*gScale,20*gScale,gScale);
|
||||
uiTextInstructions.addComponent<UITextComponent>("font",myText,8,12,gScale);
|
||||
uiTextInstructions.addComponent<UITextComponent>("font",myText,fontSize.x,fontSize.y,gScale);
|
||||
uiTextInstructions.addGroup(groupUI_Layer1);
|
||||
|
||||
SDL_Rect myDestRect = SDL_Rect();
|
||||
@ -162,42 +173,42 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
myDestRect.w = 160;
|
||||
myDestRect.h = 40;
|
||||
my9Slice = new UINineSlice("textBox");
|
||||
my9Slice->MakeSlices("textBox",32,32,14,16,14,16,myDestRect,globalScale,Game::groupUI_Layer0);
|
||||
my9Slice->MakeSlices("textBox",nineSliceSize.x,nineSliceSize.y,nineSliceX0,nineSliceX1,nineSliceY0,nineSliceY1,myDestRect,globalScale,Game::groupUI_Layer0);
|
||||
|
||||
// std::cout << "camera.w " << camera.w << std::endl;
|
||||
|
||||
uiInfo.addComponent<TransformComponent>(camera.w/gScale-94,10,72*gScale,96*gScale,gScale);
|
||||
// uiInfo.addComponent<UITextComponent>("font", "CollisionHori: Vert: Jump: P.y : P.dy: YVec: ", 8, 12, 1);
|
||||
// uiInfo.addComponent<UITextComponent>("font", "Player PTiX: PTiY: P.x: P.y : coll: Px2: tson: ", 8, 12, gScale);
|
||||
uiInfo.addComponent<UITextComponent>("font", "Player PTiX: PTiY: P.x: P.y : coll: ", 8, 12, gScale);
|
||||
// uiInfo.addComponent<UITextComponent>("font", "CollisionHori: Vert: Jump: P.y : P.dy: YVec: ", fontSize.x,fontSize.y, 1);
|
||||
// uiInfo.addComponent<UITextComponent>("font", "Player PTiX: PTiY: P.x: P.y : coll: Px2: tson: ", fontSize.x,fontSize.y, gScale);
|
||||
uiInfo.addComponent<UITextComponent>("font", "Player PTiX: PTiY: P.x: P.y : coll: ", fontSize.x,fontSize.y, gScale);
|
||||
uiInfo.addGroup(groupUI_Layer3);
|
||||
|
||||
uiCamXInfo.addComponent<TransformComponent>(camera.w/gScale-48,23,40*gScale,12*gScale,gScale);
|
||||
uiCamXInfo.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
|
||||
uiCamXInfo.addComponent<UITextComponent>("font", "nan", fontSize.x,fontSize.y, gScale);
|
||||
uiCamXInfo.addGroup(groupUI_Layer3);
|
||||
|
||||
uiCamYInfo.addComponent<TransformComponent>(camera.w/gScale-48,36,40*gScale,12*gScale,gScale);
|
||||
uiCamYInfo.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
|
||||
uiCamYInfo.addComponent<UITextComponent>("font", "nan", fontSize.x,fontSize.y, gScale);
|
||||
uiCamYInfo.addGroup(groupUI_Layer3);
|
||||
|
||||
uiPlayerXInfo.addComponent<TransformComponent>(camera.w/gScale-49,49,40*gScale,12*gScale,gScale);
|
||||
uiPlayerXInfo.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
|
||||
uiPlayerXInfo.addComponent<UITextComponent>("font", "nan", fontSize.x,fontSize.y, gScale);
|
||||
uiPlayerXInfo.addGroup(groupUI_Layer3);
|
||||
|
||||
uiPlayerYInfo.addComponent<TransformComponent>(camera.w/gScale-48,62,40*gScale,12*gScale,gScale);
|
||||
uiPlayerYInfo.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
|
||||
uiPlayerYInfo.addComponent<UITextComponent>("font", "nan",fontSize.x,fontSize.y, gScale);
|
||||
uiPlayerYInfo.addGroup(groupUI_Layer3);
|
||||
|
||||
uiBoundary1Info.addComponent<TransformComponent>(camera.w/gScale-48,75,128*gScale,12*gScale,gScale);
|
||||
uiBoundary1Info.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
|
||||
uiBoundary1Info.addComponent<UITextComponent>("font", "nan",fontSize.x,fontSize.y, gScale);
|
||||
uiBoundary1Info.addGroup(groupUI_Layer3);
|
||||
|
||||
// uiBoundary2Info.addComponent<TransformComponent>(camera.w/gScale-64,88,128*gScale,12*gScale,gScale);
|
||||
// uiBoundary2Info.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
|
||||
// uiBoundary2Info.addComponent<UITextComponent>("font", "nan",fontSize.x,fontSize.y, gScale);
|
||||
// uiBoundary2Info.addGroup(groupUI_Layer3);
|
||||
//
|
||||
// uiBoundary3Info.addComponent<TransformComponent>(camera.w/gScale-64,101,128*gScale,12*gScale,gScale);
|
||||
// uiBoundary3Info.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
|
||||
// uiBoundary3Info.addComponent<UITextComponent>("font", "nan",fontSize.x,fontSize.y, gScale);
|
||||
// uiBoundary3Info.addGroup(groupUI_Layer3);
|
||||
|
||||
// debug UI box
|
||||
@ -207,7 +218,7 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
|
||||
debugBoxRect.w = 98*gScale;
|
||||
debugBoxRect.h = 112*gScale;
|
||||
debugBox = new UINineSlice("textBox");
|
||||
debugBox->MakeSlices("textBox",32,32,14,16,14,16,debugBoxRect,1,Game::groupUI_Layer2);
|
||||
debugBox->MakeSlices("textBox",nineSliceSize.x,nineSliceSize.y,nineSliceX0,nineSliceX1,nineSliceY0,nineSliceY1,debugBoxRect,globalScale,Game::groupUI_Layer2);
|
||||
|
||||
//ecs implementation
|
||||
|
||||
|
@ -51,6 +51,12 @@ public:
|
||||
static bool playerIsJumping;
|
||||
static Vector2D playerPosition;
|
||||
static Vector2D pVel;
|
||||
static Vector2D fontSize;
|
||||
static Vector2D nineSliceSize;
|
||||
static int nineSliceX0;
|
||||
static int nineSliceX1;
|
||||
static int nineSliceY0;
|
||||
static int nineSliceY1;
|
||||
static SDL_Rect camera;
|
||||
static SDL_Rect levelMap;
|
||||
static AssetManager* assets;
|
||||
|
Reference in New Issue
Block a user