@ -79,10 +79,11 @@ 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 ;
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 ) ;
if ( stop_button . getGlobalBounds ( ) . contains ( btn . x , btn . y ) ) {
buttons = Button : : STOP ;
} else if ( start_button . getGlobalBounds ( ) . contains ( btn . x , btn . y ) ) {
buttons = Button : : START ;
}
break ;
}
default :
@ -148,9 +149,17 @@ void SFMLBackend::update_entities() {
game . streak , game . deaths ) ;
write_text ( X_ROWS / 4 + 5 , 2 , status ) ;
std : : chrono : : time_point < std : : chrono : : system_clock > now = std : : chrono : : system_clock : : now ( ) ;
string time = fmt : : format ( " {:%r} " , now ) ;
write_text ( 2 , 14 , time , 2.0f ) ;
if ( buttons = = Button : : START ) {
// better thing here please
} else if ( buttons = = Button : : STOP ) {
clock_start = std : : chrono : : system_clock : : now ( ) ;
}
auto elapsed_time = std : : chrono : : system_clock : : now ( ) - clock_start ;
string time = format ( " {:%H:%M:%OS} " , elapsed_time ) ;
write_text ( 7 , 14 , time , 2.0f ) ;
stop_button . setPosition ( translate ( 27 , 15 ) ) ;
window . draw ( start_button ) ;