Fix walls rendering

master
NaiJi ✨ 4 years ago
parent 256db75f37
commit 3b7e654ac2

Binary file not shown.

@ -1,8 +1,10 @@
size
5 5
7 7
map
0 0 0 0 0
0 0 1 0 0
0 0 1 1 0
1 1 2 2 2
0 0 0 0 0
2 2 2 2 2 2 2
2 0 0 0 0 0 2
2 0 0 1 0 0 2
2 0 0 1 1 0 2
2 1 1 2 2 2 2
2 0 0 0 0 0 2
2 2 2 2 2 2 2

Binary file not shown.

@ -0,0 +1,10 @@
size
7 7
map
2 2 2 2 2 2 2
2 0 0 0 0 0 2
2 0 0 1 0 0 2
2 0 0 1 1 0 2
2 1 1 2 2 2 2
2 0 0 0 0 0 2
2 2 2 2 2 2 2

@ -21,6 +21,9 @@ Game::Game()
main_window.create(sf::VideoMode(window_side * 3, window_side * 3), "SFML-Test Application", sf::Style::Default);
main_window.setActive();
level->mapArray()[0][0]->setHeightShift(15);
level->mapArray()[0][1]->setHeightShift(10);
current_level = 1;
//loadLevel(current_level);
}
@ -112,7 +115,7 @@ void Game::renderMap()
{
const Map &map = level->mapArray();
float painter_x = 0, painter_y = 0;
float painter_x = 60, painter_y = 60;
float horizontal_shift = 0, vertical_shift = 0;
// Brush for cell sprites
@ -150,26 +153,26 @@ void Game::renderMap()
vertical_shift = static_cast<float>(map[y][x]->heightShift());
// If cell has any height value, we should draw walls for it
/*if (vertical_shift > 0)
if (vertical_shift > 0)
{
// Brush for vertical walls
sf::ConvexShape convex_wall_brush;
convex_wall_brush.setPointCount(6);
convex_wall_brush.setPoint(0, sf::Vector2f(cell_deviation + cell_width, 0.f));
convex_wall_brush.setPoint(1, sf::Vector2f(cell_deviation + cell_width, vertical_shift));
convex_wall_brush.setPoint(2, sf::Vector2f(cell_width, cell_height + vertical_shift));
convex_wall_brush.setPoint(3, sf::Vector2f(0.f, cell_height + vertical_shift));
convex_wall_brush.setPoint(4, sf::Vector2f(0.f, cell_height));
convex_wall_brush.setPoint(5, sf::Vector2f(cell_width, cell_height));
convex_wall_brush.setPointCount(6);
convex_wall_brush.setPoint(0, sf::Vector2f(cell_deviation + cell_width, -vertical_shift));
convex_wall_brush.setPoint(1, sf::Vector2f(cell_deviation + cell_width, 0.f));
convex_wall_brush.setPoint(2, sf::Vector2f(cell_width, cell_height));
convex_wall_brush.setPoint(3, sf::Vector2f(0.f, cell_height));
convex_wall_brush.setPoint(4, sf::Vector2f(0.f, cell_height - vertical_shift));
convex_wall_brush.setPoint(5, sf::Vector2f(cell_width, cell_height));
convex_wall_brush.setOutlineThickness(0);
sf::Color wall_color = map[y][x]->color();
convex_wall_brush.setFillColor(wall_color);
sf::Color wall_color(sf::Uint8(map[y][x]->color().r - 40), sf::Uint8(map[y][x]->color().g - 40), sf::Uint8(map[y][x]->color().b - 40));
convex_wall_brush.setFillColor(wall_color);
convex_wall_brush.setPosition(painter_x, painter_y);
convex_wall_brush.setPosition(painter_x + horizontal_shift, painter_y);
main_window.draw(convex_wall_brush);
}*/
}
// Draw the top surface of the cell itself
@ -179,7 +182,7 @@ void Game::renderMap()
convex_brush.setPosition(final_x, final_y);
convex_brush.setFillColor(map[y][x]->color());
main_window.draw(convex_brush);
main_window.draw(convex_brush);
if (hero_row == y && hero_col == x)
{
@ -194,7 +197,7 @@ void Game::renderMap()
}
// Move painter to next column
painter_y = 0;
painter_y = 60;
painter_x += cell_width;
}

Loading…
Cancel
Save