mostly imgui update
This commit is contained in:
parent
0fc6c50009
commit
69130c3d94
|
|
@ -2,15 +2,15 @@ framerate 60
|
|||
|
||||
playerStartPos 900 900
|
||||
|
||||
playerSize 250 10
|
||||
playerSize 500 10
|
||||
|
||||
playerSpeed 10
|
||||
playerSpeed 5
|
||||
|
||||
playerColor 1 1 1
|
||||
|
||||
ballRadius 5
|
||||
|
||||
ballSpeed 5
|
||||
ballSpeed 10
|
||||
|
||||
ballColor 1 0 0
|
||||
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@ private:
|
|||
sf::Vector2f playerStartPos{};
|
||||
sf::Vector2f brickHalfSize{};
|
||||
sf::Vector2f playerHalfSize{};
|
||||
unsigned int totalSpecialBricks{};
|
||||
unsigned int totalBricks{};
|
||||
unsigned int framerate{};
|
||||
int totalSpecialBricks{};
|
||||
int totalBricks{};
|
||||
int framerate{};
|
||||
float playerSpeed{};
|
||||
float ballRadius{};
|
||||
float ballMaxSpeed{};
|
||||
|
|
@ -104,5 +104,4 @@ private:
|
|||
Color specialBrickColor{};
|
||||
bool windowCollasped{false};
|
||||
static constexpr unsigned int numPhysicsUpdates{4};
|
||||
|
||||
};
|
||||
73
src/Game.cpp
73
src/Game.cpp
|
|
@ -57,18 +57,18 @@ Game::Game()
|
|||
|
||||
void Game::setupLevel()
|
||||
{
|
||||
const unsigned int specialBrickInterval = totalBricks / totalSpecialBricks;
|
||||
const int specialBrickInterval = totalBricks / totalSpecialBricks;
|
||||
|
||||
constexpr float xSpacing = 20.f;
|
||||
constexpr float ySpacing = 20.f;
|
||||
const float xOffset = brickSize.x + xSpacing;
|
||||
const float yOffset = brickSize.y + ySpacing;
|
||||
const unsigned int numRows = window.getSize().x / xOffset;
|
||||
const unsigned int numColumns = (window.getSize().y - 300)/ yOffset;
|
||||
unsigned int row{};
|
||||
unsigned int column{};
|
||||
const int numRows = window.getSize().x / xOffset;
|
||||
const int numColumns = (window.getSize().y - 300)/ yOffset;
|
||||
int row{};
|
||||
int column{};
|
||||
|
||||
for (size_t i = 0; i < totalBricks; i++)
|
||||
for (int i = 0; i < totalBricks; i++)
|
||||
{
|
||||
if (row >= numRows)
|
||||
{
|
||||
|
|
@ -181,6 +181,7 @@ void Game::input()
|
|||
|
||||
case sf::Keyboard::Scan::F1:
|
||||
windowCollasped = !windowCollasped;
|
||||
ImGui::SetNextWindowCollapsed(windowCollasped);
|
||||
break;
|
||||
|
||||
case sf::Keyboard::Scan::R:
|
||||
|
|
@ -211,19 +212,19 @@ void Game::input()
|
|||
}
|
||||
}
|
||||
|
||||
if (const auto* MouseButtonPressed = event->getIf<sf::Event::MouseButtonPressed>())
|
||||
{
|
||||
switch (MouseButtonPressed->button)
|
||||
{
|
||||
case sf::Mouse::Button::Left:
|
||||
//specialBricks.emplace_back((sf::Vector2f)MouseButtonPressed->position);
|
||||
break;
|
||||
// if (const auto* MouseButtonPressed = event->getIf<sf::Event::MouseButtonPressed>())
|
||||
// {
|
||||
// switch (MouseButtonPressed->button)
|
||||
// {
|
||||
// case sf::Mouse::Button::Left:
|
||||
// //specialBricks.emplace_back((sf::Vector2f)MouseButtonPressed->position);
|
||||
// break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -446,17 +447,46 @@ void Game::movement()
|
|||
|
||||
void Game::imgui()
|
||||
{
|
||||
|
||||
ImGui::Begin("menu");
|
||||
ImGui::SetWindowCollapsed(true);
|
||||
ImGui::SetNextWindowCollapsed(windowCollasped, ImGuiCond_Once);
|
||||
ImGui::SetNextWindowSize({490,375}, ImGuiCond_Once);
|
||||
ImGui::SetNextWindowPos({26,29}, ImGuiCond_Once);
|
||||
if(!ImGui::Begin("menu"))
|
||||
{
|
||||
ImGui::End();
|
||||
return;
|
||||
}
|
||||
ImGui::Text("Controls:");
|
||||
ImGui::Indent();
|
||||
ImGui::Text("A/D or arrow keys: move left and right");
|
||||
ImGui::Text("R: reset game");
|
||||
ImGui::Text("F1: expand/collaspe this window");
|
||||
ImGui::Text("left click: spawn brick");
|
||||
ImGui::Unindent();
|
||||
|
||||
ImGui::Text("Level config:");
|
||||
if(ImGui::InputInt("Total bricks", &totalBricks))
|
||||
{
|
||||
if (totalBricks < 0)
|
||||
totalBricks = 0;
|
||||
|
||||
if (totalSpecialBricks > totalBricks)
|
||||
totalSpecialBricks = totalBricks;
|
||||
}
|
||||
|
||||
if(ImGui::InputInt("Special bricks", &totalSpecialBricks))
|
||||
{
|
||||
if (totalSpecialBricks < 0)
|
||||
totalSpecialBricks = 0;
|
||||
|
||||
if (totalSpecialBricks > totalBricks)
|
||||
totalSpecialBricks = totalBricks;
|
||||
}
|
||||
|
||||
if(ImGui::Button("Reload Level"))
|
||||
{
|
||||
resetGame();
|
||||
}
|
||||
|
||||
ImGui::Text("Game config:");
|
||||
ImGui::SliderFloat("Player Speed", &playerSpeed, 1.f, 50.f);
|
||||
ImGui::SliderFloat("Ball Speed", &ballMaxSpeed, 1.f, 50.f);
|
||||
if (ImGui::SliderFloat("Player Length", &playerSize.x, 1.f, 600.f))
|
||||
|
|
@ -545,6 +575,7 @@ void Game::run()
|
|||
imgui();
|
||||
|
||||
render();
|
||||
|
||||
}
|
||||
|
||||
ImGui::SFML::Shutdown();
|
||||
|
|
|
|||
Loading…
Reference in New Issue