|
|
@ -16,18 +16,19 @@ constexpr int FPS=30; |
|
|
|
constexpr int X_DIM = 1920 / 2; |
|
|
|
constexpr int X_DIM = 1920 / 2; |
|
|
|
constexpr int Y_DIM = 1080 / 2; |
|
|
|
constexpr int Y_DIM = 1080 / 2; |
|
|
|
bool window_active_out = false; |
|
|
|
bool window_active_out = false; |
|
|
|
|
|
|
|
bool show_build_log = false; |
|
|
|
|
|
|
|
|
|
|
|
void ImGui_setup(sf::RenderWindow &window) { |
|
|
|
void ImGui_setup(sf::RenderWindow &window) { |
|
|
|
bool res = SFML::Init(window); |
|
|
|
bool res = SFML::Init(window); |
|
|
|
fmt::println("IMGUI returned {}", res); |
|
|
|
fmt::println("IMGUI returned {}", res); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ImGui_update(sf::RenderWindow &window, sf::Clock &deltaClock, sf::Time &tick) { |
|
|
|
void ImGui_update(sf::RenderWindow &window, sf::Clock &deltaClock) { |
|
|
|
sf::Vector2u size = window.getSize(); |
|
|
|
sf::Vector2u size = window.getSize(); |
|
|
|
|
|
|
|
|
|
|
|
SFML::Update(window, deltaClock.restart()); |
|
|
|
SFML::Update(window, deltaClock.restart()); |
|
|
|
|
|
|
|
|
|
|
|
SetNextWindowPos(ImVec2(0, size.y / 2)); |
|
|
|
SetNextWindowPos(ImVec2(0, 0)); |
|
|
|
SetNextWindowSize(ImVec2(size.x, size.y / 2)); |
|
|
|
SetNextWindowSize(ImVec2(size.x, size.y / 2)); |
|
|
|
|
|
|
|
|
|
|
|
Begin("Build Status", &window_active_out); |
|
|
|
Begin("Build Status", &window_active_out); |
|
|
@ -44,8 +45,7 @@ void ImGui_update(sf::RenderWindow &window, sf::Clock &deltaClock, sf::Time &tic |
|
|
|
void Window_update(sf::RenderWindow &window, sf::Sprite &background) { |
|
|
|
void Window_update(sf::RenderWindow &window, sf::Sprite &background) { |
|
|
|
window.clear(); |
|
|
|
window.clear(); |
|
|
|
window.draw(background); |
|
|
|
window.draw(background); |
|
|
|
if(window_active_out) { |
|
|
|
if(show_build_log) { |
|
|
|
fmt::println(">>>> RENDER"); |
|
|
|
|
|
|
|
SFML::Render(window); |
|
|
|
SFML::Render(window); |
|
|
|
} |
|
|
|
} |
|
|
|
window.display(); |
|
|
|
window.display(); |
|
|
@ -56,8 +56,7 @@ void Handle_events(sf::RenderWindow &window) { |
|
|
|
|
|
|
|
|
|
|
|
// is this a main event loop
|
|
|
|
// is this a main event loop
|
|
|
|
while (window.pollEvent(event)) { |
|
|
|
while (window.pollEvent(event)) { |
|
|
|
if(window_active_out) { |
|
|
|
if(show_build_log) { |
|
|
|
fmt::println(">>> EVENTS"); |
|
|
|
|
|
|
|
SFML::ProcessEvent(window, event); |
|
|
|
SFML::ProcessEvent(window, event); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -69,10 +68,13 @@ void Handle_events(sf::RenderWindow &window) { |
|
|
|
break; |
|
|
|
break; |
|
|
|
case sf::Event::KeyPressed: |
|
|
|
case sf::Event::KeyPressed: |
|
|
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) { |
|
|
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape)) { |
|
|
|
window.close(); |
|
|
|
if(show_build_log) { |
|
|
|
|
|
|
|
window_active_out = false; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
window.close(); |
|
|
|
|
|
|
|
} |
|
|
|
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) { |
|
|
|
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space)) { |
|
|
|
fmt::println(">>> SET TRUE"); |
|
|
|
window_active_out = !window_active_out; |
|
|
|
window_active_out = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
@ -82,21 +84,13 @@ void Handle_events(sf::RenderWindow &window) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sf::Time Update_entities(sf::RenderWindow &window, sf::Sprite &background, sf::Clock &clock, sf::Clock &deltaClock, sf::Time &tick) { |
|
|
|
void Update_entities(sf::RenderWindow &window, sf::Sprite &background, sf::Clock &clock, sf::Clock &deltaClock) { |
|
|
|
sf::Vector2u winSize = window.getSize(); |
|
|
|
|
|
|
|
float timeStep = 1.0f / FPS; |
|
|
|
|
|
|
|
sf::Time since = clock.getElapsedTime(); |
|
|
|
|
|
|
|
sf::Time nextTick = since - tick > sf::seconds(1) ? since : tick; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
background.setPosition(0, 0); |
|
|
|
background.setPosition(0, 0); |
|
|
|
|
|
|
|
|
|
|
|
if(window_active_out) { |
|
|
|
if(show_build_log) { |
|
|
|
fmt::println("<<< UPDATE"); |
|
|
|
ImGui_update(window, deltaClock); |
|
|
|
ImGui_update(window, deltaClock, tick); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Window_update(window, background); |
|
|
|
Window_update(window, background); |
|
|
|
|
|
|
|
|
|
|
|
return nextTick; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -115,7 +109,6 @@ int main() { |
|
|
|
|
|
|
|
|
|
|
|
sf::Clock deltaClock; |
|
|
|
sf::Clock deltaClock; |
|
|
|
sf::Clock clock; |
|
|
|
sf::Clock clock; |
|
|
|
sf::Time tick = clock.getElapsedTime(); |
|
|
|
|
|
|
|
sf::Texture texture; |
|
|
|
sf::Texture texture; |
|
|
|
sf::Sprite background; |
|
|
|
sf::Sprite background; |
|
|
|
|
|
|
|
|
|
|
@ -127,11 +120,10 @@ int main() { |
|
|
|
background.setTexture(texture); |
|
|
|
background.setTexture(texture); |
|
|
|
|
|
|
|
|
|
|
|
while (window.isOpen()) { |
|
|
|
while (window.isOpen()) { |
|
|
|
fmt::println(">>>>>>>>>>>>>>>>>> WINDOW LOOP"); |
|
|
|
|
|
|
|
Handle_events(window); |
|
|
|
Handle_events(window); |
|
|
|
// preparing for refactoring this into a class or struct for everything
|
|
|
|
// preparing for refactoring this into a class or struct for everything
|
|
|
|
tick = Update_entities(window, background, clock, deltaClock, tick); |
|
|
|
Update_entities(window, background, clock, deltaClock); |
|
|
|
fmt::println("<<<<<<<<<<<<<<<< EXIT WINDOW LOOP"); |
|
|
|
show_build_log = window_active_out; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SFML::Shutdown(); |
|
|
|
SFML::Shutdown(); |
|
|
|