diff options
Diffstat (limited to 'src/ray.c')
-rw-r--r-- | src/ray.c | 46 |
1 files changed, 21 insertions, 25 deletions
@@ -118,17 +118,6 @@ draw_calc(void) states[current_state].x, states[current_state].y); } -void -display_calc(int x, int y) -{ - states[current_state].x = x; - states[current_state].y = y; - BeginDrawing(); - ClearBackground(RAYWHITE); - draw_calc(); - EndDrawing(); -} - static void draw_input(void) { @@ -162,7 +151,6 @@ static void draw_res(void) { char txt[64] = {0}; - char *suffix; Color col; int win_width, win_height; int txt_width; @@ -171,33 +159,26 @@ draw_res(void) win_width = GetScreenWidth(); win_height = GetScreenHeight(); - for (int i = 0; i < STATE_COUNT; i++) + for (int i = 1; i < STATE_COUNT; i++) { - j = (current_state + i)%STATE_COUNT; + int j = (current_state - i)%STATE_COUNT; if (states[j].ms == 0) break; if (states[j].right) - { - suffix = "RIGHT"; col = GREEN; - } else - { - suffix = "WRONG"; col = RED; - } - sprintf(txt, "%d + %d = %d (%s) %dms", + sprintf(txt, "%d + %d = %d %dms", states[j].x, states[j].y, - states[j].input, - suffix, states[j].ms); + states[j].input, states[j].ms); - font_size = min(win_height/8, MAX_FONTSIZE/2); + font_size = min(win_height/STATE_COUNT, MAX_FONTSIZE/2); txt_width = MeasureText(txt, font_size); /* TODO: draw every results */ - DrawText(txt, win_width-txt_width, 0, font_size, col); + DrawText(txt, win_width-txt_width, (int) font_size*1.2*i, font_size, col); } } @@ -212,6 +193,21 @@ redraw(void) EndDrawing(); } +void +display_calc(int x, int y) +{ + current_state = (current_state + 1)%STATE_COUNT; + states[current_state].x = x; + states[current_state].y = y; + states[current_state].ms = 0; + states[current_state].input = 0; + /* BeginDrawing(); */ + /* ClearBackground(RAYWHITE); */ + /* draw_calc(); */ + /* EndDrawing(); */ + redraw(); +} + static void add_input_digit(int digit) { |