|
|
@ -79,7 +79,10 @@ void SFMLBackend::handle_events() { |
|
|
|
case sf::Event::MouseButtonPressed: { |
|
|
|
case sf::Event::MouseButtonPressed: { |
|
|
|
// rect::contains(x,y) for if mouse is in the button rect
|
|
|
|
// rect::contains(x,y) for if mouse is in the button rect
|
|
|
|
sf::Event::MouseButtonEvent btn = event.mouseButton; |
|
|
|
sf::Event::MouseButtonEvent btn = event.mouseButton; |
|
|
|
fmt::println("BUTTON: X={}, Y={}", btn.x, btn.y); |
|
|
|
bool stop_clicked = stop_button.getGlobalBounds().contains(btn.x, btn.y); |
|
|
|
|
|
|
|
bool start_clicked = start_button.getGlobalBounds().contains(btn.x, btn.y); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt::println("BUTTON: start={}, stop={}", start_clicked, stop_clicked); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
default: |
|
|
|
default: |
|
|
@ -149,11 +152,10 @@ void SFMLBackend::update_entities() { |
|
|
|
string time = fmt::format("{:%r}", now); |
|
|
|
string time = fmt::format("{:%r}", now); |
|
|
|
write_text(2, 14, time, 2.0f); |
|
|
|
write_text(2, 14, time, 2.0f); |
|
|
|
|
|
|
|
|
|
|
|
sf::RectangleShape start_btn = box(27, 16, 8, 3, Value::DARK_MID); |
|
|
|
stop_button.setPosition(translate(27, 15)); |
|
|
|
write_text(29, 16, "START", 1.0f); |
|
|
|
window.draw(start_button); |
|
|
|
|
|
|
|
start_button.setPosition(translate(37, 15)); |
|
|
|
sf::RectangleShape done_btn = box(37, 16, 8, 3, Value::DARK_MID); |
|
|
|
window.draw(stop_button); |
|
|
|
write_text(39, 16, "DONE", 1.0f); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Window_update(); |
|
|
|
Window_update(); |
|
|
|
} |
|
|
|
} |
|
|
@ -171,6 +173,12 @@ void SFMLBackend::change_face(const string name) { |
|
|
|
SFMLBackend::SFMLBackend(GameEngine &g) : window(sf::VideoMode(X_DIM, Y_DIM), "Turing's Tarpit", sf::Style::None, settings), game(g) |
|
|
|
SFMLBackend::SFMLBackend(GameEngine &g) : window(sf::VideoMode(X_DIM, Y_DIM), "Turing's Tarpit", sf::Style::None, settings), game(g) |
|
|
|
{ |
|
|
|
{ |
|
|
|
change_face("building"); |
|
|
|
change_face("building"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop_texture.loadFromFile("./assets/stop_button.png"); |
|
|
|
|
|
|
|
stop_button.setTexture(stop_texture); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
start_texture.loadFromFile("./assets/start_button.png"); |
|
|
|
|
|
|
|
start_button.setTexture(start_texture); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|