Before changing to static libraries

This commit is contained in:
2022-07-04 09:42:42 -04:00
parent 70402c5382
commit 21c30b7f52
4 changed files with 35 additions and 28 deletions

View File

@ -186,7 +186,7 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
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 : dMvX: diff: bMax:", 8, 12, gScale);
uiInfo.addComponent<UITextComponent>("font", "Player PTiX: PTiY: P.x: P.y : coll: Px2 bnd ", 8, 12, gScale);
uiInfo.addGroup(groupUI_Layer3);
uiCamXInfo.addComponent<TransformComponent>(camera.w/gScale-48,23,40*gScale,12*gScale,gScale);
@ -205,23 +205,18 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g
uiPlayerYInfo.addComponent<UITextComponent>("font", "nan", 8, 12, gScale);
uiPlayerYInfo.addGroup(groupUI_Layer3);
uiBoundary1Info.addComponent<TransformComponent>(camera.w/gScale-48,75,40*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.addGroup(groupUI_Layer3);
uiBoundary2Info.addComponent<TransformComponent>(camera.w/gScale-48,88,40*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.addGroup(groupUI_Layer3);
uiBoundary3Info.addComponent<TransformComponent>(camera.w/gScale-48,101,40*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.addGroup(groupUI_Layer3);
// uiJumpInfo.addComponent<TransformComponent>(camera.w-48,48,40,12,gScale);
// uiJumpInfo.addComponent<UITextComponent>("font", "false", 8, 12, 1);
// uiJumpInfo.addGroup(groupUI_Layer3);
// debug UI box
SDL_Rect debugBoxRect = SDL_Rect();
debugBoxRect.x = camera.w-(100*gScale);
@ -350,8 +345,8 @@ void Game::update()
camera.x = player.getComponent<TransformComponent>().position.x - camera.w/2 + player.getComponent<TransformComponent>().width/2;
camera.y = player.getComponent<TransformComponent>().position.y - camera.h/2 + player.getComponent<TransformComponent>().height/2;
pTileX = player.getComponent<TransformComponent>().position.x/gScale/tileMap.tileWidth;
pTileY = player.getComponent<TransformComponent>().position.y/gScale/tileMap.tileWidth;
pTileX = (player.getComponent<TransformComponent>().position.x+player.getComponent<TransformComponent>().width/2)/gScale/tileMap.tileWidth;
pTileY = (player.getComponent<TransformComponent>().position.y+player.getComponent<TransformComponent>().height/2)/gScale/tileMap.tileWidth;
player.getComponent<TransformComponent>().updateTilePosition(pTileX,pTileY);
@ -370,14 +365,20 @@ void Game::update()
max = foundBoundaries[b];
}
}
int desiredMovementX = std::abs(-1*player.getComponent<TransformComponent>().speed*player.getComponent<TransformComponent>().scale);
float desiredMovementX = -1*player.getComponent<TransformComponent>().speed*0.016;
// int desiredMovementY = player.getComponent<TransformComponent>().velocity.y*player.getComponent<TransformComponent>().speed*player.getComponent<TransformComponent>().scale;
// uiBoundary1Info.getComponent<UITextComponent>().updateString(std::to_string((int)foundBoundaries[0]));
uiBoundary1Info.getComponent<UITextComponent>().updateString(std::to_string((int)desiredMovementX));
// uiBoundary1Info.getComponent<UITextComponent>().updateString(std::to_string((float)desiredMovementX));
if (playerIsGrounded) {
uiBoundary1Info.getComponent<UITextComponent>().updateString("yes");
} else {
uiBoundary1Info.getComponent<UITextComponent>().updateString("no");
}
// uiBoundary2Info.getComponent<UITextComponent>().updateString(std::to_string((int)foundBoundaries[1]));
int difference = player.getComponent<TransformComponent>().position.x-max;
uiBoundary2Info.getComponent<UITextComponent>().updateString(std::to_string((int)difference));
uiBoundary3Info.getComponent<UITextComponent>().updateString(std::to_string((int)max));
float difference = player.getComponent<TransformComponent>().position.x+desiredMovementX;
uiBoundary2Info.getComponent<UITextComponent>().updateString(std::to_string((float)difference));
uiBoundary3Info.getComponent<UITextComponent>().updateString(std::to_string((int)(max*gScale)));
// uiBoundary3Info.getComponent<UITextComponent>().updateString(std::to_string((int)foundBoundaries[2]));
playerPosition.x = playerX;
@ -507,6 +508,7 @@ int * Game::predictCollisions(){
}
}
}
/*
// ====== RIGHT ====
if (player.getComponent<TransformComponent>().velocity.x>0){
// ====== For Each Row ====
@ -558,6 +560,7 @@ int * Game::predictCollisions(){
}
}
}
}
}
*/
return boundaries;
}