From be6adee51baf1db0dac108d5ba0f0eced18b2bb6 Mon Sep 17 00:00:00 2001 From: AngelJumbo Date: Sun, 27 Nov 2022 00:28:40 -0500 Subject: [PATCH] Change the speed while the program runs with the - and + keys --- lavat.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lavat.c b/lavat.c index d9bb818..2d0085f 100644 --- a/lavat.c +++ b/lavat.c @@ -145,6 +145,22 @@ int main(int argc, char *argv[]) { tb_clear(); tb_peek_event(&event, 10); + switch (event.ch) { + case '-': + case '_': + if (speedMult < 10) { + speedMult++; + speed = (((1 / (float)(maxX + maxY)) * 1000000) + 10000) * speedMult; + } + break; + case '+': + case '=': + if (speedMult > 1) { + speedMult--; + speed = (((1 / (float)(maxX + maxY)) * 1000000) + 10000) * speedMult; + } + break; + } if (event.key == TB_KEY_CTRL_C || event.key == TB_KEY_ESC || event.ch == 'q' || event.ch == 'Q') break; @@ -252,6 +268,8 @@ void print_help() { " Besides those colors the default one is the normal" " foreground of your terminal.\n" " -s Set the speed, from 1 to 10. (default 5)\n" + " Change the speed while the program runs " + "with the - and + keys.\n" " -r Set the radius of the metaballs, from 1 to 10. " "(default: 5)\n" " -R Set a rim for each metaball, sizes from 1 to 5."