aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBilly Brown2017-12-02 18:06:08 +0000
committerBilly Brown2017-12-02 18:06:08 +0000
commit7f2ca2c3ab881a1652cccc4268e8843f2f383260 (patch)
tree8877425f73fea40fc6704873c6eb6ebfff7f5bba
parentalmost working (diff)
downloadlongpong-7f2ca2c3ab881a1652cccc4268e8843f2f383260.tar.gz
longpong-7f2ca2c3ab881a1652cccc4268e8843f2f383260.zip

Can quit the game at any time

-rw-r--r--client/game.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/client/game.py b/client/game.py
index 8a7a031..b8c4af2 100644
--- a/client/game.py
+++ b/client/game.py
@@ -1,6 +1,7 @@
import time
import sdl2
import sdl2.ext
+import sys
class Ball:
def __init__(self, pos, vel, size):
@@ -54,6 +55,8 @@ class Game:
break
# Tell the server to start if the spacebar is pressed
self.events.poll()
+ if self.events.has_quit():
+ sys.exit(0)
if self.events.has_space():
self.client.send_start()
# Run the game loop
@@ -62,6 +65,8 @@ class Game:
def place_windows(self):
while True:
self.events.poll()
+ if self.events.has_quit():
+ sys.exit(0)
if self.events.has_num():
for numkey in self.events.get_nums():
self.renderer.maximise_window(numkey)