Before changing to static libraries
This commit is contained in:
parent
70402c5382
commit
21c30b7f52
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
{
|
||||
"GameName":"Beagle Rescue",
|
||||
"WindowName":"Beagle Rescue",
|
||||
"WindowSize":{"w":320,"h":200},
|
||||
"WindowSize":{"w":320,"h":240},
|
||||
"WindowFullScreen": 0,
|
||||
"GlobalScale": 4
|
||||
"GlobalScale": 3
|
||||
}
|
||||
|
@ -83,23 +83,26 @@ public:
|
||||
|
||||
int *borders;
|
||||
borders = Game::predictCollisions();
|
||||
int max = borders[0];
|
||||
float max = borders[0];
|
||||
for (int b=0;b<3;b++){
|
||||
if (borders[b]>max){
|
||||
max = borders[b];
|
||||
}
|
||||
}
|
||||
int desiredMovement = std::abs(-1*transform->speed*transform->scale);
|
||||
int difference = transform->velocity.x-max*transform->scale;
|
||||
// if(difference>desiredMovement){
|
||||
float desiredMovement = -1*transform->speed*0.016; // 0.016 is the FrameTime from the Main.cpp core game loop. later, we will pass in the variable
|
||||
float difference = std::abs(max-transform->position.x);
|
||||
if(max*transform->scale<desiredMovement+transform->position.x){
|
||||
Game::playerIsGrounded = false;
|
||||
transform->velocity.x = -1;
|
||||
sprite->Play("Walk");
|
||||
sprite->spriteFlip = SDL_FLIP_NONE;
|
||||
// }else{
|
||||
// // transform->velocity.x = -difference/desiredMovement;
|
||||
// sprite->Play("Walk");
|
||||
// sprite->spriteFlip = SDL_FLIP_NONE;
|
||||
// }
|
||||
}else{
|
||||
// transform->velocity.x = -difference/desiredMovement;
|
||||
Game::playerIsGrounded = true;
|
||||
transform->velocity.x = 0;
|
||||
sprite->Play("Idle");
|
||||
sprite->spriteFlip = SDL_FLIP_NONE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDLK_RIGHT:
|
||||
@ -183,6 +186,7 @@ public:
|
||||
if(Game::gsm->currentState == GameStateManager::ST_COREGAME){
|
||||
transform->velocity.x = 0;
|
||||
sprite->Play("Idle");
|
||||
Game::playerIsGrounded = false;
|
||||
// if (!Game::gravityOnPlayer){
|
||||
// Game::gravityOnPlayer = true;
|
||||
// // sprite->Play("Fall");
|
||||
|
@ -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 ====
|
||||
@ -559,5 +561,6 @@ int * Game::predictCollisions(){
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return boundaries;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user