-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathball.py
More file actions
32 lines (25 loc) · 701 Bytes
/
Copy pathball.py
File metadata and controls
32 lines (25 loc) · 701 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from turtle import Turtle
import random
class Ball(Turtle):
def __init__(self):
super().__init__()
# self.dot(20, 'white')
self.shape('circle')
self.color('white')
self.penup()
self.x_move = 10
self.y_move = 10
self.move_speed = 0.1
def moveright(self):
new_x = self.xcor() + self.x_move
new_y = self.ycor() + self.y_move
self.goto(new_x, new_y)
def wall_bounce(self):
self.y_move *= -1
def paddle_bounce(self):
self.x_move *= -1
self.move_speed *= 0.9
def reset_position(self):
self.goto(0, 0)
self.move_speed = 0.1
self.paddle_bounce()