diff options
-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) { |