Skip to content

Commit

Permalink
Solved minor bugs during refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ZgzInfinity committed Jun 22, 2022
1 parent b6a5e0d commit d365baa
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 9 deletions.
12 changes: 10 additions & 2 deletions src/Car/PlayerCar/PlayerCar.cpp
Expand Up @@ -365,6 +365,15 @@ float PlayerCar::getCollisionCurve() const {



/**
* Get if the player car has to be drawn
*/
bool PlayerCar::getDrawCar() const {
return drawCar;
}



/**
* Get the number of angers done by the blond woman
*/
Expand Down Expand Up @@ -771,12 +780,11 @@ void PlayerCar::checkCollisionSpriteInfo(Input& input, const Line* playerLine, b

if (sprite->getOffsetX() >= 0)
x2 = x2 + width * scale * sprite->getPivotColRight().x;

else
x2 = x2 - width * scale * (1 - sprite->getPivotColLeft().x);

// Check if there is collision
if (hasCrashed((((int) input.gameWindow.getSize().x) / 2.0f) + 5,
if (hasCrashed(((float) input.gameWindow.getSize().x) / 2.0f + 5,
playerW, x2, sprite->getWidthCol(), scale))
{
// Get the collision cure coefficient
Expand Down
7 changes: 7 additions & 0 deletions src/Car/PlayerCar/PlayerCar.h
Expand Up @@ -446,6 +446,13 @@ class PlayerCar : public Vehicle {



/**
* Get if the player car has to be drawn
*/
bool getDrawCar() const;



/**
* Get the number of angers done by the blond woman
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Game/Game.cpp
Expand Up @@ -467,10 +467,11 @@ void Game::handleEvent(Input& input, const float& time){

/*
* Check if the game is showing the initial animation and it is not in
* pause neither in game over neither the player car is crashing
* pause neither in game over neither the player car is crashing or is
* been relocated in the center of the road after the crashing animation
*/

if (gameStatus != State::PREPARE_ROUND && !escape && !pauseMode && !outOfTime && !player->getCrashing())
if (gameStatus != State::PREPARE_ROUND && !escape && !pauseMode && !outOfTime && !player->getCrashing() && player->getDrawCar())
// Control the player car
player->accelerationControl(input, gameStatus, time);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Input/Input.cpp
Expand Up @@ -228,7 +228,7 @@ void Input::writeDefaultInput(){
f << "CONTROL_ACCELERATE: LEFT CONTROL" << endl;
f << "CONTROL_BRAKE: LEFT ALT" << endl;
f << "CONTROL_UP_GEAR: Z" << endl;
f << "CONTROL_LOW_GEAR: RIGHT CTRL" << endl;
f << "CONTROL_DOWN_GEAR: RIGHT CONTROL" << endl;
}
// Close the flux of the Input file
f.close();
Expand Down
4 changes: 2 additions & 2 deletions src/Scene/Map/Map.cpp
Expand Up @@ -741,7 +741,6 @@ void Map::updateMap(Input &input, vector<TrafficCar*> cars, PlayerCar& p, State&
if (!currentBiome->end && !p.getCrashing()){

// Check the map elements and detects collision with them until one is true (the rest ignored)

if (playerLine->hasSpriteFarLeft)
p.checkCollisionSpriteInfo(input, playerLine, hasCrashed, playerLine->spriteFarLeft);
if (!hasCrashed && playerLine->hasSpriteNearLeft)
Expand Down Expand Up @@ -802,7 +801,8 @@ void Map::updateMap(Input &input, vector<TrafficCar*> cars, PlayerCar& p, State&
}

// Update the wheel statuses
updateCarPlayerWheels(p);
if (p.getDrawCar())
updateCarPlayerWheels(p);

//Make smoke if sliding to the side when in a huge curve
if (p.getStateWheelLeft() != StateWheel::SAND && p.getStateWheelRight() != StateWheel::SAND &&
Expand Down
2 changes: 1 addition & 1 deletion src/Scene/Point/Point.h
Expand Up @@ -186,4 +186,4 @@ typedef Point<int> iPoint;

typedef Point<float> fPoint;

#endif // __POINT_H__
#endif // POINT_H
2 changes: 1 addition & 1 deletion src/Scene/SpriteInfo/SpriteInfo.cpp
Expand Up @@ -64,7 +64,7 @@ SpriteInfo::SpriteInfo(sf::Texture* _textureSprite, const fPoint _pivotLeft, con
offsetX = _offsetX;
offsetY = _offsetY;
side = _side;
pivotColLeft = pivotColLeft;
pivotColLeft = _pivotColLeft;
pivotColRight = _pivotColRight;
};

Expand Down

0 comments on commit d365baa

Please sign in to comment.