чување 96d2bd44ee81077181261f4115dbe336511a7a87
родитељ 6b07be5002aeccc62dd1a7fe9dc810fb389402a0
Аутор: Страхиња Радић <sr@strahinja.org>
Датум: Tue, 4 Aug 2026 11:59:34 +0000
Actually draw player name input; add C-A, C-E, C-U, Home, End
Diffstat:
| M | TODO | | | 5 | ++++- |
| M | linije.c | | | 43 | ++++++++++++++++++++++++++++++++++++++++++- |
измењених датотека: 2, додавања: 46(+), брисања: 2(-)
diff --git a/TODO b/TODO
@@ -1,6 +1,9 @@
TODO
====
-< > High score?
+[~] High score?
+ [x] Updating high score
+ [ ] Saving high score to a file
+ [ ] Loading high score from a file
< > Menu?
diff --git a/linije.c b/linije.c
@@ -2,6 +2,15 @@
* any later version. Copyright (C) 2025-2026 Страхиња Радић.
* See the file LICENSE for exact copyright and license details. */
+/*
+ * Term definitions
+ *
+ * ball string A set of adjacent (horizontally, vertically or
+ * diagonally) balls with the same color
+ *
+ * popping the string
+ * Erasing all the balls in the string from the board
+ */
#include <SDL3/SDL.h>
#include <SDL3_image/SDL_image.h>
#include <assert.h>
@@ -188,7 +197,7 @@ struct Cell {
int popping;
int path;
int starting;
- int ending;
+ int ending; /* logical variables end */
SDL_FPoint coords;
int contents;
struct Cell* down;
@@ -990,7 +999,36 @@ handle_input(struct State* state, SDL_Event* event)
"SDLK_RIGHT: player_name = {%s} [%d]",
state->player_name, state->player_name_length);
break;
+ case SDLK_HOME:
+ state->input_col = 0;
+ state->redraw = 1;
+ break;
+ case SDLK_END:
+ state->input_col = state->player_name_length;
+ state->redraw = 1;
+ break;
default:
+ if (event->key.key == SDLK_A && event->key.mod & SDL_KMOD_CTRL)
+ {
+ state->input_col = 0;
+ state->redraw = 1;
+ break;
+ }
+ if (event->key.key == SDLK_E && event->key.mod & SDL_KMOD_CTRL)
+ {
+ state->input_col = state->player_name_length;
+ state->redraw = 1;
+ break;
+ }
+ if (event->key.key == SDLK_U && event->key.mod & SDL_KMOD_CTRL)
+ {
+ *state->player_name = 0;
+ state->player_name_length = 0;
+ state->input_col = 0;
+ state->redraw = 1;
+ break;
+ }
+
if (state->player_name_length < HI_SCORE_NAME_MAX
&& event->key.key >= SDLK_SPACE
&& event->key.key <= SDLK_TILDE)
@@ -1731,6 +1769,9 @@ render_dialog(struct State* state)
SDL_RenderFillRect(state->renderer, &input_rect);
_sx = input_rect.x + tsf * TER12_WIDTH;
+ render_text(state, _sx, input_rect.y, TER12_WIDTH, TER12_HEIGHT,
+ state->ter12_texture, "%s", state->player_name);
+
cursor_rect.x = _sx + tsf * TER12_WIDTH * state->input_col;
cursor_rect.y
= input_rect.y + tsf * TER12_HEIGHT - cursor_rect.h;