World: Rename wallColor to fillColor
As this function will get more generic, make the names more generic. Fix some comments and indentation.
This commit is contained in:
parent
a0b6536432
commit
92daf5551f
2 changed files with 5 additions and 5 deletions
|
@ -205,13 +205,13 @@ float World::castRay(float originX, float originY, float orientation) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::fillColumn(sf::RenderWindow& window, unsigned int column,
|
void World::fillColumn(sf::RenderWindow& window, unsigned int column,
|
||||||
float scale, sf::Color wallColor) const
|
float scale, sf::Color fillColor) const
|
||||||
{
|
{
|
||||||
float columnHeight = static_cast<float>(window.getSize().y)*scale;
|
float columnHeight = static_cast<float>(window.getSize().y)*scale;
|
||||||
sf::RectangleShape pixelColumn(sf::Vector2f(1,columnHeight));
|
sf::RectangleShape pixelColumn(sf::Vector2f(1,columnHeight));
|
||||||
pixelColumn.setPosition(static_cast<float>(column),
|
pixelColumn.setPosition(static_cast<float>(column),
|
||||||
(static_cast<float>(window.getSize().y)-columnHeight)/2.0f);
|
(static_cast<float>(window.getSize().y)-columnHeight)/2.0f);
|
||||||
pixelColumn.setFillColor(wallColor);
|
pixelColumn.setFillColor(fillColor);
|
||||||
|
|
||||||
window.draw(pixelColumn);
|
window.draw(pixelColumn);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ void World::render(sf::RenderWindow& window) const
|
||||||
rayAngle -= 360;
|
rayAngle -= 360;
|
||||||
}
|
}
|
||||||
float obstacleScale = player.focalLength*2/(castRay(player.x, player.y, rayAngle)*player.sensorSize);
|
float obstacleScale = player.focalLength*2/(castRay(player.x, player.y, rayAngle)*player.sensorSize);
|
||||||
/* 2 Is wall height in meters. */
|
/* 2 Is wall height in meters. */
|
||||||
fillColumn(window, i, obstacleScale);
|
fillColumn(window, i, obstacleScale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
4
World.h
4
World.h
|
@ -52,9 +52,9 @@ private:
|
||||||
sf::Color ceilingColor;
|
sf::Color ceilingColor;
|
||||||
|
|
||||||
void fillColumn(sf::RenderWindow&, unsigned int column, float scale,
|
void fillColumn(sf::RenderWindow&, unsigned int column, float scale,
|
||||||
sf::Color wallColor = sf::Color(84,56,34)) const;
|
sf::Color fillColor = sf::Color(84,56,34)) const;
|
||||||
/**
|
/**
|
||||||
* Cast a ray from a given position and its distance to the origin.
|
* Cast a ray from a given position and return its distance to the origin.
|
||||||
* @param originX Ray X origin, strictly positive
|
* @param originX Ray X origin, strictly positive
|
||||||
* @param originY Ray Y origin, strictly positive
|
* @param originY Ray Y origin, strictly positive
|
||||||
* @param orientation Angle to cast to, in degrees between 0 and 360
|
* @param orientation Angle to cast to, in degrees between 0 and 360
|
||||||
|
|
Loading…
Add table
Reference in a new issue