diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2025-04-05 15:33:27 +0100 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2025-04-05 15:33:27 +0100 |
commit | b03e011bfeeae336f2648ea61fa2554ccdcf07a1 (patch) | |
tree | a1d3cfbed6a2d9b85a66230c8176a0469934c885 | |
parent | f836fce772695c4cd5913dd46f49f071efbea63d (diff) | |
download | ldjam57-b03e011bfeeae336f2648ea61fa2554ccdcf07a1.tar |
Add right click to remove
-rw-r--r-- | src/all.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -61,6 +61,7 @@ typedef struct { enum { INPUT_NONE, INPUT_CLICK, + INPUT_RCLICK, INPUT_PAUSE_PLAY, }; @@ -178,6 +179,11 @@ static void update(Game *game, uint64_t now, Arena a) { y = game->mousey * GRIDHEIGHT / game->ui.height; game->state.grid[x + y * GRIDWIDTH] = (game->state.grid[x + y * GRIDWIDTH] + 1) % (sizeof(colors) / sizeof(colors[0])); break; + case INPUT_RCLICK: + x = game->mousex * GRIDWIDTH / game->ui.width; + y = game->mousey * GRIDHEIGHT / game->ui.height; + game->state.grid[x + y * GRIDWIDTH] = EMPTY; + break; case INPUT_PAUSE_PLAY: game->state.playing = !game->state.playing; break; @@ -336,9 +342,13 @@ int main(int argc, char **argv) { case SDL_EVENT_QUIT: return 0; case SDL_EVENT_MOUSE_BUTTON_DOWN: - game->input = INPUT_CLICK; game->mousex = (int) e.button.x; game->mousey = (int) e.button.y; + if (e.button.button == 1) { + game->input = INPUT_CLICK; + } else if (e.button.button == 3) { + game->input = INPUT_RCLICK; + } break; case SDL_EVENT_KEY_DOWN: switch (e.key.key) { |