|
@@ -1,4 +1,4 @@
|
1
|
|
-#Programmierung 2 - Ping Pong Spiel
|
|
1
|
+# Programmierung 2 - Ping Pong Spiel
|
2
|
2
|
# Willi Schlegel, Francine Theil, Kristin Weber
|
3
|
3
|
# letzte Aenderung: 20.07.2017
|
4
|
4
|
|
|
@@ -8,6 +8,16 @@
|
8
|
8
|
import random
|
9
|
9
|
import time
|
10
|
10
|
from Tkinter import *
|
|
11
|
+import os
|
|
12
|
+import sys
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+#----------------------------------------------------------------
|
|
16
|
+# Funktion für den Neustart des Programms
|
|
17
|
+
|
|
18
|
+def restart_program():
|
|
19
|
+ python = sys.executable
|
|
20
|
+ os.execl(python, python, * sys.argv)
|
11
|
21
|
|
12
|
22
|
|
13
|
23
|
#----------------------------------------------------------------
|
|
@@ -98,6 +108,7 @@ class Paddle:
|
98
|
108
|
#----------------------------------------------------------------------------
|
99
|
109
|
# Spieloberflaeche
|
100
|
110
|
|
|
111
|
+
|
101
|
112
|
tk = Tk()
|
102
|
113
|
tk.title("Superfantastisches Ping-Pong-Spiel")
|
103
|
114
|
canvas = Canvas(tk, width=500, height=400, bd=3, bg='pink')
|
|
@@ -109,8 +120,11 @@ ball = Ball(canvas, 'white', 25, paddle)
|
109
|
120
|
|
110
|
121
|
|
111
|
122
|
|
112
|
|
-exit_button = Button(tk, text="Spiel starten", command=tk.quit)
|
113
|
|
-exit_button.pack()
|
|
123
|
+start_button = Button(tk, text="Spiel starten", command=tk.quit)
|
|
124
|
+start_button.pack()
|
|
125
|
+neustart_button = Button(tk, text="Neues Spiel", command=restart_program)
|
|
126
|
+neustart_button.pack()
|
|
127
|
+
|
114
|
128
|
tk.mainloop()
|
115
|
129
|
|
116
|
130
|
def button_action():
|
|
@@ -138,9 +152,4 @@ while ball.hit_bottom == True:
|
138
|
152
|
tk.update()
|
139
|
153
|
time.sleep(0.01)
|
140
|
154
|
|
141
|
|
-#button_action()
|
142
|
|
-#tk.mainloop()
|
143
|
155
|
|
144
|
|
-if __name__ == "__main__":
|
145
|
|
- app = Ball()
|
146
|
|
- app.mainloop()
|