-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ball.py
54 lines (40 loc) · 1.11 KB
/
Ball.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#Ball class for Breakout game
#Jasmine Mai
from cs1lib import *
class Ball:
def __init__(self, x, y, radius, r, g, b, velocity_x, velocity_y):
self.x = x
self.y = y
self.radius = radius
self.r = r
self.g = g
self.b = b
self.velocity_x = velocity_x
self.velocity_y = velocity_y
#move the ball
def move(self):
self.x += self.velocity_x
self.y += self.velocity_y
#draw the ball
def draw(self):
set_fill_color(self.r, self.g, self.b)
draw_ellipse(self.x, self.y, self.radius, self.radius)
#getters and setters
def get_x (self):
return self.x
def get_y(self):
return self.y
def set_x (self, x):
self.x = x
def set_y(self, y):
self.y = y
def get_radius (self):
return self.radius
def get_velocityX(self):
return self.velocity_x
def get_velocityY(self):
return self.velocity_y
def set_velocityY(self, velocity):
self.velocity_y = velocity
def set_velocityX(self, velocity):
self.velocity_x = velocity