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