浏览代码

Merge branch 'master' of http://es-lab.de:60080/kzhang/Ping-Pong

kai.zhang 7 年之前
父节点
当前提交
f64de86c85
共有 2 个文件被更改,包括 0 次插入44 次删除
  1. 0 44
      probe.py
  2. 0 0
      Ping-Pong mit 2 Paddles ( Kopfprogramm).py

+ 0 - 44
probe.py

@@ -55,48 +55,4 @@ class Ball:
55 55
                 return True
56 56
         return False
57 57
 
58
-# Eigenschaften und Funktionen der Paddle definieren
59
-class Paddle:
60
-    def __init__(self, canvas, color):
61
-        self.canvas = canvas
62
-        self.id = canvas.create_rectangle(0,0, 100, 10, fill=color)
63
-        self.canvas.move(self.id, 200, 300)
64
-        self.xspeed = 0
65
-        self.canvas.bind_all('<KeyPress-Left>', self.move_left)
66
-        self.canvas.bind_all('<KeyPress-Right>', self.move_right)
67
-
68
-    def draw(self):
69
-        self.canvas.move(self.id, self.xspeed, 0)
70
-        pos = self.canvas.coords(self.id)
71
-        if pos[0] <= 0:
72
-            self.xspeed = 0
73
-        if pos[2] >= 500:
74
-            self.xspeed = 0
75
-
76
-    def move_left(self, evt):
77
-        self.xspeed = -2
78
-    def move_right(self, evt):
79
-        self.xspeed = 2
80
-
81
-# Fenster und canvas erstellen für zeichnen
82
-tk = Tk()
83
-tk.title("Ping-Pong Spiel")
84
-canvas = Canvas(tk, width=500, height=400, bd=0, bg='papaya whip')
85
-canvas.pack()
86
-label = canvas.create_text(5, 5, anchor=NW, text="Punkt: 0")
87
-tk.update()
88
-paddle = Paddle(canvas, 'blue')
89
-ball = Ball(canvas, 'red', 25, paddle)
90
-
91
-# Animation Schleife
92
-while ball.hit_bottom == False:
93
-    ball.draw()
94
-    paddle.draw()
95
-    canvas.itemconfig(label, text="Punkt: "+str(ball.score))
96
-    tk.update_idletasks()
97
-    tk.update()
98
-    time.sleep(0.01)
99 58
 
100
-# Game Over
101
-go_label = canvas.create_text(250,200,text="GAME OVER",font=("Helvetica",30))
102
-tk.update()

pingpong.py → Ping-Pong mit 2 Paddles ( Kopfprogramm).py