refactored Text, box UI and reconfigured config.json

This commit is contained in:
Alan Youngblood 2023-08-04 14:34:43 -04:00
parent 4c2049a1e0
commit 6568026886
6 changed files with 75 additions and 20 deletions

View File

@ -0,0 +1,38 @@
[CMake]
Build Directory Count=1
Current Build Directory Index-Host System=0
[CMake][CMake Build Directory 0]
Build Directory Path=/home/ayoungblood/projects/KaijuSaveEarth/build
Build Type=Release
CMake Binary=/usr/bin/cmake
CMake Executable=/usr/bin/cmake
Environment Profile=
Extra Arguments=
Install Directory=
Runtime=Host System
[Launch]
Launch Configurations=Launch Configuration 0
[Launch][Launch Configuration 0]
Configured Launch Modes=execute
Configured Launchers=nativeAppLauncher
Name=KaijuSaveEarth
Type=Native Application
[Launch][Launch Configuration 0][Data]
Arguments=
Dependencies=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x02\x00\x00\x00\x1c\x00K\x00a\x00i\x00j\x00u\x00S\x00a\x00v\x00e\x00E\x00a\x00r\x00t\x00h\x00\x00\x00\x1c\x00K\x00a\x00i\x00j\x00u\x00S\x00a\x00v\x00e\x00E\x00a\x00r\x00t\x00h)
Dependency Action=Build
EnvironmentGroup=
Executable=file:///home/ayoungblood/projects/KaijuSaveEarth/build/KaijuSaveEarth
External Terminal=konsole --noclose --workdir %workdir -e %exe
Kill Before Executing Again=65536
Project Target=KaijuSaveEarth,KaijuSaveEarth
Use External Terminal=false
Working Directory=file:///home/ayoungblood/projects/KaijuSaveEarth
isExecutable=true
[Project]
VersionControlSupport=kdevgit

View File

Before

Width:  |  Height:  |  Size: 259 B

After

Width:  |  Height:  |  Size: 259 B

View File

Before

Width:  |  Height:  |  Size: 654 B

After

Width:  |  Height:  |  Size: 654 B

View File

@ -1,7 +1,7 @@
{ {
"GameName":"Beagle Rescue", "GameName":"Kaiju Save Earth",
"WindowName":"Beagle Rescue", "WindowName":"Kaiju Save Earth",
"WindowSize":{"w":427,"h":240}, "WindowSize":{"w":64,"h":64},
"WindowFullScreen": 0, "WindowFullScreen": 0,
"GlobalScale": 2 "GlobalScale": 12
} }

View File

@ -46,6 +46,13 @@ bool Game::debugMenu = false;
auto& player(manager.addEntity()); auto& player(manager.addEntity());
Vector2D Game::playerPosition; Vector2D Game::playerPosition;
Vector2D Game::pVel; 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& enemy(manager.addEntity());
auto& puppy(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("player", "assets/textures/actors/firefighter.png");
assets->AddTexture("font", "assets/textures/ui/ui-font-cloud-sans.png"); assets->AddTexture("font", "assets/textures/ui/ui-font-lorez5.png");
assets->AddTexture("textBox", "assets/textures/ui/ui-element-cloud.png"); assets->AddTexture("textBox", "assets/textures/ui/ui-element-bubble.png");
assets->AddTexture("puppy","assets/textures/actors/beaglepuppy.png"); assets->AddTexture("puppy","assets/textures/actors/beaglepuppy.png");
assets->AddTexture("collider","assets/textures/ColTex.png"); assets->AddTexture("collider","assets/textures/ColTex.png");
@ -152,8 +159,12 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
// std::string myText = "Find lost puppies!\nThey need your help!"; // std::string myText = "Find lost puppies!\nThey need your help!";
std::string myText = "Press U to Start"; 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<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); uiTextInstructions.addGroup(groupUI_Layer1);
SDL_Rect myDestRect = SDL_Rect(); 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.w = 160;
myDestRect.h = 40; myDestRect.h = 40;
my9Slice = new UINineSlice("textBox"); 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; // std::cout << "camera.w " << camera.w << std::endl;
uiInfo.addComponent<TransformComponent>(camera.w/gScale-94,10,72*gScale,96*gScale,gScale); 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", "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: ", 8, 12, gScale); // 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: ", 8, 12, gScale); uiInfo.addComponent<UITextComponent>("font", "Player PTiX: PTiY: P.x: P.y : coll: ", fontSize.x,fontSize.y, gScale);
uiInfo.addGroup(groupUI_Layer3); uiInfo.addGroup(groupUI_Layer3);
uiCamXInfo.addComponent<TransformComponent>(camera.w/gScale-48,23,40*gScale,12*gScale,gScale); 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); uiCamXInfo.addGroup(groupUI_Layer3);
uiCamYInfo.addComponent<TransformComponent>(camera.w/gScale-48,36,40*gScale,12*gScale,gScale); 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); uiCamYInfo.addGroup(groupUI_Layer3);
uiPlayerXInfo.addComponent<TransformComponent>(camera.w/gScale-49,49,40*gScale,12*gScale,gScale); 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); uiPlayerXInfo.addGroup(groupUI_Layer3);
uiPlayerYInfo.addComponent<TransformComponent>(camera.w/gScale-48,62,40*gScale,12*gScale,gScale); 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); uiPlayerYInfo.addGroup(groupUI_Layer3);
uiBoundary1Info.addComponent<TransformComponent>(camera.w/gScale-48,75,128*gScale,12*gScale,gScale); 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); uiBoundary1Info.addGroup(groupUI_Layer3);
// uiBoundary2Info.addComponent<TransformComponent>(camera.w/gScale-64,88,128*gScale,12*gScale,gScale); // 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); // uiBoundary2Info.addGroup(groupUI_Layer3);
// //
// uiBoundary3Info.addComponent<TransformComponent>(camera.w/gScale-64,101,128*gScale,12*gScale,gScale); // 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); // uiBoundary3Info.addGroup(groupUI_Layer3);
// debug UI box // 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.w = 98*gScale;
debugBoxRect.h = 112*gScale; debugBoxRect.h = 112*gScale;
debugBox = new UINineSlice("textBox"); 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 //ecs implementation

View File

@ -51,6 +51,12 @@ public:
static bool playerIsJumping; static bool playerIsJumping;
static Vector2D playerPosition; static Vector2D playerPosition;
static Vector2D pVel; 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 camera;
static SDL_Rect levelMap; static SDL_Rect levelMap;
static AssetManager* assets; static AssetManager* assets;