I now have a start/stop button for the pomodoro timer.
This commit is contained in:
parent
e1c667d816
commit
47c9cb719e
5 changed files with 18 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue