Back to shtanton's homepage
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/all.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/all.c b/src/all.c
index b00f45f..4fb902b 100644
--- a/src/all.c
+++ b/src/all.c
@@ -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) {