diff options
author | spew <devnull@localhost> | 2017-02-27 19:56:46 -0600 |
---|---|---|
committer | spew <devnull@localhost> | 2017-02-27 19:56:46 -0600 |
commit | 0ab5d34be4b8b9faa96d4691de95d6ae8c691f0b (patch) | |
tree | 8e3ae366baff80b18ccec861c1ef9471f4e17f38 /sys | |
parent | 9ce9299d17b565cb20e94cd39563fbb30533b5a8 (diff) |
games/galaxy: tweak pausing behavior
Diffstat (limited to 'sys')
-rw-r--r-- | sys/src/games/galaxy/galaxy.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/src/games/galaxy/galaxy.c b/sys/src/games/galaxy/galaxy.c index c8be68d62..cfb19161d 100644 --- a/sys/src/games/galaxy/galaxy.c +++ b/sys/src/games/galaxy/galaxy.c @@ -57,7 +57,7 @@ double LIM = 10, dt²; char *file; -int showv, showa, throttle, paused; +int showv, showa, throttle, moving; char *menustr[] = { [SAVE] "save", @@ -106,26 +106,28 @@ randcol(void) } void -pause(int p, int pri) +pause(int p, int id) { - static int paused, ppri; + static int paused, pid = -1; switch(p) { default: sysfatal("invalid pause value %d:", p); break; case 0: - if(pri > ppri) - ppri = pri; + if(pid != -1 && pid != id) + break; + pid = id; if(paused) break; paused = 1; qlock(&glxy); break; case 1: - if(!paused || pri < ppri) + if(!paused || pid != id) break; - paused = ppri = 0; + pid = -1; + paused = 0; qunlock(&glxy); break; } @@ -321,10 +323,12 @@ move(void) if(mc->buttons & 1) break; if(mc->buttons & 4) { + moving = 0; setcursor(mc, cursor); return; } } + moving = 1; od = subpt(orig, mc->xy); for(;;) { readmouse(mc); @@ -456,9 +460,11 @@ kbdthread(void*) { Keyboardctl *realkc; Rune r; + static int paused; threadsetname("keyboard"); - if(realkc = initkeyboard(nil), realkc == nil) + realkc = initkeyboard(nil); + if(realkc == nil) sysfatal("kbdthread: could not initkeyboard: %r"); for(;;) { @@ -482,6 +488,8 @@ kbdthread(void*) showa ^= 1; break; case ' ': + if(moving) + break; paused ^= 1; if(paused) { cursor = &pausecursor; |