|
|
|
@ -79,7 +79,10 @@ void SFMLBackend::handle_events() { |
|
|
|
|
case sf::Event::MouseButtonPressed: { |
|
|
|
|
// rect::contains(x,y) for if mouse is in the button rect
|
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
default: |
|
|
|
@ -149,11 +152,10 @@ void SFMLBackend::update_entities() { |
|
|
|
|
string time = fmt::format("{:%r}", now); |
|
|
|
|
write_text(2, 14, time, 2.0f); |
|
|
|
|
|
|
|
|
|
sf::RectangleShape start_btn = box(27, 16, 8, 3, Value::DARK_MID); |
|
|
|
|
write_text(29, 16, "START", 1.0f); |
|
|
|
|
|
|
|
|
|
sf::RectangleShape done_btn = box(37, 16, 8, 3, Value::DARK_MID); |
|
|
|
|
write_text(39, 16, "DONE", 1.0f); |
|
|
|
|
stop_button.setPosition(translate(27, 15)); |
|
|
|
|
window.draw(start_button); |
|
|
|
|
start_button.setPosition(translate(37, 15)); |
|
|
|
|
window.draw(stop_button); |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|